public override void SpecialAttack1(string name, baseStats attacker, baseStats target) { attacker.StartCoroutine(SA()); IEnumerator SA() { attacker.b.battleText.text = attacker.name + " uses " + name; foreach (GameObject button in attacker.b.lists.buttons) { button.GetComponent <Button>().interactable = false; } attacker.SP -= 5; float upAttack = attacker.attack * .50f; float supAttack = attacker.attack + upAttack; float damage = supAttack - target.def; if (damage < 1) { damage = 1; } target.HP -= damage; attacker.HP -= upAttack; if (target.GetComponent <baseStats>().HP < 1) { attacker.StartCoroutine(attacker.b.Die(target.GetComponent <baseStats>())); } else { attacker.b.TurnOrder(); } yield break; } }
public IEnumerator enemyAttack(GameObject target) { attacker.slash = slashPrefab; yield return(new WaitForSeconds(1f)); battleText.text = attacker.nameChar + " attacks!"; if (attacker == null) { TurnOrder(); } damage = attacker.GetComponent <baseStats>().attack - target.GetComponent <baseStats>().def; if (damage < 1) { damage = 1; } attacker.gameObject.GetComponent <Animator>().SetBool("attack", true); yield return(new WaitForSeconds(2f)); target.GetComponent <baseStats>().HP -= damage; target.GetComponent <baseStats>().damageText.gameObject.GetComponent <Text>().text = damage.ToString(); target.GetComponent <baseStats>().damageText.gameObject.GetComponent <DamageTextEffect>().DamageStartFloating(); attacker.gameObject.GetComponent <Animator>().SetBool("attack", false); if (target.GetComponent <baseStats>().HP < 1) { StartCoroutine(Die(target.GetComponent <baseStats>())); } else if (target.GetComponent <baseStats>().HP > 1) { TurnOrder(); } }
public override void SpecialAttack2(string name, baseStats attacker, baseStats target) { attacker.StartCoroutine(SA()); IEnumerator SA() { if (attacker.SP > 1) { foreach (GameObject button in attacker.b.lists.buttons) { button.GetComponent <Button>().interactable = false; } attacker.b.battleTarget = target.gameObject; attacker.slash = SAPrefab1; attacker.SP -= 2; float upAttack = attacker.attack + 2; float damage = upAttack - target.def; if (damage < 1) { damage = 1; } attacker.b.battleText.text = attacker.gameObject.name + " uses " + name; attacker.gameObject.GetComponent <Animator>().SetBool("attack", true); yield return(new WaitForSeconds(1.2f)); if (target.status == "") { target.status = "Confused"; target.statusDuration = 4; } attacker.gameObject.GetComponent <Animator>().SetBool("attack", false); yield return(new WaitForSeconds(1.5f)); target.HP -= damage; target.damageText.GetComponent <Text>().text = damage.ToString(); target.damageText.GetComponent <DamageTextEffect>().DamageStartFloating(); if (target.GetComponent <baseStats>().HP < 1) { attacker.StartCoroutine(attacker.b.Die(target.GetComponent <baseStats>())); } else { attacker.b.TurnOrder(); } } else { int ran = Random.Range(0, attacker.b.charStats.Count); attacker.b.battleTarget = attacker.b.charStats[ran]; attacker.StartCoroutine(attacker.b.enemyAttack(attacker.b.battleTarget)); } } }
public override void SpecialAttack1(string name, baseStats attacker, baseStats target) { attacker.StartCoroutine(SA()); IEnumerator SA() { if (attacker.SP > 2) { attacker.SP -= 3; foreach (GameObject button in attacker.b.lists.buttons) { button.GetComponent <Button>().interactable = false; } attacker.b.battleText.text = attacker.nameChar + " uses " + name; attacker.gameObject.GetComponent <Animator>().SetBool("attack", true); attacker.slash = SAPrefab1; attacker.gameObject.GetComponent <enemyDeath>().multi = true; yield return(new WaitForSeconds(1.2f)); attacker.gameObject.GetComponent <Animator>().SetBool("attack", false); yield return(new WaitForSeconds(1.5f)); float attackUp = attacker.attack * 2f; foreach (GameObject hero in attacker.b.charStats) { float damage = attackUp - hero.GetComponent <baseStats>().def; if (damage < 1) { damage = 1; } hero.GetComponent <baseStats>().HP -= damage; hero.GetComponent <baseStats>().damageText.GetComponent <Text>().text = damage.ToString(); hero.GetComponent <baseStats>().damageText.GetComponent <DamageTextEffect>().DamageStartFloating(); } if (target.GetComponent <baseStats>().HP < 1) { attacker.StartCoroutine(attacker.b.Die(target.GetComponent <baseStats>())); } else { attacker.b.TurnOrder(); } } else { int ran = Random.Range(0, attacker.b.charStats.Count); attacker.b.battleTarget = attacker.b.charStats[ran]; attacker.StartCoroutine(attacker.b.enemyAttack(attacker.b.battleTarget)); } } }
public override void SpecialAttack1(string name, baseStats attacker, baseStats target) { attacker.StartCoroutine(SA1()); IEnumerator SA1() { if (attacker.SP > 3) { foreach (GameObject button in attacker.b.lists.buttons) { button.GetComponent <Button>().interactable = false; } attacker.b.battleTarget = target.gameObject; attacker.slash = SAPrefab1; attacker.SP -= 3; float upAttack = attacker.attack * 2; float damage = upAttack - target.def; attacker.b.battleText.text = attacker.name + " uses " + name; attacker.gameObject.GetComponent <Animator>().SetBool("attack", true); yield return(new WaitForSeconds(1.2f)); attacker.gameObject.GetComponent <Animator>().SetBool("attack", false); yield return(new WaitForSeconds(1f)); target.HP -= damage; if (damage < 1) { damage = 1; } target.damageText.GetComponent <Text>().text = damage.ToString(); target.damageText.GetComponent <DamageTextEffect>().DamageStartFloating(); if (target.GetComponent <baseStats>().HP < 1) { attacker.StartCoroutine(attacker.b.Die(target.GetComponent <baseStats>())); } else { attacker.b.TurnOrder(); } } else { attacker.skip = true; } } }
public override void SpecialAttack2(string name, baseStats attacker, baseStats target) { attacker.StartCoroutine(SA()); IEnumerator SA() { if (attacker.SP > 3) { foreach (GameObject button in attacker.b.lists.buttons) { button.GetComponent <Button>().interactable = false; } attacker.b.battleText.text = attacker.nameChar + " uses " + name; attacker.gameObject.GetComponent <Animator>().SetBool("attack", true); attacker.slash = SAPrefab2; attacker.SP -= 4; yield return(new WaitForSeconds(1.2f)); attacker.gameObject.GetComponent <Animator>().SetBool("attack", false); yield return(new WaitForSeconds(1.5f)); if (target.status == "") { target.status = "Sleep"; Color c = Color.gray; target.transform.GetChild(0).GetComponent <SpriteRenderer>().color = Color.gray; //Debug.Log(target.gameObject.GetComponentInChildren<SpriteRenderer>().color); target.statusDuration = 2; } float attackUp = attacker.attack * 2f; float damage = attackUp - target.GetComponent <baseStats>().def; if (damage < 1) { damage = 1; } target.GetComponent <baseStats>().HP -= damage; target.GetComponent <baseStats>().damageText.GetComponent <Text>().text = damage.ToString(); target.GetComponent <baseStats>().damageText.GetComponent <DamageTextEffect>().DamageStartFloating(); if (target.GetComponent <baseStats>().HP < 1) { attacker.StartCoroutine(attacker.b.Die(target.GetComponent <baseStats>())); } else { attacker.b.TurnOrder(); } } else { int ran = Random.Range(0, attacker.b.charStats.Count); attacker.b.battleTarget = attacker.b.charStats[ran]; attacker.StartCoroutine(attacker.b.enemyAttack(attacker.b.battleTarget)); } } }
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)); } } } }