public void FindCitadel() { var neighbours = GetNeighbouringCities(); CitadelRef = neighbours.Select( x => BoardManager.FindTile(HexGridHelper.FindNeighbour(TileRef.Coord, x)) .CityRef.GetComponent <CastleTileMasterBase>()).First(y => y is CitadelTileMaster).gameObject; this.transform.SetParent(CitadelRef.transform); }
public IEnumerable <Compass> GetNeighbouringCities() { var result = new List <Compass>(); var dirsToCheck = new[] { Compass.West, Compass.NorthWest, Compass.NorthEast, Compass.East, Compass.SouthEast, Compass.SouthWest }; foreach (var dir in dirsToCheck) { var nCoords = HexGridHelper.FindNeighbour(TileRef.Coord, dir); if (BoardManager.IsTileCity(nCoords)) { result.Add(dir); } } return(result); }
// Use this for initialization public void DrawCliffs(TileGenData[,] mainBoard) { this.Cliffs.HideAll(); var tile = this.GetComponent <TileInfo>(); var dirsToCheck = new[] { Compass.West, Compass.NorthWest, Compass.NorthEast, Compass.East, Compass.SouthEast, Compass.SouthWest }; foreach (var d in dirsToCheck) { var n = HexGridHelper.FindNeighbour(tile.Coord, d); if (BoardManager.IsCoordValid(n)) { var adj = mainBoard[n.XCoord, n.YCoord]; if (adj.Height < tile.Height - 1) { switch (d) { case Compass.East: this.Cliffs.EEdge.SetActive(true); break; case Compass.SouthEast: this.Cliffs.SEEdge.SetActive(true); break; case Compass.SouthWest: this.Cliffs.SWEdge.SetActive(true); break; case Compass.West: this.Cliffs.WEdge.SetActive(true); break; case Compass.NorthWest: this.Cliffs.NWEdge.SetActive(true); break; case Compass.NorthEast: this.Cliffs.NEEdge.SetActive(true); break; } } } } }
private void ExpandOnNeighbours() { var neighbours = GetNeighbouringCities(); var adjacentNeighbours = HexGridHelper.GetAdjacentSides(neighbours); foreach (var an in adjacentNeighbours) { Towers.GetComponent <VertexManager>().GetVertexFromTwoSides(an.Value1, an.Value2).SetActive(false); } foreach (var n in neighbours) { Walls.GetComponent <EdgeManager>().GetEdge(n).SetActive(false); Gates.GetComponent <EdgeManager>().GetEdge(n).SetActive(false); var towers = Towers.GetComponent <VertexManager>().GetVertexFromSide(n); towers[0].SetActive(false); towers[1].SetActive(false); BoardManager.FindTile(HexGridHelper.FindNeighbour(TileRef.Coord, n)) .CityRef.GetComponent <CastleTileMasterBase>() .ReactToExpansion(); } }