Exemplo n.º 1
0
    public void AddState(FSMState s)
    {
        if (s == null)
        {
            return;
        }

        if (m_states.Count == 0)
        {
            m_states.Add(s);
            m_currentState = s;
            m_currentState.DoBeforeEnter(m_Data);
            m_currentStateID = s.m_StateID;
            return;
        }

        foreach (FSMState state in m_states)
        {
            if (state.m_StateID == s.m_StateID)
            {
                return;
            }
        }
        m_states.Add(s);
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (m_bDead == false)
        {
            Timer += Time.deltaTime;

            if (Timer > 2.0f)
            {
                MobInfo.AIFunction.SearchPlayer(m_AIData);
                Timer = 0.0f;
                return;
            }
            if (m_AIData.m_Player == null || m_AIData.m_Player.IsDead)
            {
                MobInfo.AIFunction.SearchPlayer(m_AIData);
            }
            if (MobInfo.AIFunction.CheckAllPlayersLife() == false)
            {
                if (m_CurrentState != eFSMStateID.WanderIdleStateID && m_CurrentState != eFSMStateID.WanderStateID)
                {
                    m_FSM.PerformGlobalTransition(eFSMTransition.Go_WanderIdle);
                }
            }
        }

        m_FSM.DoState();

        m_CurrentState = m_AIData.m_FSMSystem.CurrentStateID;
        if (Input.GetKeyDown(KeyCode.U))
        {
            Death();
        }
    }
Exemplo n.º 3
0
 public void PerformGlobalTransition(eFSMTransition t)
 {
     if (m_GlobalMap.ContainsKey(t))
     {
         m_currentState.DoBeforeLeave(m_Data);
         m_currentState = m_GlobalMap[t];
         m_currentState.DoBeforeEnter(m_Data);
         m_currentStateID = m_currentState.m_StateID;
     }
 }
Exemplo n.º 4
0
    private void UpdateAnimator(eFSMStateID state, bool Bool)
    {
        switch (state)
        {
        case eFSMStateID.ChaseStateID:
            m_Animator.SetBool("Move", Bool);
            break;

        case eFSMStateID.ChaseToMeleeAttackStateID:
            m_Animator.SetBool("Move", Bool);
            break;

        case eFSMStateID.ChaseToRemoteAttackStateID:
            m_Animator.SetBool("Move2", Bool);
            break;

        case eFSMStateID.IdleStateID:
            m_Animator.SetBool("Idle", Bool);
            break;

        case eFSMStateID.TankIdleStateID:
            m_Animator.SetBool("Idle", Bool);
            break;

        case eFSMStateID.WanderStateID:
            m_Animator.SetBool("Wander", Bool);
            break;

        case eFSMStateID.WanderIdleStateID:
            m_Animator.SetBool("WanderIdle", Bool);
            break;

        case eFSMStateID.NoPlayerWanderStateID:
            m_Animator.SetBool("NoPlayerWander", Bool);
            break;

        case eFSMStateID.NoPlayerWanderIdleStateID:
            m_Animator.SetBool("NoPlayerWanderIdle", Bool);
            break;

        case eFSMStateID.FleeStateID:
            m_Animator.SetBool("Flee", Bool);
            break;

        case eFSMStateID.DodgeStateID:
            m_Animator.SetBool("Move", Bool);
            break;
        }
    }
Exemplo n.º 5
0
    public void DeleteState(eFSMStateID id)
    {
        if (id == eFSMStateID.NullStateID)
        {
            return;
        }

        foreach (FSMState state in m_states)
        {
            if (state.m_StateID == id)
            {
                m_states.Remove(state);
                return;
            }
        }
    }
Exemplo n.º 6
0
    private void UpdateAnimator(eFSMStateID state)
    {
        switch (state)
        {
        case eFSMStateID.WanderIdleStateID:
            m_Animator.SetTrigger("WanderIdle");
            break;

        case eFSMStateID.AttackStateID:
            m_Animator.SetTrigger("Attack");
            break;

        case eFSMStateID.RemoteAttackStateID:
            m_Animator.SetTrigger("Attack2");
            break;

        case eFSMStateID.PatrolAttackStateID:
            m_Animator.SetTrigger("Attack");
            break;

        case eFSMStateID.CallArmyStateID:
            m_Animator.SetTrigger("CallArmy");
            break;

        case eFSMStateID.FishGetHurtStateID:
            m_Animator.SetTrigger("GetHurt");
            break;

        case eFSMStateID.PatrolGetHurtStateID:
            m_Animator.SetTrigger("GetHurt");
            break;

        case eFSMStateID.TankGetHurtStateID:
            m_Animator.SetTrigger("GetHurt");
            break;

        case eFSMStateID.DeadStateID:
            m_Animator.SetTrigger("Dead");
            break;
        }
    }
Exemplo n.º 7
0
    public void PerformTransition(eFSMTransition trans)
    {
        if (trans == eFSMTransition.NullTransition)
        {
            return;
        }

        FSMState state = m_currentState.TransitionTo(trans);

        if (state == null)
        {
            return;
        }

        // Update the currentStateID and currentState
        m_currentState.DoBeforeLeave(m_Data);

        m_currentState   = state;
        m_currentStateID = state.m_StateID;
        m_currentState.DoBeforeEnter(m_Data);
    }
Exemplo n.º 8
0
    // Update is called once per frame
    void Update()
    {
        if (m_bDead == false)
        {
            MobInfo.AIFunction.SearchPlayer(m_AIData);
            m_CurrentState = m_AIData.m_FSMSystem.CurrentStateID;

            if (m_AIData.m_Player == null || m_AIData.m_Player.IsDead)
            {
                MobInfo.AIFunction.SearchPlayer(m_AIData);
            }
            if (m_CurrentState != eFSMStateID.WanderIdleStateID && m_CurrentState != eFSMStateID.WanderStateID)
            {
                if (m_CurrentState != eFSMStateID.NoPlayerWanderIdleStateID && m_CurrentState != eFSMStateID.NoPlayerWanderStateID)
                {
                    if (MobInfo.AIFunction.CheckAllPlayersLife() == false)
                    {
                        m_FSM.PerformGlobalTransition(eFSMTransition.Go_NoPlayerWanderIdle);
                    }
                }
            }
        }


        if (m_bGoIdle)
        {
            m_WanderIdleState.ToIdle(m_AIData);
            m_bGoIdle = false;
        }
        else
        {
            m_FSM.DoState();
        }

        if (Input.GetKeyDown(KeyCode.U))
        {
            Death();
        }
    }
Exemplo n.º 9
0
 public FSMState()
 {
     m_StateID      = eFSMStateID.NullStateID;
     m_fCurrentTime = 0.0f;
     m_Map          = new Dictionary <eFSMTransition, FSMState>();
 }
Exemplo n.º 10
0
 public void SetAnimator(eFSMStateID state, bool Bool)
 {
     UpdateAnimator(state, Bool);
 }
Exemplo n.º 11
0
 public void SetAnimator(eFSMStateID state)
 {
     UpdateAnimator(state);
 }