private bool[][][] getAllowedStaedteByClient(CatanClient client) { if (client.SpielfigurenContainer.Siedlungen?.Count <= 0) { return(null); } var allowedStaedte = initilize3DBoolArrayBasedOnHexfields(); foreach (var siedlung in client.SpielfigurenContainer.Siedlungen) { var gridPoint = HexagonGrid.GetGridPointByHexagonPositionAndPoint(siedlung.HexagonPosition, siedlung.HexagonPoint); foreach (var hexPosEdge in HexagonGrid.GetHexagonEdgesByGridPoint(HexagonGrid.GetHexagonesByGridPoint(gridPoint), gridPoint)) { if (client.SpielfigurenContainer.Strassen.Find(strasse => HexagonGrid.IsHexagonEdgeOnHexagonEdge(hexPosEdge, new HexagonPositionHexagonEdge(strasse.HexagonPosition, strasse.HexagonEdge))) != null) { allowedStaedte[siedlung.HexagonPosition.RowIndex][siedlung.HexagonPosition.ColumnIndex][siedlung.HexagonPoint.Index] = true; break; } } } return(allowedStaedte); }
private void addNewKartenByClient(CatanClient cclient) { foreach (var strasse in cclient.SpielfigurenContainer.Strassen) { var foundHexagons = new List <Hexagon>(); List <Hexagon> tempHexagons; tempHexagons = HexagonGrid.GetHexagonesByGridPoint(HexagonGrid.GetGridPointByHexagonPositionAndPoint(strasse.HexagonPosition, strasse.HexagonEdge.PointA)); foreach (var tempHex in tempHexagons) { if (!foundHexagons.Exists(hex => hex.Position.Equals(tempHex.Position))) { foundHexagons.Add(tempHex); } } tempHexagons = HexagonGrid.GetHexagonesByGridPoint(HexagonGrid.GetGridPointByHexagonPositionAndPoint(strasse.HexagonPosition, strasse.HexagonEdge.PointB)); foreach (var tempHex in tempHexagons) { if (!foundHexagons.Exists(hex => hex.Position.Equals(tempHex.Position))) { foundHexagons.Add(tempHex); } } // checking edges foreach (var hex in foundHexagons) { foreach (var edge in hex.Edges) { if (HexagonGrid.IsHexagonEdgeOnHexagonEdge(new HexagonPositionHexagonEdge(hex.Position, edge), new HexagonPositionHexagonEdge(strasse.HexagonPosition, strasse.HexagonEdge))) { cclient.KartenContainer.AddRohstoffkarte(Game.LandFeld.GetErtragByLandFeldTyp(hex.LandFeldTyp)); // matched hex } } } } }
private bool[][][] getAllowedSiedlungenByClient(CatanClient client) { bool[][][] allowedSiedlungen = initilize3DBoolArrayBasedOnHexfields(); for (int rowIndex = 0; rowIndex < allowedSiedlungen.GetLength(0); rowIndex++) { for (int columnIndex = 0; columnIndex < allowedSiedlungen[rowIndex].GetLength(0); columnIndex++) { for (int pointIndex = 0; pointIndex < allowedSiedlungen[rowIndex][columnIndex].GetLength(0); pointIndex++) { var currentGridPoint = HexagonGrid.GetGridPointByHexagonPositionAndPoint(new HexagonPosition(rowIndex, columnIndex), new HexagonPoint(pointIndex)); var foundHexagones = HexagonGrid.GetHexagonesByGridPoint(currentGridPoint); if (foundHexagones.Count >= 2) { #region Überprüfen, ob es schon eine Siedlung an diesem GridPoint angelegt wurde, wenn ja, dann ignorieren var hexPositionAndHexPoint = HexagonGrid.GetHexagonAndHexagonPointByGridPoint(currentGridPoint); if (hexPositionAndHexPoint.Exists(hexPosHexPoint => allowedSiedlungen[hexPosHexPoint.HexagonPosition.RowIndex][hexPosHexPoint.HexagonPosition.ColumnIndex][hexPosHexPoint.Point.Index])) { continue; } #endregion #region Überprüfen, ob es hier eine Stadt oder Siedlung gibt var stadtGefunden = catanClients.Exists(_client => _client.SpielfigurenContainer.Staedte.Find( stadt => HexagonGrid.GetGridPointByHexagonPositionAndPoint(stadt.HexagonPosition, stadt.HexagonPoint).Equals(currentGridPoint)) != null); var siedlungGefunden = catanClients.Exists(_client => _client.SpielfigurenContainer.Siedlungen.Find( siedlung => HexagonGrid.GetGridPointByHexagonPositionAndPoint(siedlung.HexagonPosition, siedlung.HexagonPoint).Equals(currentGridPoint)) != null); #endregion if (!stadtGefunden && !siedlungGefunden) { #region Überprüfen, ob die drei angrenzenden Kreuzungen von Siedlungen oder Städten besetzt sind allowedSiedlungen[rowIndex][columnIndex][pointIndex] = catanClients.Find(_client => _client.SpielfigurenContainer.Siedlungen.Find(siedlung => HexagonGrid.GetHexagonEdgesByGridPoint(foundHexagones, currentGridPoint).Find(hex => HexagonGrid.IsGridPointOnHexagonEdge(hex.HexagonPosition, hex.HexagonEdge, HexagonGrid.GetGridPointByHexagonPositionAndPoint(siedlung.HexagonPosition, siedlung.HexagonPoint))) != null) != null || _client.SpielfigurenContainer.Staedte.Find(stadt => HexagonGrid.GetHexagonEdgesByGridPoint(foundHexagones, currentGridPoint).Find(hex => HexagonGrid.IsGridPointOnHexagonEdge(hex.HexagonPosition, hex.HexagonEdge, HexagonGrid.GetGridPointByHexagonPositionAndPoint(stadt.HexagonPosition, stadt.HexagonPoint))) != null) != null) == null; #endregion } else { allowedSiedlungen[rowIndex][columnIndex][pointIndex] = false; } } } } } return(allowedSiedlungen); }