public void UpdatePlayerScoreFromPowerup(object sender, PowerupCollectedEventArgs e) { if (ReferenceEquals(e.Collector, ParentHUD.Player)) { playerScore += e.PointValue; } }
public void PowerUpCollectedSound(object sender, PowerupCollectedEventArgs e) { if (sender is GreenMushroomObject) { SoundPool.Instance.GetAndPlay(SoundType.UP1, false); } if (sender is CoinObject) { SoundPool.Instance.GetAndPlay(SoundType.Coin, false); } }
/// <summary> /// This method is intended for when Mario receives things that change a meta-game state, i.e. he gains a life or a coin. This is /// not meant for the updating of his states, that should happen in sync with Mario's update/collision response. This is less time /// dependent, and therefore easier to just have this happen as a response to a notification from a powerup. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ReceivePowerup(object sender, PowerupCollectedEventArgs e) { //TODO move this into states? if (!ReferenceEquals(e.Collector, this)) { return; } if (e.Sender is CoinObject) { CoinCount++; if (CoinCount >= 100) { CoinCount = 0; Lives++; } } else if (e.Sender is GreenMushroomObject) { Lives++; } }