void Update() { currentBloodInt -= LowerBloodLossBasedOnRemaining(BloodLossPerSecond) * Time.deltaTime; canvas.UpdateBloodSlider(currentBloodInt); if (!hasRunOutOfBloodThisLoad && CurrentBlood < 1e-4) { hasRunOutOfBloodThisLoad = true; playerMovement.canMove = false; playerPistol.canFire = false; playerMelee.canAttack = false; playerAbilities.canUseAbilites = false; canvas.PlayerHasNoBlood(); } // Speech sending if (state == BloodState.High && CurrentBlood < LowTransition) { var message = new SwordMessage { Message = "I need blood", Duration = 2f }; GameObject.FindWithTag("SwordSpeech").SendMessage("OnSwordMessage", message); state = BloodState.Low; } else if (state == BloodState.Low && CurrentBlood < VeryLowTransition) { var message = new SwordMessage { Message = "I need blood now!", Duration = 2f }; GameObject.FindWithTag("SwordSpeech").SendMessage("OnSwordMessage", message); state = BloodState.VeryLow; } else if (state == BloodState.Low && CurrentBlood > LowTransition) { state = BloodState.High; } else if (state == BloodState.VeryLow && CurrentBlood > VeryLowTransition) { state = BloodState.Low; } }
private void OnSwordMessage(SwordMessage message) { speech.SetActive(true); text.text = message.Message; durationTracker = message.Duration; }