public override void Update(CVGameTime gameTime) { base.Update(gameTime); // as soon as a player moves past the bridge horizontally, have the bridge explode. // occurs even if player is not standing on the bridge. foreach (Actors.Player player in CurrentStage.Players) { if (this.WorldPosition.X < player.WorldPosition.X && Exploding == false) { Explode(); } } if (Exploding) { if (_explosionSoundInstance.State == SoundState.Stopped) { _explosionPlayCount++; if (_explosionPlayCount < 4) { ExplodeBridgePiece(_explosionPlayCount); } else { Active = false; } } } }
public void Update(CVGameTime gameTime) { if (_recoilTimeRemaining > 0) { _recoilTimeRemaining -= (float)gameTime.ElapsedGameTime.TotalSeconds; if (_recoilTimeRemaining < 0) { _recoilTimeRemaining = 0; } } }
//public void Initialize(Texture2D texture, Vector2 position, Player player, Stage stage) //{ // Image = new Animation(); // //Texture = texture; // currentStage = stage; // WorldPosition = position; // Image.Initialize(texture, position, 3, 10, Color.White, 1, true, currentStage); // if (player.gunDirection == Player.GunDirection.StraightUp) // Velocity = new Vector2(0, -projectileSpeed); // else if (player.gunDirection == Player.GunDirection.StraightDown) // Velocity = new Vector2(0, projectileSpeed); // else // { // int directionFactor; // if (player.playerDirection == Player.PlayerDirection.Right) // directionFactor = 1; // else // directionFactor = -1; // switch (player.gunDirection) // { // case Player.GunDirection.High: // Velocity = new Vector2(projectileSpeed * directionFactor, -((projectileSpeed * 2) / 3)); // break; // case Player.GunDirection.Low: // Velocity = new Vector2(projectileSpeed * directionFactor, ((projectileSpeed * 2) / 3)); // break; // default: // Velocity = new Vector2(projectileSpeed * directionFactor, 0); // break; // } // } // Active = true; // Damage = 2; //} public void Update(CVGameTime gameTime, Vector2 cameraPosition) { WorldPosition += Velocity; Image().Update(gameTime); Image().WorldPosition = WorldPosition; //if (Direction == Player.GunDirection.Right) // Position.X += projectileMoveSpeed; //else if (Direction == Player.GunDirection.Left) // Position.X -= projectileMoveSpeed; // Deactivate the bullet if it goes out of screen if (ScreenPosition.X < 0 || ScreenPosition.Y < 0 || ScreenPosition.X > Game.iScreenModelWidth || ScreenPosition.Y > Game.iScreenModelHeight) { Active = false; } }