private void DressRootWithInventoryActions(ActionButtonNode root)
            {
                List <Action> inventoryActions = new List <Action> ();

                inventoryActions.Add(new PickUp(this));
                inventoryActions.Add(new DropItem(this));
                inventoryActions.Add(new Equip(this));
                inventoryActions.Add(new GiveItem(this));
                List <ActionButtonNode> nodes = inventoryActions.Select((ac) => {
                    //					actions.Remove(ac);
                    ActionButtonNode actionRoot = ac.GetOptionTreeRoot();

                    if (UsedInteraction())
                    {
                        if (UsedAction())
                        {
                            actionRoot.disabled       = true;
                            actionRoot.disabledReason = "You've already taken an action\n and an interaction this turn.";
                        }
                        else
                        {
                            //Allows the interaction to happen as an action.
                            ac.IsInteraction = false;
                        }
                    }


                    return(actionRoot);
                }).ToList();

                ActionPointer inventory = new ActionPointer("Inventory", nodes);

                inventory.spriteLabel = IconDispenser.instance.SpriteFromIconName(IconName.INVENTORY);
                root.AddChild(inventory.GetRoot());
            }
示例#2
0
            public void PopulatePathChildren(ActionButtonNode parent, List <ActionOption> optionsLeft, Actor actor)
            {
                //this is a leaf state of the action in the following case.
                //Now check to see if there are any target leaves it leads to for the purpose of setting the parent disabled
                if (optionsLeft.Count == 0)
                {
                    Actor theActor = null;                     //need to change our character for an actor instead....
                    //dead end, can't fill params at this option leaf.  Set parent disabled, and reason to "cannot fil prams"
                    if (!CanFillParams(theActor))
                    {
                        parent.disabled       = true;
                        parent.disabledReason = LastLackOfTargetReason;
                    }
                    return;
                }

                ActionOption nextOne = optionsLeft.First();

                optionsLeft.Remove(nextOne);

                List <IActionOptionChoice> choices = nextOne.GetChoices(actor, this);

                //set parent disabled.
                if (choices.Count <= 0)
                {
                    parent.disabled = true;

                    parent.disabledReason = nextOne.LastNoChoiceReason;
                }

                foreach (IActionOptionChoice choice in choices)
                {
                    ActionButtonNode child = new ActionButtonNode();
                    child.label  = choice.ValueLabel();
                    child.choice = choice;
                    choice.DecorateOption(child);

                    parent.AddChild(child);

                    //imitate the next choice being chosen, so GetChoices works correctly...
                    nextOne.chosenChoice = choice;
                    PopulatePathChildren(child, optionsLeft.ToList(), actor);
                    nextOne.chosenChoice = null;
                }
            }
            private void DressRootWithStandardActions(ActionButtonNode root)
            {
                List <Action> actions = QueryActions();

                foreach (Action action in actions)
                {
                    ActionButtonNode actionRoot = action.GetOptionTreeRoot();

                    if (action.IsAttack)
                    {
                        if (AttacksLeft() <= 0)
                        {
                            actionRoot.disabled       = true;
                            actionRoot.disabledReason = "You cannot attack more than\n" + CharSheet.AttacksPerRound + " time(s) per turn.";
                        }
                        else if (UsedAction())
                        {
                            actionRoot.disabled       = true;
                            actionRoot.disabledReason = "You've already taken an action this turn";
                        }
                    }
                    else if (UsedAction() && !action.IsWait)
                    {
                        actionRoot.disabled       = true;
                        actionRoot.disabledReason = "You've already taken an action this turn";
                    }

                    //implements the rule where casting can't be done with unproficent equipment
                    if (action is Cast)
                    {
                        if (!CharSheet.IsProficientInAllWornEquipment())
                        {
                            actionRoot.disabled       = true;
                            actionRoot.disabledReason = "You cannot cast spells when wielding weapons or armour you are not proficient in";
                        }
                    }

                    root.AddChild(actionRoot);
                }
            }
            private void DressRootWithBonusActions(ActionButtonNode root)
            {
                //Add bonus actions...
                List <Action> bonus = QueryBonusActions(CharSheet);

                //I think this is doing nothing..... since the folooring line does a select
                foreach (Action act in bonus)
                {
                    ActionButtonNode ro = act.GetOptionTreeRoot();
                }
                ActionPointer p = new ActionPointer("Bonus Action", bonus.Select((act) => act.GetOptionTreeRoot()).ToList());

                p.spriteLabel = IconDispenser.instance.SpriteFromIconName(IconName.BONUS_ACTION);
                ActionButtonNode bonusRoot = p.GetRoot();

                if (UsedBonusAction())
                {
                    bonusRoot.disabled       = true;
                    bonusRoot.disabledReason = "You already used a bonus action this round";
                }
                root.AddChild(bonusRoot);
            }