1
Fork 0
mirror of https://github.com/Steffo99/octogem.git synced 2024-11-22 04:54:18 +00:00
octogem/Assets/Scripts/Components/Map.cs

31 lines
954 B
C#

using UnityEngine;
using System.Collections.Generic;
public class Map : MonoBehaviour
{
public Vector2Int mapSize;
public Tile[,] tiles;
public List<Unit> units;
private BaseObjects bases;
private void Awake()
{
bases = FindObjectOfType<BaseObjects>();
//Create the tiles
tiles = new Tile[mapSize.x, mapSize.y];
for(int y = 0; y < mapSize.y; y++)
{
for(int x = 0; x < mapSize.x; x++)
{
GameObject currentTileObject = Instantiate(bases.baseTile, transform);
Tile currentTile = currentTileObject.GetComponent<Tile>();
tiles[x, y] = currentTile;
currentTile.transform.position = new Vector3(x, y);
currentTile.position.Position = new MapPosition(x, y);
currentTile.Type = bases.tileTypes["Empty"];
//TODO: tilerenderer
}
}
}
}