public void ActivateAbility(int A) { Debug.Log("Activated Ability: " + PlayerAbilities[A].name); _Player.GetComponent <Animator>().runtimeAnimatorController = PlayerAbilities[A].Animator; _Ability1.SetActive(false); _Ability2.SetActive(false); _Ability3.SetActive(false); _Ability4.SetActive(false); _EnemyParent.SendMessage("TakeDamage", PlayerAbilities[A].Damage - StartingEnemy.Defense - EnemyDefendDefense); if (PlayerAbilities[A].DebuffMessage != "") { this.gameObject.SendMessage(PlayerAbilities[A].DebuffMessage, false); } if (PlayerAbilities[A].IsIsolatedText == false) { CombatDialogue.GetComponent <TextMeshProUGUI>().text = "Crono " + PlayerAbilities[A].CombatText + " " + StartingEnemy.Name; } if (PlayerAbilities[A].IsIsolatedText == true) { CombatDialogue.GetComponent <TextMeshProUGUI>().text = "Crono " + PlayerAbilities[A].CombatText; } State = States.Idle; PlayerTurn = false; }
void DecideEnemyAction() { if (EnemyHealthBar.GetComponent <Image>().fillAmount > .5) { if (Random.Range(0, 100) > 75) { EnemyDecidedAttack = 1; _EnemyParent.GetComponent <Animator>().runtimeAnimatorController = StartingEnemy.DefenseAbility.Animator; CombatDialogue.GetComponent <TextMeshProUGUI>().text = StartingEnemy.DefenseAbility.CombatText; EnemyDefendDefense = 0.1f; if (StartingEnemy.DefenseAbility.Healing > 0) { _EnemyParent.SendMessage("Heal", StartingEnemy.DefenseAbility.Healing); } PlayerTurn = true; State = States.Idle; return; } else { EnemyDecidedAttack = 0; _EnemyParent.GetComponent <Animator>().runtimeAnimatorController = StartingEnemy.BasicAttack.Animator; CombatDialogue.GetComponent <TextMeshProUGUI>().text = StartingEnemy.BasicAttack.CombatText; State = States.Idle; PlayerTurn = true; return; } } if (EnemyHealthBar.GetComponent <Image>().fillAmount < .5) { if (EnemySignatureCharges > 0) { EnemyDecidedAttack = 3; EnemySignatureCharges--; _EnemyParent.GetComponent <Animator>().runtimeAnimatorController = StartingEnemy.SignatureAbility.Animator; CombatDialogue.GetComponent <TextMeshProUGUI>().text = StartingEnemy.SignatureAbility.CombatText; if (StartingEnemy.SignatureAbility.Healing > 0) { _EnemyParent.SendMessage("Heal", StartingEnemy.SignatureAbility.Healing); } PlayerTurn = true; State = States.Idle; return; } if (EnemySignatureCharges <= 0) { if (Random.Range(0, 100) > 70) { EnemyDecidedAttack = 2; _EnemyParent.GetComponent <Animator>().runtimeAnimatorController = StartingEnemy.UtilityAbility.Animator; CombatDialogue.GetComponent <TextMeshProUGUI>().text = StartingEnemy.UtilityAbility.CombatText; PlayerTurn = true; State = States.Idle; return; } else { EnemyDecidedAttack = 0; _EnemyParent.GetComponent <Animator>().runtimeAnimatorController = StartingEnemy.BasicAttack.Animator; CombatDialogue.GetComponent <TextMeshProUGUI>().text = StartingEnemy.BasicAttack.CombatText; State = States.Idle; PlayerTurn = true; return; } } } }
// Update is called once per frame void FixedUpdate() { if (_Enemy.GetComponent <SpriteRenderer>().sprite == null) { _Enemy.GetComponent <SpriteRenderer>().sprite = StartingEnemy.DefaultSprite; } switch (State) { case States.Idle: if (EnemyBarFill.fillAmount <= 0) { State = States.EndingCombat; CombatDialogue.GetComponent <TextMeshProUGUI>().text = "You have Won The Battle!"; PlayerWin = true; } if (PlayerBarFill.fillAmount <= 0) { State = States.EndingCombat; CombatDialogue.GetComponent <TextMeshProUGUI>().text = "You have Died!"; PlayerDefeat = true; } IdleCount++; if (IdleCount > 100) { if (PlayerTurn) { State = States.PlayerTurn; _Ability1.SetActive(true); _Ability2.SetActive(true); _Ability3.SetActive(true); _Ability4.SetActive(true); CombatDialogue.GetComponent <TextMeshProUGUI>().text = " "; IdleCount = 0; } if (PlayerTurn == false) { State = States.EnemyTurn; IdleCount = 0; } } break; case States.PlayerTurn: DefendDefense = 0; break; case States.EnemyTurn: EnemyDefendDefense = 0; DecideEnemyAction(); break; case States.EndingCombat: if (PlayerWin) { EndingCount++; if (EndingCount > 250) { GameObject o = GameObject.Find("PersistentManager"); float f = Random.Range(0.2f, 0.3f); o.GetComponent <PersistentManager>().ExpWaiting = f; SceneManager.LoadScene(1); } } break; case States.CombatEnd: break; default: break; } }