コード例 #1
0
        // EXECUTE METHOD: ------------------------------------------------------------------------

        public override bool InstantExecute(GameObject target, IAction[] actions, int index)
        {
            ListVariables list = this.listVariables.GetListVariables(target);

            if (list == null || list.variables.Count == 0)
            {
                return(true);
            }

            for (int i = list.variables.Count - 1; i >= 0; --i)
            {
                switch (this.clear)
                {
                case ClearType.ClearAll:
                    list.Remove(i);
                    break;

                case ClearType.ClearEmpty:
                    Variable variable = list.Get(i);
                    if (variable == null || variable.Get().Equals(null))
                    {
                        list.Remove(i);
                    }
                    break;
                }
            }

            return(true);
        }
コード例 #2
0
 public static Variable GetListItem(ListVariables list, ListVariables.Position position, int index = 0)
 {
     return(list.Get(position, index));
 }
コード例 #3
0
        // EXECUTABLE: ----------------------------------------------------------------------------

        public override IEnumerator Execute(GameObject target, IAction[] actions, int index)
        {
            ListVariables list = this.listVariables.GetListVariables(target);

            if (list == null)
            {
                yield break;
            }

            Actions    actionsToExecute    = null;
            Conditions conditionsToExecute = null;

            switch (this.source)
            {
            case Source.Actions:
                actionsToExecute = this.actions;
                break;

            case Source.Conditions:
                conditionsToExecute = this.conditions;
                break;

            case Source.VariableWithActions:
                GameObject valueActions = this.variable.Get(target) as GameObject;
                if (valueActions != null)
                {
                    actionsToExecute = valueActions.GetComponent <Actions>();
                }
                break;

            case Source.VariableWithConditions:
                GameObject valueConditions = this.variable.Get(target) as GameObject;
                if (valueConditions != null)
                {
                    conditionsToExecute = valueConditions.GetComponent <Conditions>();
                }
                break;
            }

            for (int i = 0; i < list.variables.Count && !this.forceStop; ++i)
            {
                Variable itemVariable = list.Get(i);
                if (itemVariable == null)
                {
                    continue;
                }

                GameObject itemGo = itemVariable.Get() as GameObject;
                if (itemGo == null)
                {
                    continue;
                }

                this.executionComplete = false;
                if (actionsToExecute != null)
                {
                    actionsToExecute.actionsList.Execute(itemGo, this.OnCompleteActions);
                    WaitUntil wait = new WaitUntil(() =>
                    {
                        if (actionsToExecute == null)
                        {
                            return(true);
                        }
                        if (this.forceStop)
                        {
                            actionsToExecute.actionsList.Stop();
                            return(true);
                        }

                        return(this.executionComplete);
                    });

                    yield return(wait);
                }
                else if (conditionsToExecute != null)
                {
                    conditionsToExecute.Interact(itemGo);
                }
            }

            yield return(0);
        }