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); }
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); }
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); }
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); }
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); }
public override bool ExternalCondition(BehaviorInputData Input) { if (!CombatHelper.InAttackRange(Input.Attacker, Input.Attacker.Action.TargetNpc)) { return(true); } return(false); }
protected override void OnTransition(BehaviorInputData Input) { if (IsValidIndex(CurrentSelectIndex_)) { Children_[CurrentSelectIndex_].Transition(Input); } CurrentSelectIndex_ = InvalidIndex; }
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; }
protected override BehaviorRunningState OnExecute(BehaviorInputData Input) { if (Input.Attacker.Actor.IsFsmState(FsmStateName.Skill)) { return(BehaviorRunningState.Running); } return(BehaviorRunningState.Finish); }
protected override void OnTransition(BehaviorInputData Input) { if (IsValidIndex(0)) { Children_[0].Transition(Input); } CurrentCount_ = 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); } } }
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); }
protected override void OnTransition(BehaviorInputData Input) { if (NeedExit_) { OnExit(Input, BehaviorRunningState.Error); } SetActiveNode(null); TerminalState_ = BehaviorTerminalState.Ready; NeedExit_ = false; }
protected override bool OnEvaluate(BehaviorInputData Input) { if (IsValidIndex(CurrentSelectIndex_)) { if (Children_[CurrentSelectIndex_].Evaluate(Input)) { return(true); } } return(base.OnEvaluate(Input)); }
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); } }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
protected virtual BehaviorRunningState OnTick(BehaviorInputData Input) { return(BehaviorRunningState.Finish); }
public void Transition(BehaviorInputData Input) { OnTransition(Input); }
public BehaviorRunningState Tick(BehaviorInputData Input) { return(OnTick(Input)); }
public override bool ExternalCondition(BehaviorInputData Input) { return(true); }
public override bool ExternalCondition(BehaviorInputData Input) { return(Left_.ExternalCondition(Input) ^ Right_.ExternalCondition(Input)); }
public abstract bool ExternalCondition(BehaviorInputData Input);
protected virtual bool OnEvaluate(BehaviorInputData Input) { return(true); }
protected virtual void OnTransition(BehaviorInputData Input) { }