コード例 #1
0
        private void CollectItem(ICollectable pu)
        {
            MarioSprite mSprite = sprite as MarioSprite;

            if (pu is Fireflower && State != MarioState.Fire)
            {
                mSprite.SetTransitionStates(MarioState.Fire);
                PowerUpTimer = 80;
                State        = MarioState.Fire;
            }
            else if (pu is TNTPowerUp && State != MarioState.TNT)
            {
                mSprite.SetTransitionStates(MarioState.TNT);
                PowerUpTimer = 80;
                State        = MarioState.TNT;
            }
            else if (pu is Gun && State != MarioState.Gun)
            {
                mSprite.SetTransitionStates(MarioState.Gun);
                PowerUpTimer = 90;
                State        = MarioState.Gun;
            }
            else if (pu is Mushroom && State < MarioState.Big)
            {
                mSprite.SetTransitionStates(MarioState.Big);
                PowerUpTimer = 80;
                State        = MarioState.Big;
            }
            else if (pu is Star)
            {
                StarTimer = 600;
            }
            else if (pu is Coin)
            {
                world.CollectCoin(pu as Coin);
            }
            else if (pu is OneUp)
            {
                world.Lives++;
            }

            pu.Kill();
        }