示例#1
0
    void CheckDistance()
    {
        bool inDistance = false;

        var dist = Vector3.Distance(Player.position, transform.position);

        inDistance = (dist < 51f);

        switch (inDistance)
        {
        case true:
            //look first
            m_AgressiveState = AgressiveState.LOOK;
            m_PassiveState   = PassiveState.LOOK;

            //then do direction stuff
            if (dist < 30)
            {
                Vector3 dir = Player.transform.position - transform.position;
                isVisable = DetectPlayer(dir);
            }
            break;

        case false:
            m_AgressiveState = AgressiveState.IDLE;
            m_PassiveState   = PassiveState.WANDER;
            isVisable        = false;
            break;
        }
    }
示例#2
0
 void MoveToPlayer(bool det)
 {
     if (det)
     {
         m_AgressiveState = AgressiveState.ATTACK;
         m_PassiveState   = PassiveState.INTERACT;
     }
 }
示例#3
0
    void Awake()
    {
        chaseState   = new ChaseState(this);
        alertState   = new AlertState(this);
        roamState    = new RoamState(this);
        neutralState = new NeutralState(this);
        passiveState = new PassiveState(this);

        m_Nav = GetComponent <NavMeshAgent>();
    }
示例#4
0
    protected override void BuildFSM()
    {
        PassiveState passive = new PassiveState(activateRaidus);

        passive.AddTransitionState(FSMStateID.Chase, FSMTransitions.Awoken);
        passive.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth);

        IdleState idle = new IdleState();

        idle.AddTransitionState(FSMStateID.Chase, FSMTransitions.SawPlayer);
        idle.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth);

        ChaseState chase = new ChaseState(navAgent, agroDistance);

        chase.AddTransitionState(FSMStateID.Idle, FSMTransitions.PlayerOutOfRange);
        chase.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth);

        DeadState dead = new DeadState();

        AddFSMState(passive);
        AddFSMState(idle);
        AddFSMState(chase);
        AddFSMState(dead);
    }