sneak/Shared/Textures.cs
Colin McMillen f081a3db4e Apply VS suggestion for refactoring TextureRef.Get
GitOrigin-RevId: 9758a333c456f6a150282d3f4adb00c68095e416
2020-02-24 17:07:42 -05:00

62 lines
2.2 KiB
C#

using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
namespace SemiColinGames {
class TextureRef {
private static readonly List<TextureRef> allTextures = new List<TextureRef>();
public static void LoadAll(ContentManager content) {
foreach (TextureRef texture in allTextures) {
texture.Load(content);
}
}
private readonly string contentPath;
public TextureRef(string contentPath) {
allTextures.Add(this);
this.contentPath = contentPath;
}
public Texture2D Get { get; private set; }
private void Load(ContentManager content) {
Get = content.Load<Texture2D>(contentPath);
}
}
class Textures {
public static SpriteFont DebugFont;
public static TextureRef Player = new TextureRef("sprites/ccg/ninja_female");
// Backgrounds are indexed by draw order; the first element should be drawn furthest back.
public static TextureRef[] Backgrounds = new TextureRef[] {
new TextureRef("backgrounds/szadiart/pf4/background1_day"),
new TextureRef("backgrounds/szadiart/pf4/background2a_day"),
new TextureRef("backgrounds/szadiart/pf4/background3_day"),
new TextureRef("backgrounds/szadiart/pf4/background4_day"),
};
public static TextureRef Cemetery = new TextureRef("tiles/anokolisa/cemetery");
public static TextureRef Crypt = new TextureRef("tiles/anokolisa/crypt");
public static TextureRef Dungeon = new TextureRef("tiles/anokolisa/dungeon");
public static TextureRef Forest = new TextureRef("tiles/anokolisa/forest");
public static TextureRef Garden = new TextureRef("tiles/anokolisa/garden");
public static TextureRef Grassland = new TextureRef("tiles/anokolisa/grassland");
public static TextureRef Ruins = new TextureRef("tiles/anokolisa/ruins");
public static TextureRef Sewer = new TextureRef("tiles/anokolisa/sewer");
public static TextureRef Temple = new TextureRef("tiles/anokolisa/temple");
public static TextureRef Village = new TextureRef("tiles/anokolisa/village");
public static void Load(ContentManager content) {
DebugFont = content.Load<SpriteFont>("font");
TextureRef.LoadAll(content);
}
}
}