1
Fork 0
mirror of https://github.com/Steffo99/octogem.git synced 2024-11-25 06:24:19 +00:00
octogem/Assets/Scripts/Components/Map.cs

32 lines
954 B
C#
Raw Permalink Normal View History

2018-09-30 14:35:17 +00:00
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
}
}
}
}