Пример #1
0
        public Gem(Gem gem2)
        {
            this.team = gem2.team;
            this.i    = gem2.i;
            this.j    = gem2.j;
            var visualPosition = Gem.map.GetGemVisualPosition(i, j);
            int width          = (int)(Gem.Size.X * Global.thisGame.ScreenScaleFactor.X);
            int height         = (int)(Gem.Size.Y * Global.thisGame.ScreenScaleFactor.Y);

            if (team == Team.Red)
            {
                sprite = StaticSprite.CreateSprite(visualPosition.X, visualPosition.Y, new Vector2(1, 1), SpritePath[0], 0.1f, width, height);
            }
            else
            {
                sprite = StaticSprite.CreateSprite(visualPosition.X, visualPosition.Y, new Vector2(1, 1), SpritePath[1], 0.1f, width, height);
            }
            this.AddChild(sprite);
        }
Пример #2
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;
            }
        }