private void InitGame() { if (ActiveProfile.IsSavedProfileNull()) { var map1 = new Map("TestMap1", new Actor[] { new Floor(Size.Width, Color.Blue), //new FromArtPlatform(Size.Width, Size.Width/2, 0), new Block(50, .25f, 6, 5), new PhysicsHat("GravityGrenade", Size.Width /4, PhysicsHat.Radius), new Bouncer(1, Color.Red, Size.Width - 1, 1), // new Actors.IntraMapPortal("Entrance", Portal.Radius, Portal.Radius, false), new Actors.IntraMapPortal("Entrance", 2, 2, false), new Actors.InterMapPortal("Exit", Size.Width - Portal.Radius, Portal.Radius) }); var map2 = new Map("TestMap2", new Actor[] { new Platform(1, Color.Orange, 1, Size.Height / 2), new Platform(1, Color.Purple, 2.5f, Size.Height / 2), new MovablePlatform(5000, 1.1f, Color.Green, Platform.Thickness, 4.5f, Size.Height / 2), new MovablePlatform(200, 2, Color.HotPink, Platform.Thickness, Size.Width - 4, 1), new Platform(Portal.Radius, Color.Yellow, Size.Width - Portal.Radius, Size.Height / 2), new Bouncer(1, Color.Red, Size.Width - Portal.Radius, Size.Height / 2 + Portal.Radius), new Actors.InterMapPortal("Entrance", Portal.Radius, Size.Height / 2 + Portal.Radius), new Actors.IntraMapPortal("Bottom", 2, 1, true), new Actors.IntraMapPortal("Top", Size.Width - 4, Size.Y / 2, true), new Actors.InterMapPortal("Exit", Size.Width - Portal.Radius, Size.Height / 2 + Portal.Radius) }); ((InterMapPortal)map1.LinkedObjects["Exit"]).DestinationMap = map2; ((InterMapPortal)map1.LinkedObjects["Exit"]).DestinationPortalID = "Entrance"; ((InterMapPortal)map2.LinkedObjects["Entrance"]).DestinationMap = map1; ((InterMapPortal)map2.LinkedObjects["Entrance"]).DestinationPortalID = "Exit"; map2.LinkedObjects["Bottom"] = map2.LinkedObjects["Top"]; map2.LinkedObjects["Top"] = map2.LinkedObjects["Bottom"]; map2.GameObjects[2].PolyBody.Gravity = Vector2.Zero; map2.GameObjects[3].PolyBody.Gravity = Vector2.Zero; //map2.StaticActors[3].PolyBody.RotationEnabled = false; map1.UnLoaded += new MapEventHandler(SaveMap); map2.UnLoaded += new MapEventHandler(SaveMap); map1.Load("Entrance"); ActiveProfile.PhysicsWeaponInventory.WeaponPowerChanged += new PhysicsWeaponManagerEventHandler(RefreshWeaponPowerLabel); ActiveProfile.PhysicsWeaponInventory.WeaponSwitched += new PhysicsWeaponManagerEventHandler(RefreshWeaponPowerLabel); } else ActiveProfile.Load(); }
void SaveMap(Map sender) { ActiveProfile.SaveCurrentMap(); }
/// <summary> /// Saves the previous map and loads Map from file /// </summary> public void SetCurrentMap(string mapName, string startupPortal, bool saveBeforeClosing) { var game = GameEngine.Singleton.GetPlayState(); if (game.ActiveMap != null && saveBeforeClosing) this.SaveCurrentMap(); XmlNode mapNode = (savedProfile == null) ? null : savedProfile.DocumentElement .SelectSingleNode( String.Format("./map[@name='{0}']", mapName)); if (mapNode != null) { new Map(mapName, mapNode).Load(startupPortal); } else { bool CanRemoveHack // When Linked Objects Work // No need to implement linking yourself, // just load linked objects with // strings ID and PartnerAddress = false; if (CanRemoveHack) { Map map = new Map(mapName, FileIO.LoadFromFile().ToArray()); map.Load(startupPortal); } else // Proceed With Super Hack { Map map = new Map(mapName, ((GameStates.TheGameState)game).HardCodedMaps[mapName]); map.Load(startupPortal); } } }