Ejemplo n.º 1
0
        public MainWindow()
        {
            var board = new Gameboard(CountY, CountX);
            tiles = new Tile[CountX][];
            for (int i = 0; i < CountX; ++i) {
                tiles[i] = new Tile[CountY];
                for (int j = 0; j < CountY; ++j) {
                    Tile h = new Tile(board, i,j);

                    //h.SetValue(FrameworkElement.MarginProperty, new Thickness(h.Position.X, h.Position.Y, 0, 0));
                    //h.SetValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Left);
                    //h.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Top);

                    h.SetValue(HexagonalGrid.RowProperty, j);
                    h.SetValue(HexagonalGrid.ColumnProperty, i);
                    //Canvas.SetLeft(h, h.Position.X);
                    //Canvas.SetTop(h, h.Position.Y);

                    tiles[i][j] = h;
                }
            }

            InitializeComponent();
            foreach (var t in AllTiles)
            {
                //this.TileLayer.Children.Add(t);
                this.TheGrid.Children.Add(t);
            }
            this.TheGrid.InvalidateMeasure();
            this.TheGrid.InvalidateArrange();
            
            var count = CountX * CountY;
        }
Ejemplo n.º 2
0
 public int DistanceTo(Tile h)
 {
     return DistanceTo(h.X, h.Y);
 }
Ejemplo n.º 3
0
        private static void ExchangeChits(Tile a, Tile b)
        {
            Trace.TraceInformation("Exchanging chits: ({0},{1}:{{{2}}}), ({3},{4}:{{{5}}})",
                b.X, b.Y, string.Join(",", from c in b.Chits select c.ProducesOn),
                a.X, a.Y, string.Join(",", from c in a.Chits select c.ProducesOn));

            var temp = a.Chits.ToArray();
            a.Chits.Clear();
            foreach (var c in b.Chits)
            {
                a.Chits.Add(c);
            }
            b.Chits.Clear();
            foreach (var c in temp)
            {
                b.Chits.Add(c);
            }

            Trace.TraceInformation("Exchanged chits: ({0},{1}:{{{2}}}), ({3},{4}:{{{5}}})",
                b.X, b.Y, string.Join(",", from c in b.Chits select c.ProducesOn),
                a.X, a.Y, string.Join(",", from c in a.Chits select c.ProducesOn));
        }