Example #1
0
        public void AddHexEditor()
        {
            if (tiles != null)
            {
                HexTileEditor editor = tiles[0].GetComponent <HexTileEditor>();

                foreach (HexTile tile in tiles)
                {
                    tile.gameObject.AddComponent <HexTileEditor>();
                }
            }
        }
Example #2
0
        public void ChangeTile(HexGrid grid)
        {
            if ((int)tileType == Enum.GetNames(typeof(TileType)).Length - 1)
            {
                this.tileType = 0;
            }
            else
            {
                this.tileType += 1;
            }

            // Create the new tile
            HexTile       newTile   = HexTile.Create(grid, tileType, transform.position, this.gameObject.GetComponent <HexTile>().Coordinates);
            HexTileEditor newEditor = newTile.gameObject.AddComponent <HexTileEditor>();

            newEditor.tileType = this.tileType;

            // Remove the old, add the new.
            grid.Tiles.Remove(this.gameObject.GetComponent <HexTile>());
            grid.Tiles.Add(newTile.GetComponent <HexTile>());

            Destroy(this.gameObject);
        }