Пример #1
0
        //protected virtual void DoActions(NpcStateController controller)
        //{
        //    for (int i = 0; i < actions.Length; i++)
        //    {
        //        actions[i].Execute(controller);
        //    }
        //}

        protected virtual void DoActions(EnemiesAIStateController controller)
        {
            for (int i = 0; i < actions.Length; i++)
            {
                actions[i].Execute(controller);
            }
        }
Пример #2
0
        //public void OnEnterState(NpcStateController controller)
        //{
        //    for (int i = 0; i < enterActions.Length; i++)
        //    {
        //        enterActions[i].Execute(controller);
        //    }
        //}

        public void OnEnterState(EnemiesAIStateController controller)
        {
            for (int i = 0; i < enterActions.Length; i++)
            {
                enterActions[i].Execute(controller);
            }
        }
Пример #3
0
        //private void CheckTransitions(NpcStateController controller)
        //{
        //    for (int i = 0; i < transitions.Length; i++)
        //    {
        //        bool decisionSucceeded = true;
        //        for (int j = 0; j < transitions[i].decision.Length; j++)
        //        {
        //            decisionSucceeded = decisionSucceeded && transitions[i].decision[j].Decide(controller);
        //        }


        //        if (decisionSucceeded)
        //        {
        //            controller.TransitionToState(transitions[i].trueState);
        //        }
        //        else
        //        {
        //            controller.TransitionToState(transitions[i].falseState);
        //        }
        //    }
        //}

        private void CheckTransitions(EnemiesAIStateController controller)
        {
            for (int i = 0; i < transitions.Length; i++)
            {
                bool decisionSucceeded = true;
                for (int j = 0; j < transitions[i].decision.Length; j++)
                {
                    decisionSucceeded = decisionSucceeded && transitions[i].decision[j].Decide(controller);
                }

                if (decisionSucceeded)
                {
                    controller.TransitionToState(transitions[i].trueState);
                }
                else
                {
                    controller.TransitionToState(transitions[i].falseState);
                }
            }
        }
Пример #4
0
        //public virtual void Execute(NpcStateController controller) { }

        public virtual void Execute(EnemiesAIStateController controller)
        {
        }
Пример #5
0
        //public void UpdateState(NpcStateController controller)
        //{
        //    DoActions(controller);
        //    CheckTransitions(controller);
        //}

        public void UpdateState(EnemiesAIStateController controller)
        {
            DoActions(controller);
            CheckTransitions(controller);
        }
Пример #6
0
        //public virtual bool Decide(NpcStateController controller) { return true; }

        public virtual bool Decide(EnemiesAIStateController controller)
        {
            return(true);
        }