示例#1
0
    public void Start()
    {
        myStaminaState = gameObject.GetComponent <StaminaState> ();

        GameplayState.CurrentState  = GameplayState.StateType.PLAYING;
        GameplayState.TotalEnemies  = GameObject.FindGameObjectsWithTag("Enemy").Length;
        GameplayState.TotalHostages = GameObject.FindGameObjectsWithTag("Hostage").Length;
    }
示例#2
0
 private void OnTimedEvent(object source, ElapsedEventArgs e)
 {
     if (!enabled)
     {
         return;
     }
     ShiftHistoryArrayRight();
     staminaHistory[0] = new StaminaState(Environment.TickCount, currentStamina, maxStamina);
     PlayVibraion();
 }
示例#3
0
        public StaminaEventHandler()
        {
            for (int i = 0; i < staminaHistory.Length; i++)
            {
                staminaHistory[i] = new StaminaState(Environment.TickCount, currentStamina, maxStamina);
            }


            timer          = new Timer();
            timer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            timer.Interval = 250;
            timer.Start();
        }
    public void UseStamina(float amount)
    {
        if (!isLocalPlayer)
            return;

        if(state == StaminaState.Recover) return;

        state = StaminaState.Use;
        Stamina -= amount;

        StopCoroutine ("SetTransition");
        StartCoroutine ("SetTransition");
    }
 void CmdSyncState(StaminaState st)
 {
     state = st;
 }
    IEnumerator StartRecover()
    {
        if (!isLocalPlayer)
            yield break;

        state = StaminaState.Recover;

        if (isClient)
            CmdSyncState (state);

        yield return new WaitForSeconds (1.0f);

        while (Stamina < 100)
        {
            Stamina += 0.25f;
            yield return new WaitForSeconds(0.01f);
        }

        state = StaminaState.Idle;

        if (isClient)
            CmdSyncState (state);

        yield return new WaitForSeconds (0.01f);
    }
    // Use this for initialization
    void Start()
    {
        Stamina = 100;
        hungerScript = this.gameObject.GetComponent<Player_Hunger>();
        state = StaminaState.Idle;
        transition = false;

        if (!isLocalPlayer)
            return;

        StartCoroutine ("IdleRecover");
    }
    IEnumerator SetTransition()
    {
        if (transition == false)
            transition = true;

        yield return new WaitForSeconds (1.0f);
        transition = false;

        if (state == StaminaState.Use) {
            state = StaminaState.Idle;
        }
    }