VanRtkDbg/Assets/Scripts/CellMap.cs

50 lines
1000 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CellMap : MonoBehaviour
{
[System.Serializable]
public struct CellRow
{
public Cell[] cells;
}
public CellRow[] cellMapData;
public int column = 0;
public int row = 0;
// Start is called before the first frame update
void Start()
{
for (int y = 0; y < cellMapData.Length; y++)
{
for (int x = 0; x < cellMapData[y].cells.Length; x++)
{
cellMapData[y].cells[x].xPos = x;
cellMapData[y].cells[x].yPos = y;
}
}
row = cellMapData.Length;
column = cellMapData[0].cells.Length;
}
// Update is called once per frame
void Update()
{
}
public Cell GetCell(int x, int y)
{
return cellMapData[y].cells[x];
}
public bool IsCellEmpty(int x, int y)
{
return GetCell(x, y).standingUnit == null;
}
}