public WorldmapSector(string Filename) { List WorldMapL = Util.Load(Filename, "supertux-worldmap"); LispIterator iter = new LispIterator(WorldMapL); while(iter.MoveNext()) { switch(iter.Key) { case "properties": Properties Props = new Properties(iter.List); Props.Get("name", ref Name); Props.Get("music", ref Music); Console.WriteLine("Name: " + Name); Console.WriteLine("Music: " + Music); Props.PrintUnusedWarnings(); break; case "spawnpoint": WorldmapSpawnPoint SpawnPoint = new WorldmapSpawnPoint(); SpawnPoint.Parse(iter.List); SpawnPoints.Add(SpawnPoint.Name, SpawnPoint); break; default: GameObject Object = ParseObject(iter.Key, iter.List); if(Object != null) AddObject(Object); break; } } Player = new WorldmapTux(this); AddObject(Player); Spawn("default"); }
public Action(List Data, string BaseDir, SpriteData spriteData) { Properties Props = new Properties(Data); if(!Props.Get("name", ref Name)) throw new Exception("Action without name specified"); Props.Get("fps", ref Speed); Props.Get("x-offset", ref Offset.X); Props.Get("y-offset", ref Offset.Y); List<string> ImageFileNames = new List<string>(); Props.GetStringList("images", ImageFileNames); Props.PrintUnusedWarnings(); foreach(string ImageFile in ImageFileNames) { Surface surface = new Surface(BaseDir + "/" + ImageFile); Width = Math.Max(Width, surface.Width); Height = Math.Max(Height, surface.Height); Frames.Add(surface); } string MirrorActionName = null; Props.Get("mirror-action", ref MirrorActionName); if(MirrorActionName != null) { Action MirrorAction = spriteData.Actions[MirrorActionName]; foreach(Surface surface in MirrorAction.Frames) { Surface flippedSurface = new Surface(surface); flippedSurface.Left = surface.Right; flippedSurface.Right = surface.Left; Width = Math.Max(Width, surface.Width); Height = Math.Max(Height, surface.Height); Frames.Add(flippedSurface); } } }
public void Parse(List Data) { Properties Props = new Properties(Data); if(!Props.Get("name", ref Name)) throw new Exception("WorldmapSpawnPoint has no Name"); Props.Get("x", ref Pos.X); Props.Get("y", ref Pos.Y); Props.PrintUnusedWarnings(); }
public WorldmapLevel(WorldmapSector Sector, List Data) : base(Sector) { string SpriteName = "worldmap/common/leveldot.sprite"; Properties Props = new Properties(Data); Props.Get("name", ref LevelFile); FieldPos LevelPos = new FieldPos(); Props.Get("x", ref LevelPos.X); Props.Get("y", ref LevelPos.Y); Props.Get("sprite", ref SpriteName); Props.PrintUnusedWarnings(); Sprite = SpriteManager.Create(SpriteName); Sprite.Pos = new Vector(LevelPos.X*32 + 16, LevelPos.Y*32 + 16); }
public Tilemap(Tileset Tileset, Lisp.List Data) { this.Tileset = Tileset; Properties Props = new Properties(Data); uint Width = 0; uint Height = 0; Props.Get("width", ref Width); Props.Get("height", ref Height); if(Width == 0 || Height == 0) throw new Exception("Width or Height of Tilemap invalid"); List<uint> Tiles = new List<uint>(); Props.GetUIntList("tiles", Tiles); if(Tiles.Count != (int) (Width * Height)) throw new Exception("TileCount != Width*Height"); Props.Get("solid", ref Solid); Props.PrintUnusedWarnings(); Field = new Field<uint>(Tiles, Width, Height); }
public Action(List Data, string BaseDir, SpriteData spriteData) { Properties Props = new Properties(Data); if(!Props.Get("name", ref Name)) throw new Exception("Action without name specified"); Props.Get("fps", ref Speed); if(Props.Exists("hitbox")) { List<float> hitbox = new List<float>(); Props.GetFloatList("hitbox", hitbox); if (hitbox.Count != 4) throw new Exception("hitbox must specify exactly 4 coordinates"); Hitbox = new RectangleF(hitbox[0], hitbox[1], hitbox[2], hitbox[3]); Offset.X = Hitbox.Left; Offset.Y = Hitbox.Top; } List<string> ImageFileNames = new List<string>(); Props.GetStringList("images", ImageFileNames); Props.PrintUnusedWarnings(); foreach(string ImageFile in ImageFileNames) { Surface surface = new Surface(BaseDir + "/" + ImageFile); Width = Math.Max(Width, surface.Width); Height = Math.Max(Height, surface.Height); Frames.Add(surface); } string MirrorActionName = null; Props.Get("mirror-action", ref MirrorActionName); if(MirrorActionName != null) { Action MirrorAction = spriteData.Actions[MirrorActionName]; foreach(Surface surface in MirrorAction.Frames) { Surface flippedSurface = new Surface(surface); flippedSurface.Left = surface.Right; flippedSurface.Right = surface.Left; Width = Math.Max(Width, surface.Width); Height = Math.Max(Height, surface.Height); Frames.Add(flippedSurface); } } }