Exemple #1
0
        private void LoadTile(string[] strTextures)
        {
            if (tiles != null)
            {
                tiles.ClearChildren();
            }

            int nTextures = strTextures.Length;

            int startRow = (height - 1) / 2;
            int lastRow  = (height - 1) * 2 - startRow;

            for (int j = 0; j < nCols; j++)
            {
                for (int i = startRow; i <= lastRow; i += 2)
                {
                    float left   = this.Left + j * TileWidth;
                    float top    = this.Top + i * TileHeight;
                    var   sprite = StaticSprite.CreateSprite(left, top, new Vector2(1, 1), @"Sprite\GameUI\" + strTextures[0], 0.5f, (int)((float)TileWidth * 4 / 3), 2 * TileHeight);

                    Tiles[i, j] = new Tile(sprite, i, j);

                    AddHexagonCollider(Tiles[i, j].sprite);
                    CellStyle.Assign(Tiles[i, j].sprite);
                    tiles.AddChild(Tiles[i, j]);
                }
                if (j < (height - 1) / 2)
                {
                    startRow--;
                }
                else
                {
                    startRow++;
                }
                lastRow = (height - 1) * 2 - startRow;
            }
        }