public override void Initialize() { entityManager.Entities.Add(new PassBall()); entityManager.Entities.Add(new ShootBall()); entityManager.Entities.Add(new ShootTarget(InputManager, new Player(PlayerIndex.One, InputManager, PlayerManager))); for (int i = 0; i < 3; i++) { BasicEnemy basicEnemy = new BasicEnemy(PlayerManager); basicEnemy.Position.X = 900; basicEnemy.Position.Y = (i * 60) + 275; enemyManager.Enemies.Add(basicEnemy); } for (int i = 0; i < 4; i++) { BasicEnemy basicEnemy = new BasicEnemy(PlayerManager); basicEnemy.Position.X = 1100; basicEnemy.Position.Y = (i * 60) + 225; enemyManager.Enemies.Add(basicEnemy); } /*BasicEnemy basicEnemy = new BasicEnemy(PlayerManager); basicEnemy.Position.X = 900; basicEnemy.Position.Y = 375; enemyManager.Enemies.Add(basicEnemy);*/ }
public override void Update(GameTime gameTime) { switch (ScreenState) { case ScreenStates.TransitionIn: if (!IsTransitionDone(gameTime.TotalGameTime, TransitionInTime)) { } else { ScreenState = ScreenStates.Active; } break; case ScreenStates.TransitionOut: if (!IsTransitionDone(gameTime.TotalGameTime, TransitionOutTime)) { alpha += 127 / (float)(TransitionOutTime.TotalMilliseconds / gameTime.ElapsedGameTime.TotalMilliseconds); } break; case ScreenStates.TransitionNextArea: if (wrapAround) { wrapAroundXDest -= 10; } backgroundRectangle.X += 10; foreach (Player player in PlayerManager.Players) { // move player back to left player.Character.Position.X -= 7.5F; player.Character.DrawHealthBar = false; player.Character.CurrentAnimation.Update(gameTime); } foreach (Enemy enemy in enemyManager.Enemies) { enemy.Position.X -= 10; } if (wrapAround && wrapAroundXDest == 0) { backgroundRectangle = new Rectangle(0, 0, 1280, 720); wrapAround = false; ScreenState = ScreenStates.Active; } else if (backgroundRectangle.X == 1280 * (areaCounter - 1)) { ScreenState = ScreenStates.Active; } break; case ScreenStates.Active: bool allPlayersDead = true; bool allPlayersOnRightEdge = true; foreach (Player player in PlayerManager.Players) { player.Character.DrawHealthBar = true; if (!player.Character.MarkForDelete) { allPlayersDead = false; } if (player.Character.Position.X < 1000) { allPlayersOnRightEdge = false; } } if(allPlayersDead) { ScreenState = ScreenStates.TransitionOut; } if (enemyManager.Enemies.Count == 0 && allPlayersOnRightEdge && areaCounter == 1) { areaCounter++; foreach (Player player in PlayerManager.Players) { player.Character.FacingLeft = false; player.Character.SelectAnimation(player.Character.RunningAnimation); player.Character.Health = Math.Max(player.Character.Health + player.Character.MaxHealth/3, player.Character.MaxHealth); } for (int i = 0; i < 3; i++) { Chaser basicEnemy = new Chaser(PlayerManager); basicEnemy.Position.X = (i * 50) + 800 + 1280; basicEnemy.Position.Y = (i * 100) + 275; enemyManager.Enemies.Add(basicEnemy); } for (int i = 0; i < 4; i++) { Chaser chaser = new Chaser(PlayerManager); chaser.Position.X = (i * 50) + 1000 + 1280; chaser.Position.Y = (i * 100) + 225; enemyManager.Enemies.Add(chaser); } enemyManager.LoadContent(ContentManager); ScreenState = ScreenStates.TransitionNextArea; break; } else if (enemyManager.Enemies.Count == 0 && allPlayersOnRightEdge && areaCounter == 2) { areaCounter++; foreach (Player player in PlayerManager.Players) { player.Character.FacingLeft = false; player.Character.SelectAnimation(player.Character.RunningAnimation); player.Character.Health = Math.Max(player.Character.Health + player.Character.MaxHealth / 3, player.Character.MaxHealth); } for (int i = 0; i < 3; i++) { BasicEnemy chaser = new BasicEnemy(PlayerManager); chaser.Position.X = (i * 50) + 800 + 1280; chaser.Position.Y = (i * 100) + 275; enemyManager.Enemies.Add(chaser); } for (int i = 0; i < 4; i++) { Chaser chaser = new Chaser(PlayerManager); chaser.Position.X = (i * 50) + 1000 + 1280; chaser.Position.Y = (i * 100) + 225; enemyManager.Enemies.Add(chaser); } enemyManager.LoadContent(ContentManager); ScreenState = ScreenStates.TransitionNextArea; break; } else if (enemyManager.Enemies.Count == 0 && allPlayersOnRightEdge && areaCounter == 3) { areaCounter = 1; wrapAround = true; foreach (Player player in PlayerManager.Players) { player.Character.FacingLeft = false; player.Character.SelectAnimation(player.Character.RunningAnimation); player.Character.Health = Math.Max(player.Character.Health + player.Character.MaxHealth / 3, player.Character.MaxHealth); } for (int i = 0; i < 3; i++) { BasicEnemy chaser = new BasicEnemy(PlayerManager); chaser.Position.X = (i * 50) + 800 + 1280; chaser.Position.Y = (i * 100) + 275; enemyManager.Enemies.Add(chaser); } for (int i = 0; i < 4; i++) { BasicEnemy chaser = new BasicEnemy(PlayerManager); chaser.Position.X = (i * 50) + 1000 + 1280; chaser.Position.Y = (i * 100) + 225; enemyManager.Enemies.Add(chaser); } enemyManager.LoadContent(ContentManager); ScreenState = ScreenStates.TransitionNextArea; break; } PlayerManager.Update(gameTime); entityManager.Update(gameTime); enemyManager.Update(gameTime); break; } }