public static void Sleep(baseStats target, battleSystem bat) { bat.StartCoroutine(sleep()); IEnumerator sleep() { if (target.statusDuration > 0) { bat.battleText.text = target.nameChar + " is sleeping..."; target.transform.GetChild(1).GetComponent <Animator>().SetBool("sleeping", true); yield return(new WaitForSeconds(.5f)); target.transform.GetChild(1).GetComponent <Animator>().SetBool("sleeping", false); bat.StartCoroutine(bat.sleep()); target.statusDuration -= 1; } else { bat.battleText.text = target.nameChar + " woke up!"; target.transform.GetChild(0).GetComponent <SpriteRenderer>().color = Color.white; target.status = null; yield return(new WaitForSeconds(1f)); if (target.gameObject.tag == "enemy") { target.turn = true; int ran = Random.Range(0, bat.lists.chars.Count); bat.battleTarget = bat.lists.chars[ran]; bat.attacker = target; foreach (InventorySlot slot in bat.slots) { slot.attacker = bat.attacker; } bat.StartCoroutine(bat.enemyAttack(bat.battleTarget)); } else if (target.gameObject.tag == "Player") { target.turn = true; bat.attacker = target; foreach (InventorySlot slot in bat.slots) { slot.attacker = bat.attacker; } bat.playerTurn(); } } } }
public static void Poison(baseStats target, battleSystem bat) { target.StartCoroutine(poison()); IEnumerator poison() { if (target.statusDuration > 0) { bat.battleText.text = target.nameChar + " is hurt by poison."; target.transform.GetChild(1).GetComponent <Animator>().SetBool("poisoned", true); yield return(new WaitForSeconds(.5f)); target.transform.GetChild(1).GetComponent <Animator>().SetBool("poisoned", false); float damage = Mathf.Round(target.ogHP * 0.03f); //yield return new WaitForSeconds(1f); target.HP -= damage; target.damageText.GetComponent <Text>().text = damage.ToString(); target.damageText.GetComponent <DamageTextEffect>().DamageStartFloating(); target.statusDuration -= 1; yield return(new WaitForSeconds(1f)); if (target.gameObject.tag == "enemy") { target.turn = true; int ran = Random.Range(0, bat.lists.chars.Count); bat.battleTarget = bat.lists.chars[ran]; bat.attacker = target; foreach (InventorySlot slot in bat.slots) { slot.attacker = bat.attacker; } bat.StartCoroutine(bat.enemyAttack(bat.battleTarget)); } else if (target.gameObject.tag == "Player") { target.turn = true; bat.attacker = target; foreach (InventorySlot slot in bat.slots) { slot.attacker = bat.attacker; } bat.playerTurn(); } } else { target.transform.GetChild(0).GetComponent <SpriteRenderer>().color = Color.white; bat.battleText.text = target.nameChar + " is cured of poison."; target.status = null; yield return(new WaitForSeconds(1f)); if (target.gameObject.tag == "enemy") { target.turn = true; int ran = Random.Range(0, bat.lists.chars.Count); bat.battleTarget = bat.lists.chars[ran]; bat.attacker = target; foreach (InventorySlot slot in bat.slots) { slot.attacker = bat.attacker; } bat.StartCoroutine(bat.enemyAttack(bat.battleTarget)); } else if (target.gameObject.tag == "Player") { target.turn = true; bat.attacker = target; foreach (InventorySlot slot in bat.slots) { slot.attacker = bat.attacker; } bat.playerTurn(); } } } }
public static void Depression(baseStats target, battleSystem bat, MonoBehaviour baat) { baat.StartCoroutine(Depressed()); IEnumerator Depressed() { if (target.statusDuration > 0) { target.transform.GetChild(1).GetComponent <Animator>().SetBool("depressed", true); yield return(new WaitForSeconds(.5f)); target.transform.GetChild(1).GetComponent <Animator>().SetBool("depressed", false); yield return(new WaitForSeconds(1.5f)); if (target.gameObject.tag == "enemy") { target.turn = true; int ran = Random.Range(0, bat.charStats.Count); bat.battleTarget = bat.charStats[ran]; bat.attacker = target; foreach (InventorySlot slot in bat.slots) { slot.attacker = bat.attacker; } bat.damage = target.attack * .25f; target.gameObject.GetComponent <Animator>().SetBool("attack", true); } else if (target.gameObject.tag == "Player") { target.turn = true; int ran = Random.Range(0, bat.enemies.Count); bat.battleTarget = bat.enemies[ran].gameObject; foreach (InventorySlot slot in bat.slots) { slot.attacker = bat.attacker; } bat.damage = Mathf.Round(target.attack * .25f); target.gameObject.GetComponent <Animator>().SetBool("attack", true); } target.statusDuration -= 1; bat.battleText.text = target.nameChar + " attacks weakly."; yield return(new WaitForSeconds(2f)); target.gameObject.GetComponent <Animator>().SetBool("attack", false); target.GetComponent <baseStats>().HP -= bat.damage; target.GetComponent <baseStats>().damageText.gameObject.GetComponent <Text>().text = bat.damage.ToString(); target.GetComponent <baseStats>().damageText.gameObject.GetComponent <DamageTextEffect>().DamageStartFloating(); bat.StartCoroutine(bat.sleep()); } else { bat.battleText.text = target.nameChar + " feels fine again."; yield return(new WaitForSeconds(2f)); if (target.gameObject.tag == "Player") { target.turn = true; bat.attacker = target; foreach (InventorySlot slot in bat.slots) { slot.attacker = bat.attacker; } Debug.Log("Turn:" + bat.attacker.name); bat.playerTurn(); } else if (target.gameObject.tag == "enemy") { target.turn = true; int ran = Random.Range(0, bat.lists.chars.Count); bat.battleTarget = bat.lists.chars[ran]; bat.attacker = target; foreach (InventorySlot slot in bat.slots) { slot.attacker = bat.attacker; } bat.StartCoroutine(bat.enemyAttack(bat.battleTarget)); } target.status = null; } } }
public static void Confuse(baseStats target, battleSystem bat, MonoBehaviour poo) { bat.StartCoroutine(confuse()); IEnumerator confuse() { if (target.statusDuration > 0) { bat.battleText.text = target.nameChar + " is confused!"; target.transform.GetChild(1).GetComponent <Animator>().SetBool("confused", true); yield return(new WaitForSeconds(.5f)); target.transform.GetChild(1).GetComponent <Animator>().SetBool("confused", false); yield return(new WaitForSeconds(1.5f)); int ran1 = Random.Range(0, 3); if (ran1 > 0) { if (target.gameObject.tag == "enemy") { bat.attacker = target; int ran = Random.Range(0, bat.lists.enemies.Count); bat.battleTarget = bat.lists.enemies[ran]; } else if (target.gameObject.tag == "Player") { bat.attacker = target; int ran = Random.Range(0, bat.lists.chars.Count); bat.battleTarget = bat.lists.chars[ran]; } bat.damage = Mathf.Round(bat.attacker.ogHP * 0.1f); yield return(new WaitForSeconds(2f)); bat.battleText.text = target.gameObject.name + " harms their own party!"; target.AttackSlash1(); yield return(new WaitForSeconds(1f)); target.GetComponent <baseStats>().HP -= bat.damage; target.GetComponent <baseStats>().damageText.gameObject.GetComponent <Text>().text = bat.damage.ToString(); target.GetComponent <baseStats>().damageText.gameObject.GetComponent <DamageTextEffect>().DamageStartFloating(); bat.StartCoroutine(bat.sleep()); } else if (ran1 < 1) { if (target.gameObject.tag == "enemy") { target.turn = true; int ran = Random.Range(0, bat.lists.chars.Count); bat.battleTarget = bat.lists.chars[ran]; bat.attacker = target; foreach (InventorySlot slot in bat.slots) { slot.attacker = bat.attacker; } bat.StartCoroutine(bat.enemyAttack(bat.battleTarget)); } else if (target.gameObject.tag == "Player") { target.turn = true; bat.attacker = target; foreach (InventorySlot slot in bat.slots) { slot.attacker = bat.attacker; } bat.playerTurn(); } } target.statusDuration -= 1; } else { target.transform.GetChild(0).GetComponent <SpriteRenderer>().color = Color.white; bat.battleText.text = target.nameChar + " regained consciousness."; target.status = null; yield return(new WaitForSeconds(1f)); if (target.gameObject.tag == "Player") { target.turn = true; bat.attacker = target; foreach (InventorySlot slot in bat.slots) { slot.attacker = bat.attacker; } Debug.Log("Turn:" + bat.attacker.name); bat.playerTurn(); } else if (target.gameObject.tag == "enemy") { target.turn = true; int ran = Random.Range(0, bat.lists.chars.Count); bat.battleTarget = bat.lists.chars[ran]; bat.attacker = target; foreach (InventorySlot slot in bat.slots) { slot.attacker = bat.attacker; } bat.StartCoroutine(bat.enemyAttack(bat.battleTarget)); } } } }