コード例 #1
0
        private static void RespondToICollectableCollision(ICollectable powerUp, AbstractCharacter character)
        {
            if (!powerUp.HasBeenConsumed)
            {
                SoundFactory.PlayCollectibleCollectedSound();
                powerUp.SetCharacter(character);

                if (character.CurrentPowerup != null)
                {
                    ICollectable current = character.CurrentPowerup;
                    current.Destroy();
                }

                character.CurrentPowerup = powerUp;
                powerUp.Consume();
            }
        }