Esempio n. 1
0
    void OnEnterState(CuboState newState)
    {
        switch (m_state)
        {
        case CuboState.IDLE:
            m_navAgent.SetDestination(transform.position);
            m_navAgent.isStopped = true;
            break;

        case CuboState.MOVING_TO_EMPTY:
            m_navAgent.SetDestination(m_moveTarget);
            m_navAgent.isStopped = false;
            break;

        case CuboState.MOVING_TO_WORK:
            m_navAgent.SetDestination(m_moveTarget);
            m_navAgent.isStopped = false;
            break;

        case CuboState.WORKING:
            m_orderableTarget.OccupyWorkTarget(m_workTarget);
            m_navAgent.Move(m_workTarget.pos - transform.position);
            m_navAgent.SetDestination(m_workTarget.pos);
            m_navAgent.isStopped = false;
            m_lastWorkTime       = Time.time + Random.Range(0f, 0.3f);
            break;

        default:
            throw new UnityException("Unrecognized cubo state: " + m_state);
        }
    }
Esempio n. 2
0
    void Start()
    {
        m_state = CuboState.IDLE;

        m_navAgent = GetComponent <NavMeshAgent>();

        SpawnAnim();
        Camera.main.GetComponent <AudioSource>().PlayOneShot(spawnNoise);
    }
Esempio n. 3
0
    void OnExitState(CuboState oldState, CuboState nextState)
    {
        switch (m_state)
        {
        case CuboState.IDLE:
            break;

        case CuboState.MOVING_TO_EMPTY:
            m_isUnmoving = false;
            break;

        case CuboState.MOVING_TO_WORK:
            break;

        case CuboState.WORKING:
            break;

        default:
            throw new UnityException("Unrecognized cubo state: " + m_state);
        }
    }
Esempio n. 4
0
 void SwitchState(CuboState newState)
 {
     OnExitState(m_state, newState);
     m_state = newState;
     OnEnterState(newState);
 }