public void Start() { myStaminaState = gameObject.GetComponent <StaminaState> (); GameplayState.CurrentState = GameplayState.StateType.PLAYING; GameplayState.TotalEnemies = GameObject.FindGameObjectsWithTag("Enemy").Length; GameplayState.TotalHostages = GameObject.FindGameObjectsWithTag("Hostage").Length; }
private void OnTimedEvent(object source, ElapsedEventArgs e) { if (!enabled) { return; } ShiftHistoryArrayRight(); staminaHistory[0] = new StaminaState(Environment.TickCount, currentStamina, maxStamina); PlayVibraion(); }
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; } }