コード例 #1
0
ファイル: AIBaseFunction.cs プロジェクト: wuhuolong/MaxBooks
    public BehaviourReturnCode ActionTestRun()
    {
        // 追逐算法
        Vector3 toEvader = RunningProperty.TargetActorPos - RunningProperty.SelfActorPos;

        float   time      = toEvader.magnitude / (RunningProperty.TargetActor.MoveSpeed + RunningProperty.SelfActor.MoveSpeed);
        Vector3 targetPos = RunningProperty.SelfActorPos + RunningProperty.TargetActor.MoveDir * time;

        RunningProperty.AI.Machine.SwitchToState(BehaviourMachine.State.RUN);

        BehaviourRunFiniteState state = RunningProperty.AI.Machine.GetCurrentState <BehaviourRunFiniteState>();

        state.LastTargetPos = targetPos;

        //RunningProperty.SelfActor.MoveCtrl.TryRunTo(targetPos);
        return(BehaviourReturnCode.Success);
    }
コード例 #2
0
    public BehaviourMachine(BehaviourAI ai)
    {
        mAI = ai;

        mStandState       = new BehaviourStandFiniteState(ai.RunningProperty);
        mWalkState        = new BehaviourWalkFiniteState(ai.RunningProperty);
        mAttackState      = new BehaviourAttackFiniteState(ai.RunningProperty);
        mRunState         = new BehaviourRunFiniteState(ai.RunningProperty);
        mChaseTargetState = new BehaviourChaseTargetFiniteState(ai.RunningProperty);
        mPatrolState      = new BehaviourPatrolFiniteState(ai.RunningProperty);
        mFollowState      = new BehaviourFollowFiniteState(ai.RunningProperty);
        mEmptyState       = new BehaviourEmptyFiniteState(ai.RunningProperty);
        mEscapeState      = new BehaviourEscapeFiniteState(ai.RunningProperty);

        mMachine.AddState(State.WALK, mWalkState);
        mMachine.AddState(State.RUN, mRunState);
        mMachine.AddState(State.STAND, mStandState);
        mMachine.AddState(State.ATTACK, mAttackState);
        mMachine.AddState(State.CHASETARGET, mChaseTargetState);
        mMachine.AddState(State.PATROL, mPatrolState);
        mMachine.AddState(State.FOLLOW, mFollowState);
        mMachine.AddState(State.EMPTY, mEmptyState);
        mMachine.AddState(State.ESCAPE, mEscapeState);
    }