void Update() { if (!data.StaminaIsEmpty() && data.IsConsuming()) { staminaConsumer.TryToConsume(1); } else if (!data.CurrentStaminaIsFull()) { staminaRecoverer.TryToRecover(1); } }
public IEnumerator StaminaDoesNotRecovererIfStaminaIsFull() { GameObject gameObject = new GameObject(); StaminaData staminaData = ScriptableObject.CreateInstance <StaminaData>(); staminaData.maxStamina = 20; staminaData.currentStamina = 20; Stamina.StaminaRecoverer staminaRecoverer = gameObject.AddComponent <Stamina.StaminaRecoverer>(); staminaRecoverer.Initialize(staminaData); int initStamina = staminaData.currentStamina; staminaRecoverer.TryToRecover(5); yield return(null); Assert.AreEqual(staminaData.currentStamina, initStamina); Object.DestroyImmediate(gameObject); staminaData = null; }