예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #6
0
        public override bool ExternalCondition(BehaviorInputData Input)
        {
            if (!CombatHelper.InAttackRange(Input.Attacker, Input.Attacker.Action.TargetNpc))
            {
                return(true);
            }

            return(false);
        }
예제 #7
0
        protected override void OnTransition(BehaviorInputData Input)
        {
            if (IsValidIndex(CurrentSelectIndex_))
            {
                Children_[CurrentSelectIndex_].Transition(Input);
            }

            CurrentSelectIndex_ = InvalidIndex;
        }
예제 #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;
 }
예제 #9
0
        protected override BehaviorRunningState OnExecute(BehaviorInputData Input)
        {
            if (Input.Attacker.Actor.IsFsmState(FsmStateName.Skill))
            {
                return(BehaviorRunningState.Running);
            }

            return(BehaviorRunningState.Finish);
        }
예제 #10
0
        protected override void OnTransition(BehaviorInputData Input)
        {
            if (IsValidIndex(0))
            {
                Children_[0].Transition(Input);
            }

            CurrentCount_ = 0;
        }
예제 #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);
         }
     }
 }
예제 #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);
        }
예제 #13
0
        protected override void OnTransition(BehaviorInputData Input)
        {
            if (NeedExit_)
            {
                OnExit(Input, BehaviorRunningState.Error);
            }

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

            return(base.OnEvaluate(Input));
        }
예제 #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);
            }
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #23
0
 protected virtual BehaviorRunningState OnTick(BehaviorInputData Input)
 {
     return(BehaviorRunningState.Finish);
 }
예제 #24
0
 public void Transition(BehaviorInputData Input)
 {
     OnTransition(Input);
 }
예제 #25
0
 public BehaviorRunningState Tick(BehaviorInputData Input)
 {
     return(OnTick(Input));
 }
예제 #26
0
 public override bool ExternalCondition(BehaviorInputData Input)
 {
     return(true);
 }
예제 #27
0
 public override bool ExternalCondition(BehaviorInputData Input)
 {
     return(Left_.ExternalCondition(Input) ^ Right_.ExternalCondition(Input));
 }
예제 #28
0
 public abstract bool ExternalCondition(BehaviorInputData Input);
예제 #29
0
 protected virtual bool OnEvaluate(BehaviorInputData Input)
 {
     return(true);
 }
예제 #30
0
 protected virtual void OnTransition(BehaviorInputData Input)
 {
 }