コード例 #1
0
        public static TextureRegion2D GetItemTextureRegionById(int id)
        {
            ItemDefinition itemDef = itemMap[id];
            TextureAtlas   atlas   = itemTextureMaps[itemDef.SpriteMapLocation];

            return(atlas.GetTextureRegion(itemDef.SpriteIndex));
        }
コード例 #2
0
ファイル: Tile.cs プロジェクト: BrettKercher/Errant
        public void DrawGround(SpriteBatch spriteBatch, TextureAtlas tileAtlas, int xPos, int yPos)
        {
            // Draw base Ground Texture
            int             textureRegionIndex = (persistentTile.GroundTileId * tileAtlas.Width);
            TextureRegion2D textureRegion      = tileAtlas.GetTextureRegion(textureRegionIndex);

            spriteBatch.Draw(textureRegion.Texture, new Vector2(xPos, yPos), textureRegion.SourceRectangle, Color.White);

            // Draw transition textures
            foreach (KeyValuePair <ushort, byte> kvp in transitionData)
            {
                textureRegionIndex = (kvp.Key * tileAtlas.Width) + kvp.Value;
                textureRegion      = tileAtlas.GetTextureRegion(textureRegionIndex);
                spriteBatch.Draw(textureRegion.Texture, new Vector2(xPos, yPos), textureRegion.SourceRectangle, Color.White);
            }
        }
コード例 #3
0
ファイル: ObjectManager.cs プロジェクト: BrettKercher/Errant
        public static TextureRegion2D GetObjectTextureRegionById(int id)
        {
            ObjectDefinition objDef = objectMap[id];
            TextureAtlas     atlas  = objectTextureMaps[objDef.SpriteMapLocation];

            return(atlas.GetTextureRegion(objDef.SpriteIndex));
        }