void GenerateTraits() { int _random = System.Enum.GetValues(typeof(E_Trait)).Length; firstTrait = (E_Trait)Random.Range(0, _random); secondTrait = (E_Trait)Random.Range(0, _random); while (firstTrait == secondTrait) { secondTrait = (E_Trait)Random.Range(0, _random); } }
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; } } }