IEnumerator WaitAndThenGetHit(UnitStats target) { ui.DisableMainButtons(); ui.DisableTargetButtons(); bool used = false; if (flow.currentUnit.currentMana >= ability.mpCost) { flow.currentUnit.battleAnimator.GetComponent <Animator>().Play(ability.defaultAttackAnimation + flow.currentUnit.facing.ToString()); yield return(new WaitForSeconds(0.33f)); if (ability.targetType == TargetType.One) { if (ability.heal > 0 && target.currentHealth < target.maxHealth) { int toHeal = Mathf.RoundToInt(flow.currentUnit.modMagAttack * ability.heal); target.RestoreHp(toHeal); ui.ShowHealText(target, toHeal); used = true; } else if (ability.damage > 0) { DealDamageToTarget(target); used = true; } } else if (ability.targetType == TargetType.AllFriendly) { foreach (UnitStats member in flow.friendlyUnits) { UnitStats memberStats = member.GetComponent <UnitStats>(); if (ability.heal > 0 && memberStats.currentHealth < memberStats.maxHealth) { int toHeal = Mathf.RoundToInt(flow.currentUnit.modMagAttack * ability.heal); memberStats.RestoreHp(toHeal); ui.ShowHealText(memberStats, toHeal); used = true; } else if (ability.damage > 0) { DealDamageToTarget(memberStats); used = true; } } } else if (ability.targetType == TargetType.All) { if (ability.heal > 0 && flow.currentUnit.currentHealth < flow.currentUnit.maxHealth) { int toHeal = Mathf.RoundToInt(flow.currentUnit.modMagAttack * ability.heal); flow.currentUnit.RestoreHp(toHeal); ui.ShowHealText(flow.currentUnit, toHeal); used = true; } else if (ability.damage > 0) { DealDamageToTarget(flow.currentUnit); used = true; } foreach (UnitStats member in flow.units) { UnitStats memberStats = member.GetComponent <UnitStats>(); if (ability.heal > 0 && memberStats.currentHealth < memberStats.maxHealth) { int toHeal = Mathf.RoundToInt(flow.currentUnit.modMagAttack * ability.heal); memberStats.RestoreHp(toHeal); ui.ShowHealText(memberStats, toHeal); used = true; } else if (ability.damage > 0) { DealDamageToTarget(memberStats); used = true; } } } } if (used) { flow.currentUnit.currentMana -= ability.mpCost; flow.SetUpNextTurn(ability.speedRank); } else { ui.EnableMainButtons(); } }
IEnumerator WaitAndThenGetHit(UnitStats target) { ui.DisableMainButtons(); ui.DisableTargetButtons(); bool used = false; if (item.itemType == ItemType.Consumable) { ConsumableItem consumable = (ConsumableItem)Databases.items[itemNum]; if (consumable.targetType == TargetType.One) { if (consumable.hpRestore > 0 && target.currentHealth < target.maxHealth) { target.RestoreHp(consumable.hpRestore); ui.ShowHealText(target, consumable.hpRestore); used = true; } if (consumable.mpRestore > 0 && target.currentMana < target.maxMana) { target.RestoreMp(consumable.mpRestore); used = true; } } else if (consumable.targetType == TargetType.AllFriendly) { foreach (UnitStats member in flow.friendlyUnits) { UnitStats memberStats = member.GetComponent <UnitStats>(); if (memberStats.available == true) { if (consumable.hpRestore > 0 && memberStats.currentHealth < memberStats.maxHealth) { memberStats.RestoreHp(consumable.hpRestore); ui.ShowHealText(memberStats, consumable.hpRestore); used = true; } if (consumable.mpRestore > 0 && memberStats.currentMana < memberStats.maxMana) { memberStats.RestoreMp(consumable.mpRestore); used = true; } } } } else if (consumable.targetType == TargetType.All) { if (consumable.hpRestore > 0 && flow.currentUnit.currentHealth < flow.currentUnit.maxHealth) { flow.currentUnit.RestoreHp(consumable.hpRestore); ui.ShowHealText(flow.currentUnit, consumable.hpRestore); used = true; } foreach (UnitStats member in flow.units) { UnitStats memberStats = member.GetComponent <UnitStats>(); if (memberStats.available == true) { if (consumable.hpRestore > 0 && memberStats.currentHealth < memberStats.maxHealth) { memberStats.RestoreHp(consumable.hpRestore); ui.ShowHealText(memberStats, consumable.hpRestore); used = true; } if (consumable.mpRestore > 0 && memberStats.currentMana < memberStats.maxMana) { memberStats.RestoreMp(consumable.mpRestore); used = true; } } } } } if (used) { party.RemoveItemFromInventory(itemNum); flow.currentUnit.battleAnimator.GetComponent <Animator>().Play("Thrust" + target.facing.ToString()); yield return(new WaitForSeconds(0.33f)); if (target.IsDead()) { target.battleAnimator.GetComponent <Animator>().Play("Die"); flow.units.Remove(target); } else { target.battleAnimator.GetComponent <Animator>().Play("Hit" + target.facing.ToString()); } yield return(new WaitForSeconds(1.0f)); } else { ui.EnableMainButtons(); } }