public void Update(Game game,ContentManager content, SpriteBatch spriteBatch, SpriteFont font, Player playerOne, List<Sprite> enemies, EnemyShots enemyShots, PlayerShots playerShots, List<Sprite> randomObjects, List<HealthBar> healthBars, Sprite playerOneSprite, GraphicsDeviceManager graphics, Player playerTwo = null, Sprite playerTwoSprite = null) { this.enemies = enemies; this.enemyShots = enemyShots; this.playerShots = playerShots; this.playerOneSprite = playerOneSprite; this.dinosaurOne = playerOne; this.playerTwoSprite = playerTwoSprite; this.dinosaurTwo = playerTwo; _halfScreenHeight = graphics.PreferredBackBufferHeight / 1.5f; gdm = graphics; sb = spriteBatch; cm = content; explosionSound = cm.Load<SoundEffect>("Sounds/explosion"); laserPowerupSound = cm.Load<SoundEffect>("Sounds/Few"); healthPowerupSound = cm.Load<SoundEffect>("Sounds/Few"); enemyHit = cm.Load<SoundEffect>("Sounds/Few"); playerHit = cm.Load<SoundEffect>("sounds/Punch"); if (!playerOneSprite.IsInvincible) { CheckIfEnemyHitsPlayer(); } CheckIfPowerupHitsPlayer(); CheckIfPlayerHitSomething(game, spriteBatch, content, healthBars); checkIfPlayerIsHitByGroundItem(randomObjects); }
public void Update(GraphicsDeviceManager graphics, Sprite enemy, EnemyShots enemyShots) { if (rand.NextDouble() < 0.01 && enemy.Position.X > -10 && enemy.Position.X < graphics.PreferredBackBufferWidth + 10 && enemy.Name != "Explode") { enemy.OKFire = true; enemy.bulletCount = 0; } if (enemy.enemyType.type == EnemyType.Etype.Gunner && enemy.OKFire) { if (enemy.bulletCount < 7) { gunnerSound.Play(); enemyShots.AddShot(enemy); enemy.bulletCount++; } else { enemy.OKFire = false; } } else if (enemy.enemyType.type == EnemyType.Etype.Level1Boss && enemy.OKFire) { if (enemy.bulletCount < 2) { simpleSound.Play(); enemyShots.AddShot(enemy); enemy.bulletCount++; } else { enemy.OKFire = false; } } else if (enemy.OKFire) { simpleSound.Play(); enemyShots.AddShot(enemy); enemy.OKFire = false; } }
/// <summary> /// UnloadContent will be called once per game and is the place to unload /// all content. /// </summary> protected override void UnloadContent() { gameState = GameState.TitleScreen; previousState = gameState; upgradeScreen = null; startScreen = null; characterScreen = null; multiplayerLobby = null; deathScreen = null; levelBeginning = null; pauseScreen = null; loadingScreen = null; levelCreator = null; Random rand = new Random(); currentLevel = null; enemies = null; explosions = null; shotBehavior = null; enemyShots = null; playerShots = null; hbOne = null; hbTwo = null; bossLifeBar = null; cbOne = null; cbTwo = null; backGroundMusic = null; playerOneMeterTitle = null; playerTwoMeterTitle = null; meterLabel = null; playerOneMarker = null; playerTwoMarker = null; dinosaurOne = null; dinosaurTwo = null; playerOneSprite = null; playerTwoSprite = null; collisions = null; font = null; playerOneCounter = 0; playerTwoCounter = 0; levelIncrement = 0; singlePlayer = false; explodedOne = false; explodedTwo = false; input = null; padInput = null; }
protected void LoadCharacter() { if (startScreen.SinglePlayer) { singlePlayer = true; dinosaurOne = new Player(Content, graphics, characterScreen.Character, 1); dinosaurOne.ControlScheme = startScreen.ControlScheme; ValidateCharacter(1); playerOneSprite.Position = new Vector2(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight - 250); } else if (startScreen.MultiPlayer) { singlePlayer = false; dinosaurOne = new Player(Content, graphics, multiplayerLobby.playerOne, 1); dinosaurTwo = new Player(Content, graphics, multiplayerLobby.playerTwo, 2); dinosaurOne.ControlScheme = multiplayerLobby.firstPlayerControl; dinosaurTwo.ControlScheme = multiplayerLobby.secondPlayerControl; ValidateCharacter(1); ValidateCharacter(2); playerOneSprite.Position = new Vector2(graphics.PreferredBackBufferWidth / 3, graphics.PreferredBackBufferHeight - 250); playerTwoSprite.Position = new Vector2(graphics.PreferredBackBufferWidth - (graphics.PreferredBackBufferWidth / 3), graphics.PreferredBackBufferHeight - 250); } playerShots = new PlayerShots(Content, dinosaurOne, playerOneSprite, dinosaurTwo, playerTwoSprite); shotBehavior = new ShotBehavior(Content); enemyShots = new EnemyShots(Content); CreateScreens(); GenerateLevel(); }