IEnumerator EnemyTurn() { dialogText.text = enemyUnit.unitName + " attacks!"; yield return(new WaitForSeconds(1f)); //Do damage int damageDone = UnityEngine.Random.Range(1, enemyUnit.damage); bool isDead = playerUnit.TakeDamage(damageDone); //Update UI playerHUD.SetHP(playerUnit.currentHP); dialogText.text = string.Format("You took {0} damage!", damageDone); //Pause UI yield return(new WaitForSeconds(1f)); //Handle next state if (isDead) { state = BattleState.LOST; EndBattle(); } else { state = BattleState.PLAYERTURN; PlayerTurn(); } }
IEnumerator EnemyTurn() { dialogueText.text = enemyUnit.unitName + "'s turn!"; yield return(new WaitForSeconds(2f)); dialogueText.text = enemyUnit.unitName + " attacks!"; yield return(new WaitForSeconds(1f)); bool isDead = playerUnit.TakeDamage(enemyUnit.damage); playerHUD.SetHP(playerUnit); yield return(new WaitForSeconds(1f)); if (isDead) { state = BattleState.LOST; StartCoroutine(EndBattle()); } else { state = BattleState.PLAYERTURN; PlayerTurn(); } }
IEnumerator SetUpBattle(int battleNum) { playerHUD.SetHUD(player); playerHUD.SetHP(player.currentHP); int enemyAmount = battleSequences[battleNum].enemyUnits.Length; enemyAmountThisRound = enemyAmount; for (int i = 0; i < enemyAmount; i++) { GameObject go = Instantiate(battleSequences[battleNum].enemyUnits[i], transform); enemyHUD[i].gameObject.SetActive(true); enemyHUD[i].SetHUD(go.GetComponent <Unit>()); enemyHUD[i].SetHP(enemyHUD[i].enemyUnit.maxHP); } dialogText.text = battleSequences[battleNum].battleDescription; yield return(new WaitForSeconds(3f)); state = BattleState.PlayerTurn; PlayerTurn(); }
IEnumerator EnemyTurn() { bool isDead; EnemyChance(); if (playerUnit.blocking == false) { isDead = playerUnit.TakeDamage(enemyUnit.damage); playerHUD.SetHP(playerUnit.currentHP); dialogueText.text = "Your blow has landed" + enemyUnit.unitName; } else { isDead = playerUnit.isBlocking(enemyUnit.damage, playerUnit.block); playerHUD.SetHP(playerUnit.currentHP); dialogueText.text = "your blow has been blocked" + enemyUnit.unitName; playerUnit.blocking = false; } yield return(new WaitForSeconds(2f)); if (isDead) { //End the battle state = BattleState.WON; EndBattle(); } else { //Player Turn state = BattleState.PLAYERTURN; PlayerTurn(); } }
IEnumerator PlayerAttack() { //MakeSelection(); bool isDead = enemy1Unit.TakeDamage(player1Unit.data.damage); enemyHUD.SetHP(enemy1Unit.data.currentHP); Debug.Log("Attack successful against " + enemy1Unit); // Hide the player Actions options after selection is made playerHUD.DisableActions(playerHUD); yield return(new WaitForSeconds(2f)); if (isDead) { state = BattleState.WON; EndBattle(); } else { state = BattleState.ENEMYTURN; EnemyTurn(); } }
void EnemyAttack() { enemyAttack.Attack(); enemyUnit.TakeDamage(playerUnit.damage); enemyHUD.SetHP(enemyUnit.currentHP); }
IEnumerator PlayerHeal() { buttons.SetActive(false); if (PlayerUnit.CurrentHP < PlayerUnit.MaxHP) { DialogueText.text = "You Have Recovered Energy!"; PlayerAnim.SetBool("PlayerHeals", true); Instantiate(HealEffect, PlayerEffectSpawnPoint.transform.position, Quaternion.identity); } else { DialogueText.text = "You Are Already Fully Healed."; } yield return(new WaitForSeconds(4f)); PlayerUnit.Heal(45); PlayerHUD.SetHP(PlayerUnit.CurrentHP); yield return(new WaitForSeconds(3f)); state = BattleState.ENEMYTURN; StartCoroutine(EnemyTurn()); }
IEnumerator EnemyTurn() { state = BattleState.ENEMYTURN; while (state == BattleState.ENEMYTURN) { audioPlayer.PlayOneShot(attack); GameObject.FindObjectOfType <ShakeBehavior>().TriggerShake(); isDoingSomething = true; dialogueText.text = enemyUnit.unitName + " attacks!"; yield return(new WaitForSeconds(0.5f)); bool isDead = playerUnit.TakeDamage(enemyUnit.damage); playerHUD.SetHP(playerUnit.currentHP); if (isDead) { state = BattleState.LOST; EndBattle(); } else { state = BattleState.PLAYERTURN; PlayerTurn(); } } }
IEnumerator EnemyTurn() { dialogueText.text = enemyUnit.unitName + " attacks!"; flowchart.ExecuteBlock("PunchPlayer"); yield return(new WaitForSeconds(1f)); dialogueText.text = "The attack lands feebly."; bool isDead = playerUnit.TakeDamage(enemyUnit.damage); playerHUD.SetHP(playerUnit.currentHP); yield return(new WaitForSeconds(1f)); if (isDead) { state = BattleState.LOST; EndBattle(); } else { state = BattleState.PLAYERTURN; PlayerTurn(); } }
IEnumerator PlayerAttack() { bool isDead = enemyUnit.currentHp <= 0; StartCoroutine(HitChance()); PlayerView(); //bool isDead = enemyUnit.TakeDamage(playerUnit.damage); Instantiate(AtkName, playerUnit.transform); //atkNameText.text = "Attack"; playerUnit.anim.SetTrigger("Attack"); enemyUnit.anim.SetTrigger("Hurt"); enemyHUD.SetHP(enemyUnit.currentHp); skillMenu.SetActive(false); yield return(new WaitForSeconds(3f)); if (isDead) { StopAllCoroutines(); state = BattleState.WON; StartCoroutine(EndBattle()); enemyUnit.GiveExperience(10); } else { state = BattleState.ENEMYTURN; StartCoroutine(EnemyTurn()); EnemyView(); } }
IEnumerator EnemyTurn() { dialogueText.text = enemyUnit.unitName + " atacó!"; enemySound.Play(); yield return(new WaitForSeconds(0.5f)); bool isDead = playerUnit.TakeDamage(enemyUnit.damage); playerHUD.SetHP(playerUnit.currentHP); yield return(new WaitForSeconds(1f)); if (isDead) { state = BattleState.LOST; EndBattle(); } else { state = BattleState.PLAYERTURN; PlayerTurn(); } }
IEnumerator EnemyTurn() { if (enemyUnit.currentHP >= enemyUnit.maxHP * .7f) { dialogueText.text = enemyUnit.unitName + " attacks!"; bool isDead = playerUnit.TakeDamage(enemyUnit.damage); playerHUD.SetHP(playerUnit.currentHP); yield return(new WaitForSeconds(1f)); if (isDead) { state = BattleState.LOSE; EndBattle(); } else { state = BattleState.PLAYERTURN; PlayerTurn(); } } else { int number = Random.Range(0, 10); if (number >= 2) { dialogueText.text = enemyUnit.unitName + " attacks!"; bool isDead = playerUnit.TakeDamage(enemyUnit.damage); playerHUD.SetHP(playerUnit.currentHP); yield return(new WaitForSeconds(1f)); if (isDead) { state = BattleState.LOSE; EndBattle(); } else { state = BattleState.PLAYERTURN; PlayerTurn(); } } else { dialogueText.text = enemyUnit.unitName + " heals!"; enemyUnit.Heal(5); enemyHUD.SetHP(enemyUnit.currentHP); yield return(new WaitForSeconds(1f)); state = BattleState.PLAYERTURN; PlayerTurn(); } } }
IEnumerator PlayerHeal() { playerUnit.Heal(Random.Range(2, 4)); playerHUD.SetHP(playerUnit.currentHP); dialogueText.text = "You regained some stamina..."; yield return(new WaitForSeconds(2f)); state = BattleState.ENEMYTURN; StartCoroutine(EnemyTurn()); }
IEnumerator PlayerHeal() { playerUnit.Heal(5); playerHUD.SetHP(playerUnit.currentHP); dialogText.text = "You are filled with determination.. and strength"; yield return(new WaitForSeconds(2f)); state = BattleState.ENEMYTURN; StartCoroutine(EnemyTurn()); }
IEnumerator PlayerHeal() { PlayerUnit.Heal(5); playerHUD.SetHP(PlayerUnit.currentHP); DialogueText.text = "You feel renewed strenght"; yield return(new WaitForSeconds(2f)); state = BattleState.ENEMYTURN; StartCoroutine(EnemyTurn()); }
// Start is called before the first frame update void Start() { music.Play(); state = BattleState.START; StartCoroutine(SetupBattle()); playerUnit.currentHP = playerUnit.maxHP; enemyUnit.currentHP = enemyUnit.maxHP; playerHUD.SetHP(playerUnit.currentHP); enemyHUD.SetHP(enemyUnit.currentHP); userHealCount = 3; enemyHealCount = 3; }
IEnumerator PlayerAttack() { buttons.SetActive(false); btnDesc.SetActive(false); if (EnemyUnit.CurrentSpeed >= PlayerUnit.CurrentAcc) { yield return(new WaitForSeconds(2f)); bool isDead = EnemyUnit.TakeDamage(0); EnemyHUD.SetHP(EnemyUnit.CurrentHP); DialogueText.text = "Oh No! Enemy Has Dodged!"; yield return(new WaitForSeconds(3f)); if (isDead) //the enemy { state = BattleState.WON; EndBattle(); } else { state = BattleState.ENEMYTURN; StartCoroutine(EnemyTurn()); } } else if (EnemyUnit.CurrentSpeed <= PlayerUnit.CurrentAcc) { EnemyAnim.SetBool("EnemyHit", true); bool isDead = EnemyUnit.TakeDamage(PlayerUnit.Damage); EnemyHUD.SetHP(EnemyUnit.CurrentHP); DialogueText.text = "Enemy Has Been Hit!"; yield return(new WaitForSeconds(3f)); if (isDead) //the enemy { state = BattleState.WON; EndBattle(); } else { state = BattleState.ENEMYTURN; StartCoroutine(EnemyTurn()); } } }
IEnumerator PlayerHeal() { playerUnit.Heal(Mathf.RoundToInt(playerUnit.damage * 2f)); // Leikmaður getur „heal“-að sig um tvöfaldan skaðinn sem hann getur valdið playerHUD.SetHP(playerUnit.currentHP); audioSource.PlayOneShot(healSound); dialogueText.text = "You feel renewed strength!"; yield return(new WaitForSeconds(2f)); state = BattleState.ENEMYTURN; StartCoroutine(EnemyTurn()); }
IEnumerator PlayerHeal() { Instantiate(healFx, playerUnit.transform); playerUnit.Heal(15); playerHUD.SetHP(playerUnit.currentHp); dialogueText.text = "You feel renewed"; playerHUD.SetMana(playerUnit.currentMana); yield return(new WaitForSeconds(2f)); state = BattleState.ENEMYTURN; StartCoroutine(EnemyTurn()); }
IEnumerator PlayerHeal() { playerUnit.HealDamage(playerUnit.damage); playerHUD.SetHP(playerUnit.currentHP); Debug.Log("Heal successful"); // Hide the player Actions options after selection is made playerHUD.DisableActions(playerHUD); yield return(new WaitForSeconds(2f)); state = BattleState.ENEMYTURN; EnemyTurn(); }
public void EnemyTurn(float[] vectorAction) { dialogueText.text = enemyUnit.unitName + " attacks!"; if (vectorAction[0] == 1) { bool isDead = playerUnit.TakeDamage(enemyUnit.damage); playerHUD.SetHP(playerUnit.currentHP); if (isDead) { state = BattleState.LOST; EndBattle(); } else { state = BattleState.PLAYERTURN; agent.AddReward(0.5f); PlayerTurn(); } } else if (vectorAction[1] == 1) { enemyUnit.Heal(5); agent.AddReward(0.5f); enemyHUD.SetHP(enemyUnit.currentHP); state = BattleState.PLAYERTURN; PlayerTurn(); } //yield return new waitforseconds(1f); //bool isdead = playerunit.takedamage(enemyunit.damage); //playerhud.sethp(playerunit.currenthp); //yield return new waitforseconds(1f); //if (isdead) //{ // state = battlestate.lost; // endbattle(); //} //else //{ // state = battlestate.playerturn; // playerturn(); //} }
IEnumerator EnemyTurn() { //displays the name of attack that enemy uses textBox.text = enemyUnit.unitName + " uses " + enemyUnit.currentSkills[0].skillName + "!"; yield return(new WaitForSeconds(1f)); //calculating damage here int damage = ((enemyUnit.attack) + (enemyUnit.currentSkills[0].skillPower)) - playerUnit.defense; bool isDead = playerUnit.TakeDamage(damage); //damage player - return T/F is dead playerHUD.SetHP(playerUnit.currentHP); //sets player's HP level in HUD //display successful hit, and damage textBox.text = enemyUnit.currentSkills[0].skillName + " hits for " + damage + " damage!"; yield return(new WaitForSeconds(1f)); if (isDead) { battleState = BattleState.Lost; EndBattle(); } else { battleState = BattleState.PlayerTurn; PlayerTurn(); } }
IEnumerator PlayerAttack() { //Damage state = BattleState.ENEMYTURN; bool isDead = enemyUnit.TakeDamage(playerUnit.damage); dialogueText.text = "You attack the enemy!"; Fire(); yield return(new WaitForSeconds(1f)); enemyHUD.SetHP(enemyUnit); dialogueText.text = "The attack hits!"; yield return(new WaitForSeconds(2f)); //Change if enemy is dead //change state based on what happened if (isDead) { //end battle state = BattleState.WON; Destroy(enemyGO); StartCoroutine(EndBattle()); } else { //enemy turn state = BattleState.ENEMYTURN; StartCoroutine(EnemyTurn()); } }
IEnumerator PlayerAttack() { GameObject.FindObjectOfType <ShakeBehavior>().TriggerShake(); bool isDead = enemyUnit.TakeDamage(playerUnit.damage); enemyHUD.SetHP(enemyUnit.currentHP); dialogueText.text = "You striked " + enemyUnit.unitName + "!"; audioPlayer.PlayOneShot(attack); yield return(new WaitForSeconds(2f)); if (isDead) { audioPlayer.PlayOneShot(monsterDead); state = BattleState.WON; isDoingSomething = false; dialogueText.text = "You won the battle!"; Invoke("EndBattle", 1f); } else { state = BattleState.ENEMYTURN; StartCoroutine(EnemyTurn()); } }
IEnumerator PlayerAttack(Unit playerUnit) { state = BattleState.PLAYERMOVE; dialogBox.EnableActionSelector(false); yield return(dialogBox.TypeDialog(playerUnit.unitName + " attacks!")); yield return(new WaitForSeconds(0.7f)); StartCoroutine(enemyUnit.flash()); yield return(new WaitForSeconds(0.3f)); bool isDead = enemyUnit.TakeDamage(playerUnit.damage); enemyHUD.SetHP(enemyUnit.currentHP, enemyUnit.maxHP); yield return(dialogBox.TypeDialog(enemyUnit.unitName + " took damage!")); yield return(new WaitForSeconds(1f)); if (isDead) { StartCoroutine(enemyUnit.fadeOut()); state = BattleState.WON; StartCoroutine(EndBattle()); } else { state = BattleState.ENEMYTURN; StartCoroutine(EnemyTurn()); } }
void PlayerAttack() { playerAttack.Attack(); playerUnit.TakeDamage(playerDamage); playerHUD.SetHP(playerUnit.currentHP); }
IEnumerator EnemyTurn() { if (!block) { dialogueText.text = enemyUnit.unitName + " attacks!"; yield return(new WaitForSeconds(1f)); isDead = playerUnit.TakeDamage(enemyUnit.damage); playerHUD.SetHP(playerUnit.currentHP); yield return(new WaitForSeconds(1f)); } else { dialogueText.text = "You blocked the attack!"; block = false; yield return(new WaitForSeconds(1f)); } if (isDead) { state = BattleState.LOST; EndBattle(); } else { state = BattleState.PLAYERTURN; PlayerTurn(); } }
IEnumerator PlayerAttack() { bool isDead = enemyUnit.TakeDamage(playerUnit.damage += damageMult); enemyHUD.SetHP(enemyUnit.currentHP); dialogueText.text = "The attack is successful!"; if (damageMult >= 5) { dialogueText.text = "Critical hit!"; } damageMult = 0; yield return(new WaitForSeconds(2f)); if (isDead) { state = BattleState.WON; EndBattle(); } else { state = BattleState.ENEMYTURN; StartCoroutine(EnemyTurn()); } }
IEnumerator PlayerAttack() { //Damage the enemy bool isDead = enemyUnit.TakeDamage(playerUnit.damage); enemyHUD.SetHP(enemyUnit.currentHP); dialogText.text = "The attack was successful"; yield return(new WaitForSeconds(2f)); if (isDead) { //end battle state = BattleState.WON; EndBattle(); } else { // enemyturn state = BattleState.ENEMYTURN; StartCoroutine(EnemyTurn()); } //check if enemy is dead // change state based on what happened }
IEnumerator PlayerAttack() { //Do damage int damageDone = UnityEngine.Random.Range(1, playerUnit.damage); bool isDead = enemyUnit.TakeDamage(damageDone); //Update UI enemyHUD.SetHP(enemyUnit.currentHP); dialogText.text = string.Format("Attack landed for {0} damage!", damageDone); //Pause UI yield return(new WaitForSeconds(2f)); //Handle next state if (isDead) { state = BattleState.WON; EndBattle(); } else { state = BattleState.ENEMYTURN; StartCoroutine(EnemyTurn()); } }