public void RestartMapWon() { try { if (activeSkills != null) { world.RemoveBody(activeSkills.shieldGfx.body); activeSkills = null; } foreach (AI ai in theAI) { ai.projectile.Clear(world); world.RemoveBody(ai.wheel.body); world.RemoveBody(ai.torso.body); } theAI.Clear(); if (drops.Count > 0) { foreach (Drops d in drops) { world.RemoveBody(d.hpBox.body); world.RemoveBody(d.ethanolBox.body); } } if (player != null) player.projectile.Clear(world); //player.torso.Position = new Vector2(60, 1300); player.MovePlayer(new Vector2(60, 1300)); if (map != null) { map.InializeMap(); } //reset spawnpoints foreach (Spawn sp in spawnpoints) { if (sp.Visited) sp.Visited = false; } drops.Clear(); menu.totalTime = 0f; runTime = 0; player.torso.Position = new Vector2(60, 1300); player.wheel.Position = new Vector2(60, 1300); camera = new Camera(graphics.GraphicsDevice.Viewport); camera.UpdateCamera(player); /* if (quest != null) { world.RemoveBody(quest.boulder.body); } quest = new Quests(world, this); if (map != null) map.button.body.OnCollision += quest.InteractWithQuestItems; * */ } catch (Exception ex) { logger.Fatal("Restart: " + ex.Message + " " + ex.TargetSite + " " + ex.StackTrace); } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { camera = new Camera(GraphicsDevice.Viewport); menu = new Menu(this); menu.gameState = Menu.GameState.StartMenu; IsMouseVisible = true; projectile = new Projectile(this); myFont = Content.Load<SpriteFont>("font"); //quest = new Quests(world, this); IsFixedTimeStep = false; timer = new System.Timers.Timer(10); timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); base.Initialize(); }
/// <summary> /// Restart the game /// </summary> public void Restart() { try { if (activeSkills != null) { world.RemoveBody(activeSkills.shieldGfx.body); activeSkills = null; } foreach (AI ai in theAI) { ai.projectile.Clear(world); world.RemoveBody(ai.wheel.body); world.RemoveBody(ai.torso.body); } theAI.Clear(); if (player != null) { world.RemoveBody(player.torso.body); world.RemoveBody(player.wheel.body); } if (drops.Count > 0) { foreach (Drops d in drops) { world.RemoveBody(d.hpBox.body); world.RemoveBody(d.ethanolBox.body); } } if (player != null) player.projectile.Clear(world); player = null; //starta i slutet av banan (låt va kvar /Timmo) if (endOfMapSpawn) player = new Player(world, playerTexture, new Vector2(42, 90), 10.0f, new Vector2(8385, 1000), this, "player"); else player = new Player(world, playerTexture, new Vector2(60, 88), 10.0f, new Vector2(60, 1300), this, "player"); if (map != null) { map.InializeMap(); } //reset spawnpoints foreach (Spawn sp in spawnpoints) { if (sp.Visited) sp.Visited = false; } drops.Clear(); menu.totalTime = 0f; runTime = 0; camera = new Camera(graphics.GraphicsDevice.Viewport); camera.UpdateCamera(player); /* if (quest != null) { world.RemoveBody(quest.boulder.body); } quest = new Quests(world, this); if (map != null) map.button.body.OnCollision += quest.InteractWithQuestItems; * */ skilltree = new Skilltree(player, this); } catch (Exception ex) { logger.Fatal("Restart: " + ex.Message + " " + ex.TargetSite + " " + ex.StackTrace); } }