public override void Update(GameTime gameTime) { foreach (var comp in _components) { comp.Update(gameTime); } if (ri.timecounter > 3) { _components.Remove(ri); playerHand.SetTrue(); enemyHand.SetTrue(); userInterface.enableTimer = true; } player.Update(gameTime); player2.Update(gameTime); rain.Update(gameTime); checkWin(); }
public override void Update(GameTime gameTime) { player.Update(gameTime); player2.Update(gameTime); playerHand.Update(gameTime); enemyHand.Update(gameTime); userInterface.Update(gameTime); for (int i = 0; i < playerHand._projectiles.Count; i++) { if (Collisions.CollidesWith(playerHand._projectiles.ElementAt(i).Bounds, player2.Bounds)) { Console.WriteLine("hit registered"); player2.life -= playerHand._projectiles.ElementAt(i).damage; playerHand._projectiles.Remove(playerHand._projectiles.ElementAt(i)); Console.WriteLine(System.Convert.ToString(player2.life)); userInterface.enemyLifeText = Convert.ToString(player2.life); } } for (int i = 0; i < enemyHand._enemyProjectiles.Count; i++) { if (Collisions.CollidesWith(enemyHand._enemyProjectiles.ElementAt(i).Bounds, player.Bounds)) { Console.WriteLine("hit registered"); player.life -= enemyHand._enemyProjectiles.ElementAt(i).damage; enemyHand._enemyProjectiles.Remove(enemyHand._enemyProjectiles.ElementAt(i)); Console.WriteLine(System.Convert.ToString(player.life)); userInterface.playerLifeText = Convert.ToString(player.life); } } if (userInterface.timer >= 1.0F) { userInterface.timer = 0F; } if (userInterface.timecounter < 0) { if (Convert.ToInt16(userInterface.playerLifeText) > Convert.ToInt16(userInterface.enemyLifeText)) { userInterface.playerText++; userInterface.playerLifeText = "30"; userInterface.enemyLifeText = "30"; player.life = 30; player2.life = 30; } else if (Convert.ToInt16(userInterface.enemyLifeText) > Convert.ToInt16(userInterface.playerLifeText)) { userInterface.enemyText++; userInterface.playerLifeText = "30"; userInterface.enemyLifeText = "30"; player.life = 30; player2.life = 30; } userInterface.timecounter = 30; userInterface.roundText++; } if (player.life <= 0) { userInterface.timecounter = 30; userInterface.enemyText++; userInterface.playerLifeText = "30"; userInterface.enemyLifeText = "30"; player.life = 30; player2.life = 30; } if (player2.life <= 0) { userInterface.timecounter = 30; userInterface.playerText++; userInterface.playerLifeText = "30"; userInterface.enemyLifeText = "30"; player.life = 30; player2.life = 30; } if (userInterface.playerText == 3) { _game.ChangeState(new MenuState(_game, _graphicsDevice, _content)); } if (userInterface.enemyText == 3) { _game.ChangeState(new MenuState(_game, _graphicsDevice, _content)); } }