public void KillCharacter(SO_Character character) { Debug.Log("Killed " + character.characterName); for (int i = 0; i < characterUI.Length; i++) { if (character == characterUI[i].thisCharacter) { selectedCharacters[i].isDead = true; switch (i) { case 0: StartCoroutine(DeathLerp(character1Sprite, 1f)); break; case 1: StartCoroutine(DeathLerp(character2Sprite, 1f)); break; case 2: StartCoroutine(DeathLerp(character3Sprite, 1f)); break; default: break; } } } }
void HandleStaminaUI(SO_Character character, int stamina) { int charIndex = 0; Mathf.Clamp(stamina, 0, 2); for (int i = 0; i < characterUI.Length; i++) { if (character == characterUI[i].thisCharacter) { charIndex = i; } } switch (stamina) { case 0: characterUI[charIndex].stamina[0].sprite = emptyStaminaSprite; characterUI[charIndex].stamina[1].sprite = emptyStaminaSprite; break; case 1: characterUI[charIndex].stamina[0].sprite = fullStaminaSprite; characterUI[charIndex].stamina[1].sprite = emptyStaminaSprite; break; case 2: characterUI[charIndex].stamina[0].sprite = fullStaminaSprite; characterUI[charIndex].stamina[1].sprite = fullStaminaSprite; break; default: break; } }
void RegenerateStamina(SO_Character _char) { int _chance = UnityEngine.Random.Range(0, 100); if (_chance > 40) { characterManager.AdjustStamina(_char, +1); } }
public void AdjustHealth(SO_Character _char, int adjust) { if (_char.isDead) { return; } _char.health += adjust; _char.health = Mathf.Clamp(_char.health, 0, 3); if (adjust < 0) { CameraShake.instance.ShakeCamera(.5f, .5f); audioManager.Play(E_SFX.Injury); for (int i = 0; i < characterUI.Length; i++) { if (_char == characterUI[i].thisCharacter) { if (_char.health > 0) { switch (i) { case 0: StartCoroutine(InjuryLerp(character1Sprite, 1f)); break; case 1: StartCoroutine(InjuryLerp(character2Sprite, 1f)); break; case 2: StartCoroutine(InjuryLerp(character3Sprite, 1f)); break; default: break; } } else { KillCharacter(_char); } } } } HandleHealthUI(_char, _char.health); }
public void AdjustStamina(SO_Character _char, int adjust) { if (_char.isDead) { return; } if (_char.stamina == 0 && adjust < 0) { AdjustHealth(_char, -1); } _char.stamina += adjust; _char.stamina = Mathf.Clamp(_char.stamina, 0, 2); HandleStaminaUI(_char, _char.stamina); }
void HandleHealthUI(SO_Character character, int health) { int charIndex = 0; Mathf.Clamp(health, 0, 3); for (int i = 0; i < characterUI.Length; i++) { if (character == characterUI[i].thisCharacter) { charIndex = i; } } switch (health) { case 0: characterUI[charIndex].health[0].sprite = emptyHealthSprite; characterUI[charIndex].health[1].sprite = emptyHealthSprite; characterUI[charIndex].health[2].sprite = emptyHealthSprite; break; case 1: characterUI[charIndex].health[0].sprite = fullHealthSprite; characterUI[charIndex].health[1].sprite = emptyHealthSprite; characterUI[charIndex].health[2].sprite = emptyHealthSprite; break; case 2: characterUI[charIndex].health[0].sprite = fullHealthSprite; characterUI[charIndex].health[1].sprite = fullHealthSprite; characterUI[charIndex].health[2].sprite = emptyHealthSprite; break; case 3: characterUI[charIndex].health[0].sprite = fullHealthSprite; characterUI[charIndex].health[1].sprite = fullHealthSprite; characterUI[charIndex].health[2].sprite = fullHealthSprite; break; default: break; } }
public void TraitSelected(E_Trait trait, SO_Character character) { if (canUseTrait) { StopAllCoroutines(); canUseTrait = false; scenarioTextBox.text = ""; for (int i = 0; i < characterManager.selectedCharacters.Count; i++) { if (character != characterManager.selectedCharacters[i]) { RegenerateStamina(characterManager.selectedCharacters[i]); } } if (trait == scenarioQueue.Peek().traitToPass) { passType = E_PassType.TraitPass; } else if (trait == scenarioQueue.Peek().secondaryTraits[0]) { if (UnityEngine.Random.value > secondaryTraitSuccessPercent) { passType = E_PassType.Secondary1Pass; } else { passType = E_PassType.Fail; } } else if (trait == scenarioQueue.Peek().secondaryTraits[1]) { if (UnityEngine.Random.value > secondaryTraitSuccessPercent) { passType = E_PassType.Secondary2Pass; } else { passType = E_PassType.Fail; } } else if (trait == E_Trait.Lucky) { if (UnityEngine.Random.value > 0.5f) { passType = E_PassType.LuckyPass; } else { passType = E_PassType.Fail; } } else { passType = E_PassType.Fail; } switch (passType) { case E_PassType.TraitPass: characterManager.AdjustStamina(character, -1); //UI changes to stamina bar should be done here AudioManager.instance.Play(E_SFX.Success); if (character.health == 0) { StartCoroutine(TextTyper(string.Format(currentScenario.passTraitText + "\nUnfortuantely, {0} is exhausted from the effort and collapses. They won't be able to continue.", character.characterName), true)); } else { StartCoroutine(TextTyper(string.Format(currentScenario.passTraitText, character.characterName), true)); } break; case E_PassType.Secondary1Pass: characterManager.AdjustStamina(character, -1); //UI changes to stamina bar should be done here AudioManager.instance.Play(E_SFX.Success); if (character.health == 0) { StartCoroutine(TextTyper(string.Format(currentScenario.secondary1PassText + "\nUnfortuantely, {0} is exhausted from the effort and collapses. They won't be able to continue.", character.characterName), true)); } else { StartCoroutine(TextTyper(string.Format(currentScenario.secondary1PassText, character.characterName), true)); } //SetContinueButton(true); break; case E_PassType.Secondary2Pass: characterManager.AdjustStamina(character, -1); //UI changes to stamina bar should be done here AudioManager.instance.Play(E_SFX.Success); if (character.health == 0) { StartCoroutine(TextTyper(string.Format(currentScenario.secondary2PassText + "\nUnfortuantely, {0} is exhausted from the effort and collapses. They won't be able to continue.", character.characterName), true)); } else { StartCoroutine(TextTyper(string.Format(currentScenario.secondary2PassText, character.characterName), true)); } break; case E_PassType.LuckyPass: characterManager.AdjustStamina(character, -1); //UI changes to stamina bar should be done here AudioManager.instance.Play(E_SFX.Success); if (character.health == 0) { StartCoroutine(TextTyper(string.Format(currentScenario.luckyPassText + "\nUnfortuantely, {0} is exhausted from the effort and collapses. They won't be able to continue.", character.characterName), true)); } else { StartCoroutine(TextTyper(string.Format(currentScenario.luckyPassText, character.characterName), true)); } // SetContinueButton(true); break; case E_PassType.Fail: //Types too early, needs to adjust health and then sort appropriate respooinse. // character.isDead is implemented now, that would work great. // Could swap int of dead characters for a loop that checks for not dead before game over? // Love you characterManager.AdjustStamina(character, -1); characterManager.AdjustHealth(character, -1); if (character.health > 0) { StartCoroutine(TextTyper(string.Format(currentScenario.failText, character.characterName), true)); AudioManager.instance.Play(E_SFX.Injury); } else { if (character.health == 0) { partyMembersDown++; AudioManager.instance.Play(E_SFX.Death); //TODO : Kill Character here - Sprite Remove, Etc. if (partyMembersDown < 3) { StartCoroutine(TextTyper(string.Format(currentScenario.characterCriticalFail, character.characterName), true)); // SetContinueButton(true); characterManager.KillCharacter(character); } else { StartCoroutine(TextTyper(string.Format(currentScenario.partyCriticalFail, character.name), true)); // SetContinueButton(true); //Errrr game over stuff then I guess? finalSceneScript.DoFinalScene(characterManager.selectedCharacters.ToArray(), false); } } else { AudioManager.instance.Play(E_SFX.Injury); } //SetContinueButton(true); } break; } } }