Пример #1
0
        static void Main(string[] args)
        {
            SettlerSimLib.SettlerBoard testing = new SettlerSimLib.SettlerBoard();

            List<IHex> testBoard = testing.GameBoard;

            foreach (IHex hex in testBoard)
            {
                Console.WriteLine("Hex with value " + hex.DiceRollValue);
                Console.WriteLine("\tLand Type : " + Enum.GetName(typeof(LandType), hex.LandType));
            }
        }
Пример #2
0
 public SettlerBoardVM()
 {
     model = SettlerBoard.Instance;
     hexTiles = new ObservableCollection<HexVM>();
     locationPoints = new ObservableCollection<LocationPointVM>();
     edges = new ObservableCollection<EdgeVM>();
     foreach (IHex hex in model.GameBoard)
     {
         HexVM hexVM = new HexVM(hex, model);
         hexTiles.Add(hexVM);
         foreach (ILocationPoint locPoint in hex.LocationPointsEnum)
         {
             if (!LocationPoints.Where((point) => point.LocationPoint == locPoint).Any())
             {
                 if (hex.LocationPointsEnum.ElementAt((int)SettlerSimLib.LocationPoints.Left) == locPoint)
                     LocationPoints.Add(new LocationPointVM(locPoint, hexVM.OffsetX, hexVM.OffsetY + hexVM.r));
                 else if (hex.LocationPointsEnum.ElementAt((int)SettlerSimLib.LocationPoints.TopLeft) == locPoint)
                     LocationPoints.Add(new LocationPointVM(locPoint, hexVM.OffsetX + hexVM.h, hexVM.OffsetY));
                 else if (hex.LocationPointsEnum.ElementAt((int)SettlerSimLib.LocationPoints.TopRight) == locPoint)
                     LocationPoints.Add(new LocationPointVM(locPoint, hexVM.OffsetX + hexVM.h + hexVM.s, hexVM.OffsetY));
                 else if (hex.LocationPointsEnum.ElementAt((int)SettlerSimLib.LocationPoints.Right) == locPoint)
                     LocationPoints.Add(new LocationPointVM(locPoint, hexVM.OffsetX + hexVM.b, hexVM.OffsetY + hexVM.r));
                 else if (hex.LocationPointsEnum.ElementAt((int)SettlerSimLib.LocationPoints.BottomRight) == locPoint)
                     LocationPoints.Add(new LocationPointVM(locPoint, hexVM.OffsetX + hexVM.h + hexVM.s, hexVM.OffsetY + (2 * hexVM.r)));
                 else if (hex.LocationPointsEnum.ElementAt((int)SettlerSimLib.LocationPoints.BottomLeft) == locPoint)
                     LocationPoints.Add(new LocationPointVM(locPoint, hexVM.OffsetX + hexVM.h, hexVM.OffsetY + (2 * hexVM.r)));
             }
         }
     }
     foreach (LocationPointVM locPoint in this.LocationPoints)
     {
         foreach (IEdge edge in locPoint.LocationPoint.Edges)
         {
             if (!Edges.Any((edgeAny) => edgeAny.Edge == edge))
             {
                 LocationPointVM pointVM = this.LocationPoints.First((findPoint) => findPoint.LocationPoint == edge.GetOppositePoint(locPoint.LocationPoint));
                 EdgeVM edgeVM = new EdgeVM(edge, locPoint.OffsetX, locPoint.OffsetY, pointVM.OffsetX, pointVM.OffsetY);
                 Edges.Add(edgeVM);
             }
         }
     }
 }
Пример #3
0
 public HexVM(IHex HexModel, SettlerBoard board)
 {
     hexModel = HexModel;
     CalulateHexagonValues();
     // Calculate how much it needs to shift
     if (board.GameBoard.GetRange(0, 3).Contains(HexModel))
     {
         offsetX = b + s;
         int indexValue = board.GameBoard.IndexOf(HexModel);
         offsetX += indexValue * (h + s);
         offsetY = indexValue * r;
     }
     else if (board.GameBoard.GetRange(3,4).Contains(HexModel))
     {
         offsetX = s + h;
         int indexValue = board.GameBoard.IndexOf(HexModel) - 3;
         offsetX += indexValue * (h + s);
         offsetY = (indexValue + 1) * r;
     }
     else if (board.GameBoard.GetRange(7, 5).Contains(HexModel))
     {
         int indexValue = board.GameBoard.IndexOf(HexModel) - 7;
         offsetX += indexValue * (h + s);
         offsetY = (indexValue + 2) * r;
     }
     else if (board.GameBoard.GetRange(12, 4).Contains(HexModel))
     {
         int indexValue = board.GameBoard.IndexOf(HexModel) - 12;
         offsetX += indexValue * (h + s);
         offsetY = (indexValue + 4) * r;
     }
     else if (board.GameBoard.GetRange(16, 3).Contains(HexModel))
     {
         int indexValue = board.GameBoard.IndexOf(HexModel) - 16;
         offsetX += indexValue * (h + s);
         offsetY = (indexValue + 6) * r;
     }
 }