Example #1
0
    public void SetStateDurability(eBrainBaseState state, float durInSec)
    {
        switch (state)
        {
        case eBrainBaseState.hungry:
            m_hungerDurability = durInSec;
            break;

        case eBrainBaseState.thirsty:
            m_thirstDurability = durInSec;
            break;

        case eBrainBaseState.fatigued:
            m_fatigueDurability = durInSec;
            break;

        case eBrainBaseState.injured:
            m_injuryDurability = durInSec;
            break;

        case eBrainBaseState.stressed:
            m_stressDurability = durInSec;
            break;

        case eBrainBaseState.lonely:
            m_lonelinessDurability = durInSec;
            break;
        }
    }
Example #2
0
    public float GetState(eBrainBaseState state)
    {
        float result = 0f;

        switch (state)
        {
        case eBrainBaseState.hungry:
            result = m_hunger;
            break;

        case eBrainBaseState.thirsty:
            result = m_thirst;
            break;

        case eBrainBaseState.fatigued:
            result = m_fatigue;
            break;

        case eBrainBaseState.injured:
            result = m_injury;
            break;

        case eBrainBaseState.stressed:
            result = m_stress;
            break;

        case eBrainBaseState.lonely:
            result = m_loneliness;
            break;
        }
        return(result);
    }
Example #3
0
 protected eBrainBaseState UpdateState(float deltaTime)
 {
     if (!IsDead())
     {
         if (m_hungerDurability != 0f)
         {
             ChangeStateBy(eBrainBaseState.hungry, 1f / m_hungerDurability * deltaTime);
         }
         if (m_thirstDurability != 0f)
         {
             ChangeStateBy(eBrainBaseState.thirsty, 1f / m_thirstDurability * deltaTime);
         }
         if (m_fatigueDurability != 0f)
         {
             ChangeStateBy(eBrainBaseState.fatigued, 1f / m_fatigueDurability * deltaTime);
         }
         if (m_lonelinessDurability != 0f)
         {
             ChangeStateBy(eBrainBaseState.lonely, 1f / m_lonelinessDurability * deltaTime);
         }
         if (m_stressDurability != 0f)
         {
             ChangeStateBy(eBrainBaseState.stressed, -1f / m_stressDurability * deltaTime);
         }
         if (m_injuryDurability != 0f)
         {
             ChangeStateBy(eBrainBaseState.injured, -1f / m_injuryDurability * deltaTime);
         }
         eBrainBaseState state = m_state;
         state = ((m_fatigue > m_stateTolerance) ? eBrainBaseState.fatigued : ((m_thirst > m_stateTolerance) ? eBrainBaseState.thirsty : ((m_hunger > m_stateTolerance) ? eBrainBaseState.hungry : ((m_injury > m_stateTolerance) ? eBrainBaseState.injured : ((m_stress > m_stateTolerance) ? eBrainBaseState.stressed : ((!(m_loneliness > m_stateTolerance)) ? eBrainBaseState.happy : eBrainBaseState.lonely))))));
         if (state != m_state)
         {
             if (Application.isEditor)
             {
                 Debug.Log(string.Concat(" BrainBase.cs (", base.gameObject.name, "): state has changed from ", m_state, " to ", state, " isDead: ", IsDead()));
             }
             m_state = state;
         }
         HandleState(deltaTime);
     }
     return(m_state);
 }
Example #4
0
    public float ChangeStateBy(eBrainBaseState state, float delta)
    {
        float result = -1f;

        switch (state)
        {
        case eBrainBaseState.hungry:
            m_hunger = Mathf.Clamp(m_hunger + delta, 0f, 1f);
            result   = m_hunger;
            break;

        case eBrainBaseState.thirsty:
            m_thirst = Mathf.Clamp(m_thirst + delta, 0f, 1f);
            result   = m_thirst;
            break;

        case eBrainBaseState.fatigued:
            m_fatigue = Mathf.Clamp(m_fatigue + delta, 0f, 1f);
            result    = m_fatigue;
            break;

        case eBrainBaseState.injured:
            m_injury = Mathf.Clamp(m_injury + delta, 0f, 1f);
            result   = m_injury;
            break;

        case eBrainBaseState.stressed:
            m_stress = Mathf.Clamp(m_stress + delta, 0f, 1f);
            result   = m_stress;
            break;

        case eBrainBaseState.lonely:
            m_loneliness = Mathf.Clamp(m_loneliness + delta, 0f, 1f);
            result       = m_loneliness;
            break;
        }
        return(result);
    }