DRObjects.Items.Archetypes.Local.Potion.PerformAction C# (CSharp) Méthode

PerformAction() public méthode

public PerformAction ( ActionType actionType, Actor actor, object args ) : ActionFeedback[]
actionType ActionType
actor Actor
args object
Résultat ActionFeedback[]
        public override ActionFeedback[] PerformAction(ActionType actionType, Actor actor, object[] args)
        {
            //See if we can identify the item
            if (actor.Knowledge.CanIdentifyPotion(this.PotionType))
            {
                this.IsIdentified = true; //identify!
            }

            if (actionType == ActionType.CONSUME)
            {
                //Take the effects of the potion
                //Identify it too!
                this.IsIdentified = true;
                actor.Knowledge.LearnToIdentify(this.PotionType);

                //remove from inventory
                actor.Inventory.Inventory.Remove(this.Category, this);

                switch (this.PotionType)
                {
                    case Enums.PotionType.AGILITY:
                        {
                            Effect effect = new Effect();
                            effect.Actor = actor;
                            effect.EffectAmount = 2;
                            effect.MinutesLeft = 5;
                            effect.Name = EffectName.AGIL;
                            effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "The effect wears off");
                            return new ActionFeedback[2] { new ReceiveEffectFeedback() { Effect = effect }, new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "You feel more agile") };
                        }
                    case Enums.PotionType.BLEEDING:
                        actor.Anatomy.BloodLoss = 2; //Start bleeding. Silly idiot
                        return new ActionFeedback[1] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.DarkRed, "The potion scrapes your insides as you drink it. You start bleeding") };
                    case Enums.PotionType.BLINDING:
                        {
                            Effect effect = new Effect();
                            effect.Actor = actor;
                            effect.EffectAmount = 10;
                            effect.MinutesLeft = 3;
                            effect.Name = EffectName.BLIND;
                            effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "You can see again");
                            return new ActionFeedback[2] { new ReceiveEffectFeedback() { Effect = effect }, new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.DarkRed, "Your eyes cloud over.") };
                        }
                    case Enums.PotionType.BRAWN:
                        {
                            Effect effect = new Effect();
                            effect.Actor = actor;
                            effect.EffectAmount = 2;
                            effect.MinutesLeft = 5;
                            effect.Name = EffectName.BRAWN;
                            effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "The effect wears off");
                            return new ActionFeedback[2] { new ReceiveEffectFeedback() { Effect = effect }, new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "You feel strong") };
                        }
                    case Enums.PotionType.CHARISMA:
                        { //AKA Alcohol :)
                            Effect effect = new Effect();
                            effect.Actor = actor;
                            effect.EffectAmount = 2;
                            effect.MinutesLeft = 5;
                            effect.Name = EffectName.CHAR;
                            effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "The effect wears off");
                            return new ActionFeedback[2] { new ReceiveEffectFeedback() { Effect = effect }, new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "You feel more confident") };
                        }
                    case Enums.PotionType.DEFENCE:
                        actor.CurrentDefences = actor.MaximumDefences;
                        return new ActionFeedback[1] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "Your defences are ready once more") };
                    case Enums.PotionType.DEFENSIVE_KNOWLEDGE:
                        {
                            for (int i = 0; i < 20; i++)
                            {
                                actor.Attributes.IncreaseSkill(SkillName.DODGER);
                            }
                            return new ActionFeedback[1] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "You become more knowledgable about not getting hit") };
                        }
                    case Enums.PotionType.FEEDING:
                        {
                            //Fill em up
                            actor.FeedingLevel = FeedingLevel.STUFFED;
                            return new ActionFeedback[1] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "You feel rather full") };
                        }
                    case Enums.PotionType.FIRE:
                        {
                            actor.Anatomy.Chest -= 2;
                            return new ActionFeedback[1] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.DarkRed, "The potion tastes like fire. That burns a bit...") };
                        }
                    case Enums.PotionType.HEALING:
                        {
                            //Be healed! This is not strictly speaking an effect, but that should be fine
                            Effect effect = new Effect();
                            effect.Actor = actor;
                            effect.EffectAmount = 5;
                            effect.MinutesLeft = 0;
                            effect.Name = EffectName.HEAL;
                            effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "Your wounds heal...");
                            return new ActionFeedback[2] { new ReceiveEffectFeedback() { Effect = effect }, new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "Your wounds close") };
                        }
                    case Enums.PotionType.ICE:
                        {
                            actor.Anatomy.Chest -= 2;
                            return new ActionFeedback[1] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.DarkRed, "The potion freezes your insides.") };
                        }
                    case Enums.PotionType.INTELLIGENCE:
                        {
                            Effect effect = new Effect();
                            effect.Actor = actor;
                            effect.EffectAmount = 2;
                            effect.MinutesLeft = 5;
                            effect.Name = EffectName.INTEL;
                            effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "The effect wears off");
                            return new ActionFeedback[2] { new ReceiveEffectFeedback() { Effect = effect }, new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "You feel smarter") };
                        }
                    case Enums.PotionType.OFFENSIVE_KNOWLEDGE:
                        {
                            for (int i = 0; i < 20; i++)
                            {
                                actor.Attributes.IncreaseSkill(SkillName.FIGHTER);
                            }
                            return new ActionFeedback[1] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "You become more knowledgable about hitting things") };
                        }
                    case Enums.PotionType.PARALYSIS:
                        {
                            actor.Anatomy.StunAmount = 3;
                            return new ActionFeedback[1] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.DarkRed, "You can't move...") };
                        }
                    case Enums.PotionType.PERCEPTION:
                        {
                            Effect effect = new Effect();
                            effect.Actor = actor;
                            effect.EffectAmount = 2;
                            effect.MinutesLeft = 5;
                            effect.Name = EffectName.PERC;
                            effect.EffectDisappeared = new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.Blue, "The effect wears off");
                            return new ActionFeedback[2] { new ReceiveEffectFeedback() { Effect = effect }, new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.ForestGreen, "Your vision feels sharper") };
                        }
                    case Enums.PotionType.POISON:
                        {
                            actor.Anatomy.Chest -= 2;
                            return new ActionFeedback[1] { new LogFeedback(InterfaceSpriteName.POTION_ICON, Color.DarkRed, "This potion tastes horrible. You feel sick.") };
                        }
                    default:
                        throw new NotImplementedException("No code for " + this.PotionType);
                }

            }
            else
            {
                return base.PerformAction(actionType, actor, args);
            }
        }