示例#1
0
文件: SetupMap.cs 项目: Sindrex/Sire
        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);
            }
        }
示例#2
0
 public void FlushTiles()
 {
     for (int i = Tiles.Count - 1; i >= 0; i--)
     {
         MapMakerTileController go = Tiles[i];
         Tiles.Remove(go);
         Destroy(go.gameObject);
     }
 }
示例#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);
     }
 }