コード例 #1
0
 public void UpdatePlayerScoreFromPowerup(object sender, PowerupCollectedEventArgs e)
 {
     if (ReferenceEquals(e.Collector, ParentHUD.Player))
     {
         playerScore += e.PointValue;
     }
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
        /// <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++;
            }
        }