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 Tile(Gameboard gameboard, int X, int Y)
        {
            Chits = new ObservableCollection<ProductionChit>();
            //Chits.CollectionChanged += Chits_CollectionChanged;

            this.X = X;
            this.Y = Y;

            var offsetX = 192 * X;
            var offsetY = heightConstant * 256 * Y;
            if (X % 2 == 0)
                offsetY += heightConstant * 128;

            //this.Position = new Point(offsetX, offsetY);

            InitializeComponent();
            this.Location.Text = X + "," + Y;
        }