public void SetHexaNeighbours(HexaView[] neighboursView) { hexaNeighbours = new HexaView[neighboursView.Length]; for (int loop1 = 0; loop1 < neighboursView.Length; loop1++) hexaNeighbours[loop1] = neighboursView[loop1]; }
public void CreateTownsAndRoads(HexaModel[] neighboursModel, HexaView hexaView, HexaView[] neighboursView) { hexaNeighbours = new HexaModel[neighboursModel.Length]; for (int loop1 = 0; loop1 < neighboursModel.Length; loop1++) hexaNeighbours[loop1] = neighboursModel[loop1]; if (kind == HexaKind.Nothing || kind == HexaKind.Water) return; /////////////////////// // Creating roads -> // /////////////////////// // Always make owns road or get reference from other roads (not sending reference to other hexas) if (neighboursModel[(int)RoadPos.UpLeft] == null || neighboursModel[(int)RoadPos.UpLeft].GetRoad(RoadPos.BottomRight) == null) { roadOwner[(int)RoadPos.UpLeft] = true; roads[(int)RoadPos.UpLeft] = new RoadModel(); hexaView.CreateRoadView(RoadPos.UpLeft, Matrix.CreateRotationY(-(float)Math.PI / 3.0f) * Matrix.CreateTranslation(new Vector3(-0.25f, 0.0f, 0.14f))); } else { roads[(int)RoadPos.UpLeft] = neighboursModel[(int)RoadPos.UpLeft].GetRoad(RoadPos.BottomRight); hexaView.SetRoadView(RoadPos.UpLeft, neighboursView[(int)RoadPos.UpLeft].GetRoadView(RoadPos.BottomRight)); } if (neighboursModel[(int)RoadPos.UpRight] == null || neighboursModel[(int)RoadPos.UpRight].GetRoad(RoadPos.BottomLeft) == null) { roadOwner[(int)RoadPos.UpRight] = true; roads[(int)RoadPos.UpRight] = new RoadModel(); hexaView.CreateRoadView(RoadPos.UpRight, Matrix.CreateRotationY((float)Math.PI / 3.0f) * Matrix.CreateTranslation(new Vector3(-0.25f, 0.0f, -0.14f))); } else { roads[(int)RoadPos.UpRight] = neighboursModel[(int)RoadPos.UpRight].GetRoad(RoadPos.BottomLeft); hexaView.SetRoadView(RoadPos.UpRight, neighboursView[(int)RoadPos.UpRight].GetRoadView(RoadPos.BottomLeft)); } if (neighboursModel[(int)RoadPos.MiddleLeft] == null || neighboursModel[(int)RoadPos.MiddleLeft].GetRoad(RoadPos.MiddleRight) == null) { roadOwner[(int)RoadPos.MiddleLeft] = true; roads[(int)RoadPos.MiddleLeft] = new RoadModel(); hexaView.CreateRoadView(RoadPos.MiddleLeft, Matrix.CreateTranslation(new Vector3(0.0f, 0.0f, 0.29f))); } else { roads[(int)RoadPos.MiddleLeft] = neighboursModel[(int)RoadPos.MiddleLeft].GetRoad(RoadPos.MiddleRight); hexaView.SetRoadView(RoadPos.MiddleLeft, neighboursView[(int)RoadPos.MiddleLeft].GetRoadView(RoadPos.MiddleRight)); } if (neighboursModel[(int)RoadPos.MiddleRight] == null || neighboursModel[(int)RoadPos.MiddleRight].GetRoad(RoadPos.MiddleLeft) == null) { roadOwner[(int)RoadPos.MiddleRight] = true; roads[(int)RoadPos.MiddleRight] = new RoadModel(); hexaView.CreateRoadView(RoadPos.MiddleRight, Matrix.CreateTranslation(new Vector3(0.0f, 0.0f, -0.28f))); } else { roads[(int)RoadPos.MiddleRight] = neighboursModel[(int)RoadPos.MiddleRight].GetRoad(RoadPos.MiddleLeft); hexaView.SetRoadView(RoadPos.MiddleRight, neighboursView[(int)RoadPos.MiddleRight].GetRoadView(RoadPos.MiddleLeft)); } if (neighboursModel[(int)RoadPos.BottomLeft] == null || neighboursModel[(int)RoadPos.BottomLeft].GetRoad(RoadPos.UpRight) == null) { roadOwner[(int)RoadPos.BottomLeft] = true; roads[(int)RoadPos.BottomLeft] = new RoadModel(); hexaView.CreateRoadView(RoadPos.BottomLeft, Matrix.CreateRotationY((float)Math.PI / 3.0f) * Matrix.CreateTranslation(new Vector3(0.25f, 0.0f, 0.14f))); } else { roads[(int)RoadPos.BottomLeft] = neighboursModel[(int)RoadPos.BottomLeft].GetRoad(RoadPos.UpRight); hexaView.SetRoadView(RoadPos.BottomLeft, neighboursView[(int)RoadPos.BottomLeft].GetRoadView(RoadPos.UpRight)); } if (neighboursModel[(int)RoadPos.BottomRight] == null || neighboursModel[(int)RoadPos.BottomRight].GetRoad(RoadPos.UpLeft) == null) { roadOwner[(int)RoadPos.BottomRight] = true; roads[(int)RoadPos.BottomRight] = new RoadModel(); hexaView.CreateRoadView(RoadPos.BottomRight, Matrix.CreateRotationY(-(float)Math.PI / 3.0f) * Matrix.CreateTranslation(new Vector3(0.25f, 0.0f, -0.14f))); } else { roads[(int)RoadPos.BottomRight] = neighboursModel[(int)RoadPos.BottomRight].GetRoad(RoadPos.UpLeft); hexaView.SetRoadView(RoadPos.BottomRight, neighboursView[(int)RoadPos.BottomRight].GetRoadView(RoadPos.UpLeft)); } /////////////////////// // Creating tows -> // /////////////////////// if ((neighboursModel[(int)RoadPos.UpLeft] == null || neighboursModel[(int)RoadPos.UpLeft].getTown(TownPos.BottomRight) == null) && (neighboursModel[(int)RoadPos.UpRight] == null || neighboursModel[(int)RoadPos.UpRight].getTown(TownPos.BottomLeft) == null)) { townOwner[(int)TownPos.Up] = true; towns[(int)TownPos.Up] = new TownModel(); hexaView.CreateTownView(TownPos.Up, Matrix.CreateTranslation(new Vector3(-0.32f, 0.0f, 0.0f))); } else { if (neighboursModel[(int)RoadPos.UpLeft] != null && neighboursModel[(int)RoadPos.UpLeft].getTown(TownPos.BottomRight) != null) { towns[(int)TownPos.Up] = neighboursModel[(int)RoadPos.UpLeft].getTown(TownPos.BottomRight); hexaView.SetTownView(TownPos.Up, neighboursView[(int)RoadPos.UpLeft].GetTownView(TownPos.BottomRight)); } else { towns[(int)TownPos.Up] = neighboursModel[(int)RoadPos.UpRight].getTown(TownPos.BottomLeft); hexaView.SetTownView(TownPos.Up, neighboursView[(int)RoadPos.UpRight].GetTownView(TownPos.BottomLeft)); } } if ((neighboursModel[(int)RoadPos.BottomLeft] == null || neighboursModel[(int)RoadPos.BottomLeft].getTown(TownPos.UpRight) == null) && (neighboursModel[(int)RoadPos.BottomRight] == null || neighboursModel[(int)RoadPos.BottomRight].getTown(TownPos.UpLeft) == null)) { townOwner[(int)TownPos.Bottom] = true; towns[(int)TownPos.Bottom] = new TownModel(); hexaView.CreateTownView(TownPos.Bottom, Matrix.CreateTranslation(new Vector3(0.32f, 0.0f, 0.0f))); } else { towns[(int)TownPos.Bottom] = neighboursModel[(int)RoadPos.BottomLeft].getTown(TownPos.UpRight); hexaView.SetTownView(TownPos.Bottom, neighboursView[(int)RoadPos.BottomLeft].GetTownView(TownPos.UpRight)); } if ((neighboursModel[(int)RoadPos.UpRight] == null || neighboursModel[(int)RoadPos.UpRight].getTown(TownPos.Bottom) == null) && (neighboursModel[(int)RoadPos.MiddleRight] == null || neighboursModel[(int)RoadPos.MiddleRight].getTown(TownPos.UpLeft) == null)) { townOwner[(int)TownPos.UpRight] = true; towns[(int)TownPos.UpRight] = new TownModel(); hexaView.CreateTownView(TownPos.UpRight, Matrix.CreateTranslation(new Vector3(-0.16f, 0.0f, -0.28f))); } else { if (neighboursModel[(int)RoadPos.UpRight] != null && neighboursModel[(int)RoadPos.UpRight].getTown(TownPos.Bottom) != null) { towns[(int)TownPos.UpRight] = neighboursModel[(int)RoadPos.UpRight].getTown(TownPos.Bottom); hexaView.SetTownView(TownPos.UpRight, neighboursView[(int)RoadPos.UpRight].GetTownView(TownPos.Bottom)); } else { towns[(int)TownPos.UpRight] = neighboursModel[(int)RoadPos.MiddleRight].getTown(TownPos.UpLeft); hexaView.SetTownView(TownPos.UpRight, neighboursView[(int)RoadPos.MiddleRight].GetTownView(TownPos.UpLeft)); } } if ((neighboursModel[(int)RoadPos.UpLeft] == null || neighboursModel[(int)RoadPos.UpLeft].getTown(TownPos.Bottom) == null) && (neighboursModel[(int)RoadPos.MiddleLeft] == null || neighboursModel[(int)RoadPos.MiddleLeft].getTown(TownPos.UpRight) == null)) { townOwner[(int)TownPos.UpLeft] = true; towns[(int)TownPos.UpLeft] = new TownModel(); hexaView.CreateTownView(TownPos.UpLeft, Matrix.CreateTranslation(new Vector3(-0.16f, 0.0f, 0.28f))); } else { towns[(int)TownPos.UpLeft] = neighboursModel[(int)RoadPos.UpLeft].getTown(TownPos.Bottom); hexaView.SetTownView(TownPos.UpLeft, neighboursView[(int)RoadPos.UpLeft].GetTownView(TownPos.Bottom)); } if ((neighboursModel[(int)RoadPos.BottomRight] == null || neighboursModel[(int)RoadPos.BottomRight].getTown(TownPos.Up) == null) && (neighboursModel[(int)RoadPos.MiddleRight] == null || neighboursModel[(int)RoadPos.MiddleRight].getTown(TownPos.BottomLeft) == null)) { townOwner[(int)TownPos.BottomRight] = true; towns[(int)TownPos.BottomRight] = new TownModel(); hexaView.CreateTownView(TownPos.BottomRight, Matrix.CreateTranslation(new Vector3(0.16f, 0.0f, -0.28f))); } else { if (neighboursModel[(int)RoadPos.BottomRight] != null && neighboursModel[(int)RoadPos.BottomRight].getTown(TownPos.Bottom) != null) { towns[(int)TownPos.BottomRight] = neighboursModel[(int)RoadPos.BottomRight].getTown(TownPos.Up); hexaView.SetTownView(TownPos.BottomRight, neighboursView[(int)RoadPos.BottomRight].GetTownView(TownPos.Up)); } else { towns[(int)TownPos.BottomRight] = neighboursModel[(int)RoadPos.MiddleRight].getTown(TownPos.BottomLeft); hexaView.SetTownView(TownPos.BottomRight, neighboursView[(int)RoadPos.MiddleRight].GetTownView(TownPos.BottomLeft)); } } if ((neighboursModel[(int)RoadPos.BottomLeft] == null || neighboursModel[(int)RoadPos.BottomLeft].getTown(TownPos.Up) == null) && (neighboursModel[(int)RoadPos.MiddleLeft] == null || neighboursModel[(int)RoadPos.MiddleLeft].getTown(TownPos.BottomRight) == null)) { townOwner[(int)TownPos.BottomLeft] = true; towns[(int)TownPos.BottomLeft] = new TownModel(); hexaView.CreateTownView(TownPos.BottomLeft, Matrix.CreateTranslation(new Vector3(0.16f, 0.0f, 0.28f))); } else { if (neighboursModel[(int)RoadPos.BottomLeft] != null && neighboursModel[(int)RoadPos.BottomLeft].getTown(TownPos.Bottom) != null) { towns[(int)TownPos.BottomLeft] = neighboursModel[(int)RoadPos.BottomLeft].getTown(TownPos.Up); hexaView.SetTownView(TownPos.BottomLeft, neighboursView[(int)RoadPos.BottomLeft].GetTownView(TownPos.Up)); } else { towns[(int)TownPos.BottomLeft] = neighboursModel[(int)RoadPos.MiddleLeft].getTown(TownPos.BottomRight); hexaView.SetTownView(TownPos.BottomLeft, neighboursView[(int)RoadPos.MiddleLeft].GetTownView(TownPos.BottomRight)); } } }