/// <summary> /// Processes the power-up - Optimizes it according to its nature. /// </summary> /// <param name="powerUp">The power-up to process</param> /// <param name="gameTime">The current game time</param> /// <returns>The processed power-up.</returns> private PowerUp ProcessPowerUp( PowerUp powerUp, GameTime gameTime ) { PowerUp processedPowerUp = powerUp; if ( powerUp is SpeedBoost ) { // One instance of processing is to set the speed boost's factor according to the setting file. processedPowerUp = new SpeedBoost( gameTime, BoostFactor ); } return processedPowerUp; }
public bool AppendPowerUp( PowerUp powerUp, GameTime gameTime ) { if ( powerUp is AppearingPowerUp ) return false; else if ( powerUp is InstantPowerUp ) { if ( PendingPowerUp == null ) { PendingPowerUp = ( InstantPowerUp )powerUp; PendingPowerUp.Take( this, gameTime ); return true; } else return false; } else if ( powerUp is TimedPowerUp ) { if ( this.powerUp == null ) { this.powerUp = ( TimedPowerUp )powerUp; this.powerUp.Take( this, gameTime ); return true; } else return false; } else { throw new Exception( "Liek if this gets thrown, i'm a sheep" ); } }