void OnDestroy() { // 正常 wordEvent.RemoveAllListeners(); inputCheckEvent.RemoveAllListeners(); checkSentenceEvent.RemoveAllListeners(); tapRightEvent.RemoveAllListeners(); voiceRepeatEvent.RemoveAllListeners(); // Boss 战 bossEnterEvent.RemoveAllListeners(); bossEnterFinishEvent.RemoveAllListeners(); bossPrepareAttackEvent.RemoveAllListeners(); bossAttackEvent.RemoveAllListeners(); bossDamageEvent.RemoveAllListeners(); bossDrawEvent.RemoveAllListeners(); bossFinishEvent.RemoveAllListeners(); bossWordRe_EnterEvent.RemoveAllListeners(); bossWordClickWrongEvent.RemoveAllListeners(); bossSentenceCompleteEvent.RemoveAllListeners(); }
public void Fight() { if (attackerStrat != null && defenderStrat != null) { float attackerArmySize = attacker.armySize; float defenderArmySize = defender.armySize; float attackerDamage = 0f; float defenderDamage = 0f; MatchUpStats matchUp = matchUps.GetMatchUp(attackerStrat, defenderStrat); for (int i = 1; i <= combatRounds; i++) { attackerDamage += GetDamage(matchUp.attackerDmgModifier, attackerArmySize); defenderDamage += GetDamage(matchUp.defenderDmgModifier, defenderArmySize); if (debugLogs) { Debug.Log("attackerDamage1: " + attackerDamage); } if (debugLogs) { Debug.Log("defenderDamage1: " + defenderDamage); } attackerArmySize -= GetDead(ref defenderDamage); defenderArmySize -= GetDead(ref attackerDamage); if (debugLogs) { Debug.Log("attackerDamage2: " + attackerDamage); } if (debugLogs) { Debug.Log("defenderDamage2: " + defenderDamage); } if (attackerArmySize <= 0 || defenderArmySize <= 0) { break; } } // % of enemy army killed float attackerPerformance = 1 - defenderArmySize / defender.armySize; float defenderPerformance = 1 - attackerArmySize / attacker.armySize; if (debugLogs) { Debug.Log("attackerPerformance: " + attackerPerformance); } if (debugLogs) { Debug.Log("defenderPerformance: " + defenderPerformance); } attacker.SetArmySize((int)Mathf.Ceil(attackerArmySize)); defender.SetArmySize((int)Mathf.Ceil(defenderArmySize)); gameObject.SetActive(false); if (debugLogs) { Debug.Log("attackerPerformance > defenderPerformance: " + (attackerPerformance > defenderPerformance)); } resolveBattle.Invoke(attackerPerformance > defenderPerformance); resolveBattle.RemoveAllListeners(); } }