public void EstablishSource() { if (tag == "Enemy") { attacker = DeathHandler.Combatant.LizardPerson; } if (tag == "Player") { Mage[] mages = FindObjectsOfType <Mage>(); for (int i = 0; i < mages.Length; i++) { for (int j = 0; j < mages[i].spellSlots.Length; j++) { if (name == mages[i].spellSlots[j].attack.name + "(Clone)") { if (mages[i].playerIndex == Player.Index.One) { attacker = DeathHandler.Combatant.ThermalMage; } else { attacker = DeathHandler.Combatant.ElectromagneticMage; } } } } } }
private void ReportDeath(DeathHandler.Combatant victim) { print(attacker + " killed " + victim); DeathHandler dh = FindObjectOfType <DeathHandler>(); dh.RegisterDeath(attacker, victim); }
private void ApplyDamage(Health enemyHp) { //Sometimes enemies will die in the middle of an attack if (enemyHp == null) { return; } //If the enemy is recovering then we can't hurt them again either if (enemyHp.inRecovery) { return; } //If this is going to kill it, we'll report it to the death handler if (enemyHp.currentHealth - damage <= 0) { //Figure out which kind of death to report DeathHandler.Combatant victim = DeathHandler.Combatant.NULL; //If it's tagged enemy, then its a lizard person if (enemyHp.tag == "Enemy") { victim = DeathHandler.Combatant.LizardPerson; } else //Otherwise, we'll find out which player based on the mage's playerIndex { Mage player = enemyHp.GetComponent <Mage>(); if (player.playerIndex == Player.Index.One) { victim = DeathHandler.Combatant.ThermalMage; } if (player.playerIndex == Player.Index.Two) { victim = DeathHandler.Combatant.ElectromagneticMage; } } ReportDeath(victim); } enemyHp.DealDamage(damage); }
private void CastSpell(int spellIndex) { //Instantiate casted Magic GameObject magic; magic = Instantiate(spellSlots[spellIndex].attack.gameObject, transform.position, Quaternion.identity); //Tag the spell DeathHandler.Combatant source = DeathHandler.Combatant.NULL; if (playerIndex == Index.One) { source = DeathHandler.Combatant.ThermalMage; } if (playerIndex == Index.Two) { source = DeathHandler.Combatant.ElectromagneticMage; } //Start cooldown StartCoroutine(CoolDown(spellIndex)); }