/// <summary> /// Loads a new sprite instance. The sprite's data must be in the "sprites" folder. /// </summary> /// <param name="spriteId">The name of the sprite.</param> /// <param name="game"></param> public Sprite(string spriteId, Game game) { this.name = spriteId; PropertyReader sprite = game.loader.GetPropertyReader().Select("sprites/" + spriteId + ".xml"); graphic = new AnimatedGraphics(sprite.GetString("animation"), game); speed = sprite.GetInt("speed"); noclip = sprite.GetBool("noclip"); foreach (PropertyReader ext in sprite.SelectAll("exts/ext")) { this.SetProperty(ext.GetString("key"), ext.GetString("value")); } this.size = game.TileSize; }
public Layer(int width, int height, string path, Game game) { string[] tileLines = game.loader.LoadText(string.Format(path, "tiles")).Split('\n'); string[] passLines = game.loader.LoadText(string.Format(path, "passability")).Split('\n'); objects = new List<Sprite>[width, height]; tiles = new Graphics[width, height]; passable = new bool[width, height]; onStep = new List<Script>[width, height]; ladderMove = new Layer[width, height]; for (int j = 0; j < height; ++j) { string[] tileLine = tileLines[j].Split(' '); string[] passLine = passLines[j].Split(' '); for (int i = 0; i < width; ++i) { objects[i, j] = new List<Sprite>(); onStep[i, j] = new List<Script>(); int tileID = int.Parse(tileLine[i]); if (tileID == 0) { tiles[i, j] = new NoGraphics(); } else { AnimatedGraphics anim = new AnimatedGraphics("tiles", game, tileID - 1); tiles[i, j] = anim; } passable[i, j] = int.Parse(passLine[i]) == 1; } } }
public AnimatedScreenGraphics(AnimatedGraphics graphics, Point coords) : base(graphics, coords) { this.animatedGraphics = graphics; }
public void AnimatedGraphics_SetState(AnimatedGraphics gfx, string state) { gfx.SetState(state); }
public void AnimatedGraphics_SetDir(AnimatedGraphics gfx, string dir) { gfx.SetDirection((Sprite.Dir)Enum.Parse(typeof(Sprite.Dir), dir, true)); }
public int AnimatedGraphics_GetFrameCount(AnimatedGraphics gfx) { return gfx.FrameCount; }