Exemplo n.º 1
0
        protected override BehaviorRunningState OnTick(BehaviorInputData Input)
        {
            var State = BehaviorRunningState.Finish;

            if (IsValidIndex(CurrentSelectIndex_))
            {
                if (PreviousSelectIndex_ != CurrentSelectIndex_)
                {
                    if (IsValidIndex(PreviousSelectIndex_))
                    {
                        Children_[PreviousSelectIndex_].Transition(Input);
                    }

                    PreviousSelectIndex_ = CurrentSelectIndex_;
                }
            }

            if (IsValidIndex(PreviousSelectIndex_))
            {
                State = Children_[PreviousSelectIndex_].Tick(Input);

                if (State == BehaviorRunningState.Finish)
                {
                    PreviousSelectIndex_ = InvalidIndex;
                }
            }

            return(State);
        }
Exemplo n.º 2
0
        protected override BehaviorRunningState OnTick(BehaviorInputData Input)
        {
            var State = BehaviorRunningState.Finish;

            if (IsValidIndex(0))
            {
                State = Children_[0].Tick(Input);

                if (State == BehaviorRunningState.Finish)
                {
                    if (LoopCount_ != -1)
                    {
                        CurrentCount_++;
                        if (CurrentCount_ == LoopCount_)
                        {
                            State = BehaviorRunningState.Finish;
                        }
                    }
                    else
                    {
                        State = BehaviorRunningState.Running;
                    }
                }
            }

            if (State == BehaviorRunningState.Finish)
            {
                CurrentCount_ = 0;
            }

            return(State);
        }
Exemplo n.º 3
0
        protected override BehaviorRunningState OnTick(BehaviorInputData Input)
        {
            var State = BehaviorRunningState.Finish;

            if (CurrentSelectIndex_ == InvalidIndex)
            {
                CurrentSelectIndex_ = 0;
            }

            State = Children_[CurrentSelectIndex_].Tick(Input);

            if (State == BehaviorRunningState.Finish)
            {
                CurrentSelectIndex_++;

                if (CurrentSelectIndex_ == ChildCount_)
                {
                    CurrentSelectIndex_ = InvalidIndex;
                }
                else
                {
                    State = BehaviorRunningState.Running;
                }
            }

            if (State == BehaviorRunningState.Error)
            {
                CurrentSelectIndex_ = InvalidIndex;
            }

            return(State);
        }
Exemplo n.º 4
0
        public override bool ExternalCondition(BehaviorInputData Input)
        {
            if (!Input.Attacker.Skill.CanUseSkill())
            {
                return(false);
            }

            var NextSkill = Input.Attacker.Skill.GetSkill(Input.SkillID);

            if (NextSkill != null && NextSkill.CanUse())
            {
                return(true);
            }

            var SkillList = Input.Attacker.Skill.GetSkillList();

            foreach (var Skill in SkillList)
            {
                if (Skill.Type != SkillType.Passive && Skill.CanUse())
                {
                    NextSkill = Skill;
                    break;
                }
            }

            if (NextSkill == null)
            {
                return(false);
            }

            Input.SkillID = NextSkill.SkillID;
            //Input.Distance = NextSkill.Radius;
            return(true);
        }
Exemplo n.º 5
0
        protected override void OnEnter(BehaviorInputData Input)
        {
            var Args = Input.Attacker.Skill.CreateSkillArgs(Input.SkillID);

            Args.Position  = Input.Attacker.Action.TargetNpc.Position;
            Args.Direction = (Input.Attacker.Action.TargetNpc.Position - Input.Attacker.Position).normalized;
            Input.Attacker.Skill.UseSkill(Args);
        }
Exemplo n.º 6
0
        public override bool ExternalCondition(BehaviorInputData Input)
        {
            if (!CombatHelper.InAttackRange(Input.Attacker, Input.Attacker.Action.TargetNpc))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 7
0
        protected override void OnTransition(BehaviorInputData Input)
        {
            if (IsValidIndex(CurrentSelectIndex_))
            {
                Children_[CurrentSelectIndex_].Transition(Input);
            }

            CurrentSelectIndex_ = InvalidIndex;
        }
Exemplo n.º 8
0
 public AINpc(string Name, Transform Trans, CombatTeam Team, float[] InitAttr)
     : base(Name, Trans, Team, InitAttr)
 {
     AIData_          = new BehaviorInputData();
     AIData_.Enabled  = true;
     AIData_.Attacker = this;
     AIData_.Node     = AIFactory.CreateNormalAI();
     AIData_.SkillID  = 0;
 }
Exemplo n.º 9
0
        protected override BehaviorRunningState OnExecute(BehaviorInputData Input)
        {
            if (Input.Attacker.Actor.IsFsmState(FsmStateName.Skill))
            {
                return(BehaviorRunningState.Running);
            }

            return(BehaviorRunningState.Finish);
        }
Exemplo n.º 10
0
        protected override void OnTransition(BehaviorInputData Input)
        {
            if (IsValidIndex(0))
            {
                Children_[0].Transition(Input);
            }

            CurrentCount_ = 0;
        }
Exemplo n.º 11
0
 protected override void OnEnter(BehaviorInputData Input)
 {
     if (!Input.Attacker.Actor.IsFsmState(FsmStateName.Walk))
     {
         if (Input.Attacker.Action.IsValidTarget())
         {
             Input.Attacker.Action.MoveTo(Input.Attacker.Action.TargetNpc.Position);
         }
     }
 }
Exemplo n.º 12
0
        public override bool ExternalCondition(BehaviorInputData Input)
        {
            if (Input.Attacker.Action.IsValidTarget())
            {
                return(true);
            }

            Input.Attacker.Action.SetTarget(FilterHelper.FindNearest(Input.Attacker));
            return(Input.Attacker.Action.TargetNpc != null);
        }
Exemplo n.º 13
0
        protected override void OnTransition(BehaviorInputData Input)
        {
            if (NeedExit_)
            {
                OnExit(Input, BehaviorRunningState.Error);
            }

            SetActiveNode(null);
            TerminalState_ = BehaviorTerminalState.Ready;
            NeedExit_      = false;
        }
Exemplo n.º 14
0
        protected override bool OnEvaluate(BehaviorInputData Input)
        {
            if (IsValidIndex(CurrentSelectIndex_))
            {
                if (Children_[CurrentSelectIndex_].Evaluate(Input))
                {
                    return(true);
                }
            }

            return(base.OnEvaluate(Input));
        }
Exemplo n.º 15
0
        protected override void OnTransition(BehaviorInputData Input)
        {
            for (var Index = 0; Index < MaxChildCount; ++Index)
            {
                ChildrenState_[Index] = BehaviorRunningState.Running;
            }

            for (var Index = 0; Index < ChildCount_; ++Index)
            {
                Children_[Index].Transition(Input);
            }
        }
Exemplo n.º 16
0
        protected override BehaviorRunningState OnExecute(BehaviorInputData Input)
        {
            if (Input.Attacker.Actor.IsFsmState(FsmStateName.Walk) && Input.Attacker.Action.IsValidTarget())
            {
                if (!CombatHelper.InAttackRange(Input.Attacker, Input.Attacker.Action.TargetNpc))
                {
                    Input.Attacker.Action.MoveTo(Input.Attacker.Action.TargetNpc.Position);
                }

                return(BehaviorRunningState.Running);
            }

            return(BehaviorRunningState.Finish);
        }
Exemplo n.º 17
0
        protected override bool OnEvaluate(BehaviorInputData Input)
        {
            CurrentSelectIndex_ = 0;

            for (var Index = 0; Index < ChildCount_; ++Index)
            {
                if (Children_[Index].Evaluate(Input))
                {
                    CurrentSelectIndex_ = Index;
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 18
0
        protected override bool OnEvaluate(BehaviorInputData Input)
        {
            for (var Index = 0; Index < ChildCount_; ++Index)
            {
                if (ChildrenState_[Index] == BehaviorRunningState.Running)
                {
                    if (!Children_[Index].Evaluate(Input))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Exemplo n.º 19
0
        protected override BehaviorRunningState OnTick(BehaviorInputData Input)
        {
            var FinishedCount = 0;

            for (var Index = 0; Index < ChildCount_; ++Index)
            {
                if (Mode_ == BehaviorParallelMode.Or)
                {
                    if (ChildrenState_[Index] == BehaviorRunningState.Running)
                    {
                        ChildrenState_[Index] = Children_[Index].Tick(Input);
                    }

                    if (ChildrenState_[Index] != BehaviorRunningState.Running)
                    {
                        FinishedCount = ChildCount_;
                        break;
                    }
                }
                else if (Mode_ == BehaviorParallelMode.And)
                {
                    if (ChildrenState_[Index] == BehaviorRunningState.Running)
                    {
                        ChildrenState_[Index] = Children_[Index].Tick(Input);
                    }

                    if (ChildrenState_[Index] != BehaviorRunningState.Running)
                    {
                        FinishedCount++;
                    }
                }
            }

            if (FinishedCount == ChildCount_)
            {
                for (var Index = 0; Index < MaxChildCount; ++Index)
                {
                    ChildrenState_[Index] = BehaviorRunningState.Running;
                }

                return(BehaviorRunningState.Finish);
            }

            return(BehaviorRunningState.Running);
        }
Exemplo n.º 20
0
        protected override bool OnEvaluate(BehaviorInputData Input)
        {
            var IsLoop = (LoopCount_ == -1) || CurrentCount_ < LoopCount_;

            if (!IsLoop)
            {
                return(false);
            }

            if (IsValidIndex(0))
            {
                if (Children_[0].Evaluate(Input))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 21
0
        protected override bool OnEvaluate(BehaviorInputData Input)
        {
            var Index = 0;

            if (CurrentSelectIndex_ != InvalidIndex)
            {
                Index = CurrentSelectIndex_;
            }

            if (IsValidIndex(Index))
            {
                if (Children_[Index].Evaluate(Input))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 22
0
        protected override BehaviorRunningState OnTick(BehaviorInputData Input)
        {
            var State = BehaviorRunningState.Finish;

            if (TerminalState_ == BehaviorTerminalState.Ready)
            {
                OnEnter(Input);
                NeedExit_      = true;
                TerminalState_ = BehaviorTerminalState.Running;
                SetActiveNode(this);
            }

            if (TerminalState_ == BehaviorTerminalState.Running)
            {
                State = OnExecute(Input);
                SetActiveNode(this);

                if (State == BehaviorRunningState.Finish || State == BehaviorRunningState.Error)
                {
                    TerminalState_ = BehaviorTerminalState.Finish;
                }
            }

            if (TerminalState_ == BehaviorTerminalState.Finish)
            {
                if (NeedExit_)
                {
                    OnExit(Input, State);
                }

                TerminalState_ = BehaviorTerminalState.Ready;
                NeedExit_      = false;
                SetActiveNode(null);
            }

            return(State);
        }
Exemplo n.º 23
0
 protected virtual BehaviorRunningState OnTick(BehaviorInputData Input)
 {
     return(BehaviorRunningState.Finish);
 }
Exemplo n.º 24
0
 public void Transition(BehaviorInputData Input)
 {
     OnTransition(Input);
 }
Exemplo n.º 25
0
 public BehaviorRunningState Tick(BehaviorInputData Input)
 {
     return(OnTick(Input));
 }
Exemplo n.º 26
0
 public override bool ExternalCondition(BehaviorInputData Input)
 {
     return(true);
 }
Exemplo n.º 27
0
 public override bool ExternalCondition(BehaviorInputData Input)
 {
     return(Left_.ExternalCondition(Input) ^ Right_.ExternalCondition(Input));
 }
Exemplo n.º 28
0
 public abstract bool ExternalCondition(BehaviorInputData Input);
Exemplo n.º 29
0
 protected virtual bool OnEvaluate(BehaviorInputData Input)
 {
     return(true);
 }
Exemplo n.º 30
0
 protected virtual void OnTransition(BehaviorInputData Input)
 {
 }