/// <summary> /// Returns the number of weapon activations required to kill the target component or ship - avoids over-firing /// </summary> /// <returns></returns> private int GetNumWeaponsToActivate(Component_Weapon weapon) { int numWeaponsToKillShields = Mathf.CeilToInt(targetShip.ShieldStrength / weapon.ShieldDamage); #if FULL_DEBUG Debug.LogWarning("Weapon activation calculation: "); Debug.Log("Target shield: " + targetShip.ShieldStrength + " weapon shield dmg " + weapon.ShieldDamage + " num to kill shield " + numWeaponsToKillShields); #endif if (numWeaponsToKillShields > selectedComponents.Count) { return selectedComponents.Count; } int numWpnsToKillComp = Mathf.CeilToInt(targetComponent.CompHP / weapon.ComponentDamage); int numWpnsToKillHull = Mathf.CeilToInt(targetShip.HullHP / weapon.HullDamage); #if FULL_DEBUG Debug.Log("Target comp HP: " + targetComponent.CompHP + " weapon comp dmg " + weapon.ComponentDamage + " num to kill comp " + numWpnsToKillComp); Debug.Log("Target hull HP: " + targetShip.HullHP + " weapon hull dmg " + weapon.HullDamage + " num to kill hull " + numWpnsToKillHull); #endif //num weapon activations is the minimum to kill target component or to kill hull int totalWpnActivations = numWeaponsToKillShields + (numWpnsToKillComp < numWpnsToKillHull ? numWpnsToKillComp : numWpnsToKillHull); if (totalWpnActivations > selectedComponents.Count) { return selectedComponents.Count; } return totalWpnActivations; }
private bool WeaponCanHitEnemy(Component_Weapon weapon) { return weapon.range >= Vector3.Distance(trans.position, aiTrans.position); }