コード例 #1
0
        public static StaticSprite CreateSprite(float left, float top, Vector2 ScreenScaleFactor, String path, float depth = 1.0f, int width = 0, int height = 0)
        {
            List <Texture2D> textures   = new List <Texture2D>();
            Texture2D        newTexture = Global.thisGame.Content.Load <Texture2D>(path);

            textures.Add(newTexture);

            if (width == 0)
            {
                width = newTexture.Width;
            }

            if (height == 0)
            {
                height = newTexture.Height;
            }

            top  = top * ScreenScaleFactor.Y;
            left = left * ScreenScaleFactor.X;

            width  = (int)((float)width * ScreenScaleFactor.X);
            height = (int)((float)height * ScreenScaleFactor.Y);

            StaticSprite temp = new StaticSprite(textures, left, top, width, height, true);

            temp._Depth = depth;
            return(temp);
        }
コード例 #2
0
ファイル: StaticSprite.cs プロジェクト: bikrone/hexagon
 public static StaticSprite CreateSprite(float left, float top, int width, int height, String path, float depth = 1.0f)
 {
     List<Texture2D> textures = new List<Texture2D>();
     textures.Add(Global.thisGame.Content.Load<Texture2D>(path));
     StaticSprite temp = new StaticSprite(textures, left, top, width, height);
     temp._Depth = depth;
     return temp;
 }
コード例 #3
0
        public static StaticSprite CreateSprite(float left, float top, int width, int height, String path, float depth = 1.0f)
        {
            List <Texture2D> textures = new List <Texture2D>();

            textures.Add(Global.thisGame.Content.Load <Texture2D>(path));
            StaticSprite temp = new StaticSprite(textures, left, top, width, height);

            temp._Depth = depth;
            return(temp);
        }
コード例 #4
0
ファイル: Gem.cs プロジェクト: bikrone/hexagon
        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);
        }
コード例 #5
0
ファイル: StaticSprite.cs プロジェクト: bikrone/hexagon
        public static StaticSprite CreateSprite(float left, float top, Vector2 ScreenScaleFactor, String path, float depth = 1.0f, int width = 0, int height = 0)
        {
            List<Texture2D> textures = new List<Texture2D>();
            Texture2D newTexture = Global.thisGame.Content.Load<Texture2D>(path);
            textures.Add(newTexture);

            if (width == 0)
                width = newTexture.Width;

            if (height == 0 )
                height = newTexture.Height;

            top = top * ScreenScaleFactor.Y;
            left = left * ScreenScaleFactor.X;

            width = (int)((float)width * ScreenScaleFactor.X);
            height = (int)((float)height * ScreenScaleFactor.Y);

            StaticSprite temp = new StaticSprite(textures, left, top, width, height, true);
            temp._Depth = depth;
            return temp;
        }
コード例 #6
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;
            }
        }