Esempio n. 1
0
        public void SpawnMap(Map map)
        {
            MapMakerManager.Instance.FlushTiles();

            int height = map.height;
            int width  = map.width;

            MapMakerManager.Instance.Tiles = new List <MapMakerTileController>();
            Vector3 current = new Vector3();

            for (int x = 0; x < width; x++)
            {
                map.MapTiles[x] = new MapTile[height];
                for (int y = 0; y < height; y++)
                {
                    map.MapTiles[x][y] = new MapTile();
                    GameObject go = Instantiate(MapTilePrefab, MapContainer.transform);
                    go.transform.localPosition = current;
                    MapMakerTileController tile = go.GetComponent <MapMakerTileController>();
                    tile.xIndex = x;
                    tile.yIndex = y;
                    tile.MyTile = map.MapTiles[x][y];
                    MapMakerManager.Instance.Tiles.Add(tile);

                    current = new Vector3(current.x, current.y + Offset, 0);
                }
                current = new Vector3(current.x + Offset, 0, 0);
            }
        }
Esempio n. 2
0
 public void FlushTiles()
 {
     for (int i = Tiles.Count - 1; i >= 0; i--)
     {
         MapMakerTileController go = Tiles[i];
         Tiles.Remove(go);
         Destroy(go.gameObject);
     }
 }
Esempio n. 3
0
 public void SelectTile(MapMakerTileController selected)
 {
     foreach (var item in MapMakerManager.Instance.Tiles)
     {
         if (!item.Equals(selected))
         {
             item.UnSelect();
         }
     }
     if (!selected.IsSelected)
     {
         selected.Select();
         SelectedTab.SetActive(true);
     }
     else
     {
         selected.UnSelect();
         SelectedTab.SetActive(false);
     }
 }