示例#1
0
    public void Update(Actor actor)
    {
        if (Action.State == EventAction.ActionState.None)
        {
            bool satisfied = true;
            //Debug.Log(Deps);
            if (Deps != null)
            {
                //Debug.Log(Deps.Count);
                foreach (var dep in Deps)
                {
                    //Debug.LogFormat("{0} = {1}", dep.GetType(), dep.Satisfied());
                    if (!dep.Satisfied())
                    {
                        satisfied = false;
                        break;
                    }
                }
            }
            if (satisfied)
            {
                if (Action.Filter())
                {
                    Action.Action();
                }
                else
                {
                    Action.State = EventAction.ActionState.Failed;
                }
            }
            else
            {
                if (currentDep == null || currentDep.Satisfied())
                {
                    var dep = Deps.Find(d => !d.Satisfied());
                    //Debug.Log(Deps.Count);
                    currentDep = dep;
                    //Debug.Log(dep.GetType().Name);
                }
                if (currentDep.ActionWrapper == null)
                {
                    currentDep.ActionWrapper        = new ActionWrapper();
                    currentDep.ActionWrapper.Action = actor.FindAction(currentDep.ActionCategory(), out currentDep.ActionWrapper.Deps, currentDep);
                }
                currentDep.ActionWrapper.Update(actor);
            }
        }

        if (Action.State == EventAction.ActionState.Started)
        {
            //Debug.Log("Update the action " + Action.GetType().Name);
            Action.Update();
        }

        if (Action.State == EventAction.ActionState.Failed)
        {
            //Debug.Log(Action.State);
        }

        if (Action.State == EventAction.ActionState.Finished)
        {
            //Debug.Log(Action.State);
        }
    }