Skip to main content

45度角地图

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TileMap : MonoBehaviour
{

public GameObject[] floorArray;
public GameObject[] outWallArray;

public int row;
public int column;

public float canvasWidth = 1024 / 100;
public float canvasHeight = 768 / 100;
public float tileWidth = 1;
public float tileHeight = 0.5f;


// Start is called before the first frame update
void Start()
{
InitMap();
}

// Update is called once per frame
void Update()
{

}

void InitMap()
{

float w, h = 0;
int index;
for (int x = 0; x < row; x++)
{
for (int y = 0; y < column; y++)
{
index = y % 2;

if (index == 1)
{
w = x + 0.5f;
}
else
{
w = x;
}

h = y * tileHeight / 2;

GameObject.Instantiate(outWallArray[index], new Vector3(w, h, 0), Quaternion.identity);
}
}


}
}