/// <summary> /// Handle entity combat. /// Return true if combat resulted in defender's death /// and attacker is allowed to move unto that tile. /// </summary> /// <param name="attacker"></param> /// <param name="defender"></param> /// <returns></returns> private bool DoCombat(FighterComponent attacker, FighterComponent defender) { int attackPower = attacker.GetAttackPower(); // Debug.Log("Attacker attacks with power " + attackPower); //Debug.Log("Defender defends with power " + defender.GetDefensePower()); //if (attacker.thisEntity.isPlayer == true) //{ // MessageLog_Manager.NewMessage("You attack the " + defender.thisEntity.Name + " with " + attackPower + " attack!", Color.red); //} int damage = attackPower - defender.GetDefensePower(); //Debug.Log("After defense mitigation... damage is " + damage); if (damage > 0) { if (defender.thisEntity.isPlayer == true) { cameraShaker.AddTrauma(5.2f, 2.8f); MessageLog_Manager.NewMessage(attacker.thisEntity.Name + " hits you for " + damage.ToString() + "!", Color.white); } else { MessageLog_Manager.NewMessage("You hit the " + defender.thisEntity.Name + " for " + damage.ToString() + "!", Color.red); } } else { if (attacker.thisEntity.isPlayer == true) { MessageLog_Manager.NewMessage(defender.thisEntity.Name + "'s defense absorb your attack!", Color.white); } else { MessageLog_Manager.NewMessage("Your defenses absorb the attack!", Color.white); } } bool result = defender.ReceiveDamage(damage); if (result == true) { if (attacker.thisEntity.isPlayer == true) { MessageLog_Manager.NewMessage(defender.thisEntity.Name + " DIES!", Color.red); // Gain xp for kill XPComponent xPComponent = (XPComponent)attacker.thisEntity.GetEntityComponent(ComponentID.XP); EnemyComponent enemy = (EnemyComponent)defender.thisEntity.GetEntityComponent(ComponentID.AI); XPSystem.instance.DoXPGainAction(xPComponent.xpData, enemy.enemyLevel); } else { MessageLog_Manager.NewMessage(attacker.thisEntity.Name + " KILLS YOU!", Color.red); } } return(result); }