public override Enemy CreateEnemy(Vector2 pos, int movementStrategy, int bulletStrategy) { Enemy NewEnemy = new FinalBoss(pos, (float)1.75, movementStrategy, bulletStrategy); //GeneratePosition is used temporarily while we do not have positions to pass in return(NewEnemy); }
public void ManagerUpdate(SpriteBatch spriteBatch, GameTime gameTime, KeyboardState state) { passedFrames++; passedPowerupFrames++; // check if user is alive if (Property.test_player.dead) { isGameOver = true; return; } Property.state = state; // updates the keyboard state in GameProperties Property.test_player.Update(state); // update the player //TestCode(); //DemoCode(); interpreter.Interpret(); if (passedFrames >= SpawnInterval) { AddEnemy(); passedFrames = 0; } // check if the user is shooting if (state.IsKeyDown(Keys.Space) && Property.prev_state.IsKeyUp(Keys.Space)) { Property.playerBullets.Add(CreateBullet(Property.BulletType.Green, new Vector2(Property.test_player.entPosition.X, (Property.test_player.entPosition.Y - 100)), new Vector2(0, -1), 0, 0)); Property.SoundEffects["throw"].Play(); } /// Updates each enemy MovedEnemy movement = new MovedEnemy(); //strategy call foreach (Enemy enemy in Property.enemies) //movement updates { switch (enemy.movementStrat) { case 1: movement.SetMovement(new GruntMovement()); movement.Move(enemy); break; case 2: movement.SetMovement(new GruntMovement2()); movement.Move(enemy); break; case 3: movement.SetMovement(new GruntMovement3()); movement.Move(enemy); break; case 8: movement.SetMovement(new MidbossMovement()); movement.Move(enemy); break; case 9: movement.SetMovement(new FinalbossMovement()); movement.Move(enemy); break; default: movement.SetMovement(new GruntMovement()); movement.Move(enemy); break; } } if (gameTime.TotalGameTime.Milliseconds % 500 == 0) // condition for enemies to shoot { foreach (Enemy enemy in Property.enemies) { if (enemy.isFinBoss && gameTime.TotalGameTime.Milliseconds % 6000 == 0) { FinalBoss placeHolder = (FinalBoss)enemy; placeHolder.FireSpecialAttack(bulletFactory); } Property.enemyBullets.Add(enemy.CreateBullet(Property.BulletType.Red, (float)3.15, bulletFactory)); // invoke factories in GameManager } } /// Updates each player bullet foreach (Bullet b in Property.playerBullets) { movement.SetMovement(new PlayerBulletMovement()); movement.MoveBullet(b); } /// Updates each enemy bullet foreach (Bullet b in Property.enemyBullets) { switch (b.movementPattern) { case 1: movement.SetMovement(new BulletMovement()); movement.MoveBullet(b); break; case 2: movement.SetMovement(new BulletMovement2()); movement.MoveBullet(b); break; case 3: movement.SetMovement(new BulletMovement3()); movement.MoveBullet(b); break; default: movement.SetMovement(new BulletMovement()); movement.MoveBullet(b); break; } } // Updates each powerup foreach (var power in Property.powerUps) { power.Update(); } //power up creation if (passedPowerupFrames >= spawnPowerupInterval) { Random rand = new Random(); float randX = rand.Next(1, Property.ScreenWidth); float randY = rand.Next(1, Property.ScreenHeight); Vector2 pos = new Vector2(randX, randY); Property.powerUps.Add(CreatePowerup(pos)); // !!! passedPowerupFrames = 0; } Property.prev_state = Property.state; Property.CheckCollisions(); Property.RemoveInactiveEntities(spriteBatch, gameTime); if (Property.gameWon) { isGameWon = true; return; } return; }