public override float CalculateDps(Ship owner) { var meanDamage = (minDamage + maxDamage) / 2f; meanDamage = owner.ApplyDamageModifier(Mathf.FloorToInt(meanDamage)); return meanDamage / fireRate; }
public override void Activate(Ship activator, int slot) { if (Cooldown > 0) { return; } var hardpoint = activator.GetHardpointAt(slot); var module = activator.ModuleLoadout.GetSlot(slot); var aimingAt = module.Aim; if (hardpoint.CanAimAt(aimingAt)) { var firedTransform = hardpoint ? hardpoint.transform : activator.transform; var aimRot = Quaternion.LookRotation((module.Aim - firedTransform.position).normalized); var bulletInstance = (Bullet)Instantiate(bulletType, firedTransform.position, aimRot); bulletInstance.owner = activator; var randomDamage = UnityEngine.Random.Range(minDamage, maxDamage); bulletInstance.damage = activator.ApplyDamageModifier(randomDamage); if (activator.GetComponent<Rigidbody>()) { bulletInstance.baseVelocity = activator.GetComponent<Rigidbody>().velocity; } if (muzzleFlashType) { var flash = (Transform)Instantiate(muzzleFlashType, firedTransform.position, firedTransform.rotation); flash.SetParent(firedTransform, true); } Cooldown = fireRate; } }