public Chunk(float x, float y) : base(x, y) { var world = new World(); SpawnPoints = new List <Entity>(); level = FP.Choose.From(levels); ents = loader.BuildLevelAsArray(Library.GetXml("Levels/" + level)); int spawns = 0; foreach (var e in ents) { if (!(e is Player)) { e.X += X; e.Y += Y; } if (e is SpawnPoint) { ++spawns; SpawnPoints.Add(e); } if (e.GetComponent <Grid>() != null) { var grid = e.GetComponent <Grid>(); var map = new Tilemap(Library.GetTexture("tiles/Tileset.png"), FP.Width, FP.Height, 16, 16); AutoTileSet.CreateFromGrid(map, grid); e.AddComponent(map); e.Visible = true; e.Layer = ObjectLayers.Platforms; } } if (spawns != 4) { throw new Exception("too few spawn points in" + level + ";" + spawns + "found, 4 required."); } }
public Map(string map_filename) { OgmoLoader ogmo = new OgmoLoader(); ogmo.RegisterClassAlias <MapRoom>("Room"); var mapRoomEntities = ogmo.BuildLevelAsArray( Library .Get <XmlDocument>(map_filename)); this.mapRooms = new MapRoom[mapRoomEntities.Length]; Array.Copy(mapRoomEntities, this.mapRooms, this.mapRooms.Length); this.Visible = false; this.RenderStep = 100; this.Camera = new Camera(); foreach (var r in mapRooms) { r.Camera = this.Camera; } this.Scale *= .7f; }
public GameWorld() : base() { World = this; Engine.Console.InvisibleUntilOpen = true; // Fade Fade fade = new Fade(new Color(0x000000), 0.15f); AddResponse(Door.DoorMessages.StartChangeRoom, (a) => { player.Active = false; fade.FadeIn(() => { Door callingDoor = (Door)a[0]; ActuallyChangeRoom(callingDoor); fade.FadeOut(() => player.Active = true); }); }); this.Add(fade); // Ogmo loading OgmoLoader ogmoSenpai = new OgmoLoader(); // TODO: Move enemy init logic somewhere else ogmoSenpai.RegisterClassAlias <Enemy>("EnemyWalker"); ogmoSenpai.DefineGrid("TileCollision", KQ.CollisionTypeSolid, 24, 24); ogmoSenpai.DefineGrid("px4TileCollision", KQ.CollisionTypeSolid, 6, 6); ogmoSenpai.DefineTilemap("Blocks", 24, 24, Library.Get <Texture>("content/ogmo/rooms/roomProjectTileset.png")); Map map = new Map("content/ogmo/layout/layout.oel"); this.Add(map); foreach (MapRoom layoutRoom in map.mapRooms.OfType <MapRoom>()) { XmlDocument roomXml = Library.Get <XmlDocument>("content/ogmo/rooms/" + layoutRoom.Filename + ".oel"); //Load level properties Room realRoom = new Room ( ogmoSenpai.BuildLevelAsArray(roomXml).ToList(), ogmoSenpai.GetLevelProperties <RealRoomMeta>(roomXml), layoutRoom, this ); realRoom.RealRoomMeta.Init(); rooms.Add(layoutRoom.Filename, realRoom); } (CurrentRoom = rooms["start"]).PopulateWorld(); Add(player); HUD hud = new HUD(player); Add(hud); Entity follow = player; //for (int i = 0; i < 4; i++) //{ // Orb orb = new Orb(player.X, player.Y, (OrbType)i, follow); // follow = orb; // orbs.Add(Add(orb)); //} }