public void QuadrantDestroyed(ShipQuadrant quad, AttachedWeapon weapon, float damage, bool ignoreShields, bool ignoreArmor, bool ignoreArmorRating) { if (quad == CenterSection) { if (Destroyed) { return; } weapon.GetKill(CurrentUnit); Destroyed = true; if (fleetData != null) { fleetData.RecalculateStats(); } if (CurrentUnit != null) { (CurrentUnit as Ship).Die(); } CurrentUnit = null; return; } else if (CurrentUnit != null) { CurrentUnit.AttachFireDamage((CurrentUnit as Ship).GetDamageHardPoint(), designData.Hull.ExplosionScale); if (damage > 0) { CenterSection.TakeDamage(weapon, CurrentUnit.transform.position, damage, ignoreShields, ignoreArmor, ignoreArmorRating); } } CalculateEngines(); }
public void TakeDamage(AttachedWeapon weapon, Vector3 hitPoint, Vector3 source, float damage, bool ignoreShields, bool ignoreArmor, bool ignoreArmorRating) { if (!ignoreShields) { CheckShieldHit(hitPoint, Vector2.zero); } stationData.TakeDamage(weapon, hitPoint, damage, ignoreShields, ignoreArmor, ignoreArmorRating); }
public override void LocalGetDownButton(Hand hand) { base.LocalGetDownButton(hand); if (main_handler.CurrentGrabHand == null) { AttachedWeapon.DisctivePhysics(hand); } }
void Die(AttachedWeapon weapon) { Destroyed = true; weapon.GetKill(this); shipManager.FighterKilled(this); ResourceManager.instance.CreateExplosion(transform.position, "effect_explosionfighter", "FighterExplosion", 0.33f, 5f, true); parentWing.RemoveUnit(this); gameObject.SetActive(false); }
public override void LocalGetDownButton(Hand hand) { if (CurrentGrabHand == null) { CurrentGrabHand = hand; CurrentGrabHand.GetComponentInChildren <SkinnedMeshRenderer>().enabled = false; AttachedWeapon.DisctivePhysics(hand); } }
public override void GlobalGetUpButton(Hand hand) { if (CurrentGrabHand != null) { AttachedWeapon.ActivePhysics(CurrentGrabHand, 1, 1); hand_pose.SetActive(false); CurrentGrabHand.GetComponentInChildren <SkinnedMeshRenderer>().enabled = true; CurrentGrabHand = null; } }
protected override void DetachFromWeapon() { var offset = ((ISupportClassicModule)AttachedWeapon).GetOffset(ModLoc); var v = AttachedWeapon.Offset(offset); Level.Add(new CraneSightPickup(v.x, v.y, this) { hSpeed = AttachedWeapon.hSpeed, vSpeed = AttachedWeapon.vSpeed }); }
public override void HandleGlobalInputs() { if (CurrentGrabHand != null) { if (OVRInput.GetUp(active_button, CurrentGrabHand.m_controller)) { AttachedWeapon.ActivePhysics(CurrentGrabHand, 2, 1); CurrentGrabHand.GetComponentInChildren <SkinnedMeshRenderer>().enabled = true; CurrentGrabHand = null; } } }
public float TakeShieldDamage(AttachedWeapon weapon, Vector3 position, float damage) { if (damage > 0 && shieldHealth > 0 && shieldRating > 0) { float effectiveDamage; if (weapon.baseWeapon.ShieldDamageModifier != 1f) { effectiveDamage = damage * weapon.baseWeapon.ShieldDamageModifier; } else { effectiveDamage = damage; } if (effectiveDamage > 0) { float absorbDamage = effectiveDamage * Mathf.Clamp(shieldRating / effectiveDamage, ResourceManager.instance.GetGameConstants().MinShieldAbsorb, 1f); float damageUseRatio; if (shieldHealth > absorbDamage) { if (GameManager.instance.GetShowCombatDamage()) { parentShip.CreateShieldDamagePopup(position, absorbDamage); } shieldHealth -= absorbDamage; damageUseRatio = 1f - absorbDamage / effectiveDamage; } else { if (GameManager.instance.GetShowCombatDamage()) { parentShip.CreateShieldDamagePopup(position, shieldHealth); } damageUseRatio = 1f - shieldHealth / effectiveDamage; shieldHealth = 0; shieldTimer = shieldDelay; } return(damage * damageUseRatio); } else { return(0f); } } else { return(damage); } }
public void Initialize(AttachedWeapon attached, Weapon weapon, Vector3 origin, GameObject target, Vector3 targetOffset) { if (target == null) { Destroy(gameObject); return; } attachedWeapon = attached; PrimaryWeapon = weapon; SecondaryWeapon = PrimaryWeapon.GetSecondaryWeapon(); Origin = origin; transform.position = origin; lifeTimer = PrimaryWeapon.ProjectileLife; Target = target; TargetOffset = targetOffset; if (PrimaryWeapon.isHoming) { isHoming = true; transform.rotation = Quaternion.LookRotation(target.transform.position - transform.position); additionalHomingTargets = PrimaryWeapon.HomingAdditionalTargets; if (PrimaryWeapon.PDTargetable) { transform.tag = "PDTarget"; Rigidbody rigidBody = gameObject.AddComponent <Rigidbody>(); rigidBody.isKinematic = true; Health = PrimaryWeapon.ProjectileHealth; GetShipManager().AddDPTargetableProjectile(this); } if (PrimaryWeapon.Jammable) { GetShipManager().AddJammableProjectile(this); } } else { if (target.transform.root.tag == "Ship" || target.transform.root.tag == "Fighter") { MobileSpaceUnit targetScript = target.transform.root.GetComponent <MobileSpaceUnit>(); RotateTowardsMovingTarget(targetScript); } else { transform.rotation = Quaternion.LookRotation(target.transform.position - transform.position); } } if (PrimaryWeapon.Spread > 0) { float spreadHalf = PrimaryWeapon.Spread / 2f; transform.Rotate(Random.Range(-spreadHalf, spreadHalf), Random.Range(-spreadHalf, spreadHalf), 0); } }
public void Initialize(AttachedWeapon attachedWeapon, GameObject parentObject, Vector3 origin, GameObject target, Vector3 targetOffset) { transform.position = origin; transform.parent = parentObject.transform; this.attachedWeapon = attachedWeapon; damageBonus = this.attachedWeapon.GetDamageBonus(); Target = target; TargetOffSet = targetOffset; if (Target.tag == "PDTarget") { targetProjectile = Target.GetComponent <Projectile>(); } if (this.attachedWeapon.baseWeapon.IgnoreShieldChance != 0) { if (this.attachedWeapon.baseWeapon.IgnoreShieldChance == 1f) { ignoreShields = true; } else { ignoreShields = Random.Range(0f, 1f) < this.attachedWeapon.baseWeapon.IgnoreShieldChance; } } if (this.attachedWeapon.baseWeapon.IgnoreArmorChance != 0) { if (this.attachedWeapon.baseWeapon.IgnoreArmorChance == 1f) { ignoreArmor = true; } else { ignoreArmor = Random.Range(0f, 1f) < this.attachedWeapon.baseWeapon.IgnoreArmorChance; } } if (this.attachedWeapon.baseWeapon.IgnoreArmorRatingChance != 0) { if (this.attachedWeapon.baseWeapon.IgnoreArmorRatingChance == 1f) { ignoreArmorRating = true; } else { ignoreArmorRating = Random.Range(0f, 1f) < this.attachedWeapon.baseWeapon.IgnoreArmorRatingChance; } } }
public bool inFiringArc(AttachedWeapon weapon, PDTargetInfo targetInfo) { //Check range in 2d if (weapon.baseWeapon.GetMaxRangeSqr() < targetInfo.RangeSqr) { return(false); } Vector2 WeaponDirection; switch (weapon.GetFiringDirection()) { case QuadrantTypes.Fore: { WeaponDirection = new Vector2(transform.forward.x, transform.forward.z); break; } case QuadrantTypes.Aft: { WeaponDirection = new Vector2(-transform.forward.x, -transform.forward.z); break; } case QuadrantTypes.Port: { WeaponDirection = new Vector2(-transform.right.x, -transform.right.z); break; } case QuadrantTypes.Starboard: { WeaponDirection = new Vector2(transform.right.x, transform.right.z); break; } default: { WeaponDirection = new Vector2(transform.forward.x, transform.forward.z); break; } } float targetAngle = Vector2.Angle(targetInfo.Direction, WeaponDirection); if (targetAngle > weapon.baseWeapon.GetHalfArc()) { return(false); } return(true); }
public void SetWeapons() { foreach (string weaponName in Definition.WeaponNames) { Weapon weapon = ResourceManager.instance.GetWeapon(weaponName); if (weapon != null) { AttachedWeapon attachedWeapon = new AttachedWeapon(weapon); attachedWeapon.SetParent(this); Weapons.Add(attachedWeapon); if (weapon.GetMaxRange() > attackRange) { attackRange = weapon.GetMaxRange(); } } } }
// Use this for initialization public ShipQuadrant(ShipData SD, ShipDesignQuadData quadData, QuadrantTypes quadType) { parentShip = SD; foreach (SavedWeapon weapon in quadData.Weapons) { QuadrantTypes firingDirection = quadType; if (weapon.weapon.AlwaysForward) { if (weapon.rotation == 0f) { firingDirection = QuadrantTypes.Fore; } else if (weapon.rotation == 90f) { firingDirection = QuadrantTypes.Starboard; } else if (weapon.rotation == 180f) { firingDirection = QuadrantTypes.Aft; } else { firingDirection = QuadrantTypes.Port; } } AttachedWeapon attachedWeapon = new AttachedWeapon(weapon.weapon); attachedWeapon.SetFiringQuadrant(firingDirection); Weapons.Add(attachedWeapon); } health = quadData.Health; healthMax = quadData.Health; armorHealth = quadData.ArmorHealth; armorHealthMax = quadData.ArmorHealth; armorRating = quadData.ArmorRating; shieldHealth = quadData.ShieldHealth; shieldHealthMax = quadData.ShieldHealth; shieldRating = quadData.ShieldRating; shieldRecharge = quadData.ShieldRechargeRate; shieldDelay = quadData.ShieldRechargeDelay; engineThrust = quadData.EngineThrust; engineTurn = quadData.EngineTurn; }
void CheckForTargets(AttachedWeapon weapon) { if (!weapon.baseWeapon.PointDefenseOnly) { //Check primary target validity if (Target != null && Target.CanBeTargeted() && isEnemy(Target) && inFiringArc(weapon, new TargetInfo(Target, MainTargetDirection, MainTargetRange))) { weapon.Fire(GetWeaponHardPoints(weapon), Target.gameObject, audioSource); return; } else //Check for targets of opportunity { foreach (TargetInfo potentialTarget in CachedTargets) { if (inFiringArc(weapon, potentialTarget)) { weapon.Fire(GetWeaponHardPoints(weapon), potentialTarget.Target.gameObject, audioSource); return; } } if (weapon.baseWeapon.PointDefense) { foreach (PDTargetInfo potentialTarget in PDCachedTargets) { if (inFiringArc(weapon, potentialTarget)) { weapon.Fire(GetWeaponHardPoints(weapon), potentialTarget.Target.gameObject, audioSource); return; } } } } } else if (weapon.baseWeapon.PointDefense) { foreach (PDTargetInfo potentialTarget in PDCachedTargets) { if (inFiringArc(weapon, potentialTarget)) { weapon.Fire(GetWeaponHardPoints(weapon), potentialTarget.Target.gameObject, audioSource); return; } } } }
public override void GlobalGetUpButton(Hand hand) { if (CurrentGrabHand != null) { if (secondary_handler.CurrentGrabHand == null) { AttachedWeapon.ActivePhysics(CurrentGrabHand, 2, 2); } else { AttachedWeapon.DisctivePhysics(secondary_handler.CurrentGrabHand); } hand_pose.SetActive(false); CurrentGrabHand.GetComponentInChildren <SkinnedMeshRenderer>().enabled = true; CurrentGrabHand = null; } }
public override void LocalGetDownButton(Hand hand) { base.LocalGetDownButton(hand); AttachedWeapon.DisctivePhysics(); AttachedWeapon.transform.SetParent(null); if (hand.m_controller == OVRInput.Controller.LTouch) { AttachedWeapon.transform.localScale = new Vector3(-1, 1, 1); rOffset = -rotationOffset; } else if (hand.m_controller == OVRInput.Controller.RTouch) { AttachedWeapon.transform.localScale = new Vector3(1, 1, 1); rOffset = rotationOffset; } }
public void TakeDamage(AttachedWeapon weapon, Vector3 hitPoint, Vector3 source, float damage, bool ignoreShields, bool ignoreArmor, bool ignoreArmorRating) { if (!ValidMoveOrder && Target == null) { SetNewTarget(weapon.GetParentUnit(), true); } Vector2 direction = new Vector2(source.x - transform.position.x, source.z - transform.position.z); if (inCloakingState()) { ignoreShields = true; } QuadrantTypes quadHit = GetQuadrantDirection(direction); if (!ignoreShields) { CheckShieldHit(hitPoint, quadHit); } shipData.TakeDamage(weapon, hitPoint, damage, quadHit, ignoreShields, ignoreArmor, ignoreArmorRating); }
public Vector3[] GetWeaponHardPoints(AttachedWeapon weapon) { return(hardPoints.GetRandomHardpoints(weapon.baseWeapon, weapon.GetFiringDirection())); }
protected override void UpdateChars(ref CharacteristicsSet applied) { AttachedWeapon.BarrelOffsetTl += AttachedWeapon.OffsetLocal(new Vec2(16, 0)); base.UpdateChars(ref applied); }
public void TakeDamage(AttachedWeapon weapon, float damage, bool ignoreShields, bool ignoreArmor, bool ignoreArmorRating) { if (weapon.baseWeapon.FighterDamageModifier != 1f) { damage *= weapon.baseWeapon.FighterDamageModifier; } if (!ignoreShields && ShieldHealth > 0) { float effectiveDamage; if (weapon.baseWeapon.ShieldDamageModifier != 1f) { effectiveDamage = damage * weapon.baseWeapon.ShieldDamageModifier; } else { effectiveDamage = damage; } if (effectiveDamage > 0) { float absorbDamage = effectiveDamage * Mathf.Clamp(ShieldRating / effectiveDamage, ResourceManager.instance.GetGameConstants().MinShieldAbsorb, 1f); float damageUseRatio; if (ShieldHealth > absorbDamage) { if (GameManager.instance.GetShowCombatDamage()) { CreateShieldDamagePopup(absorbDamage); } ShieldHealth -= absorbDamage; damageUseRatio = 1f - absorbDamage / effectiveDamage; } else { if (GameManager.instance.GetShowCombatDamage()) { CreateShieldDamagePopup(ShieldHealth); } damageUseRatio = 1f - ShieldHealth / effectiveDamage; ShieldHealth = 0; ShieldTimer = ShieldDelay; } damage *= damageUseRatio; } else { return; } } //Armor takes reduced damage based on armor rating if (!ignoreArmor && damage > 0 && ArmorHealth > 0) { float effectiveDamage; if (weapon.baseWeapon.ArmorDamageModifier != 1f) { effectiveDamage = damage * weapon.baseWeapon.ArmorDamageModifier; } else { effectiveDamage = damage; } if (effectiveDamage > 0) { if (!ignoreArmorRating && ArmorRating > 0) { float damageCoeff = Mathf.Min(0.99f, Mathf.Pow(damage / ArmorRating, 0.366f) * 0.5f); //float damageReduction = 1f - damageCoeff; effectiveDamage *= damageCoeff; } if (ArmorHealth > effectiveDamage) { ArmorHealth -= effectiveDamage; if (GameManager.instance.GetShowCombatDamage()) { CreateArmorDamagePopup(effectiveDamage); } return; } else { if (GameManager.instance.GetShowCombatDamage()) { CreateArmorDamagePopup(ArmorHealth); } float ratio = 1f - ArmorHealth / effectiveDamage; damage *= ratio; ArmorHealth = 0; } } else { return; } } //Apply remaining damage to health if (damage > 0) { if (weapon.baseWeapon.HealthDamageModifier != 1f) { damage *= weapon.baseWeapon.HealthDamageModifier; } if (GameManager.instance.GetShowCombatDamage()) { CreateHealthDamagePopup(damage); } Health -= damage; if (Health < 0) { Health = 0; Die(weapon); } } }
public void TakeDamage(AttachedWeapon weapon, Vector3 position, float damage, QuadrantTypes quad, bool ignoreShields, bool ignoreArmor, bool ignoreArmorRating) { //Apply defense bonus damage -= damage * GetDefenseBonus(); //Record damage taken damageTaken += damage; if (CurrentUnit == null) { return; } if (weapon.baseWeapon.PowerDamageModifier != 0) { power -= damage * weapon.baseWeapon.PowerDamageModifier; if (power < 0) { power = 0; } } if (weapon.baseWeapon.DamageAllQuads) { float ForeDamage = damage / 4f; float PortDamage = ForeDamage; float StarboardDamage = ForeDamage; float AftDamage = ForeDamage; if (!ignoreShields) { ForeDamage = CenterSection.TakeShieldDamage(weapon, position, ForeDamage); PortDamage = CenterSection.TakeShieldDamage(weapon, position, PortDamage); StarboardDamage = CenterSection.TakeShieldDamage(weapon, position, StarboardDamage); AftDamage = CenterSection.TakeShieldDamage(weapon, position, AftDamage); } if (!ForeSection.isDestroyed()) { ForeSection.TakeDamage(weapon, position, ForeDamage, ignoreShields, ignoreArmor, ignoreArmorRating); } else { CenterSection.TakeDamage(weapon, position, ForeDamage, ignoreShields, ignoreArmor, ignoreArmorRating); } if (!Destroyed) { if (!PortSection.isDestroyed()) { PortSection.TakeDamage(weapon, position, PortDamage, ignoreShields, ignoreArmor, ignoreArmorRating); } else { CenterSection.TakeDamage(weapon, position, PortDamage, ignoreShields, ignoreArmor, ignoreArmorRating); } } if (!Destroyed) { if (!StarboardSection.isDestroyed()) { StarboardSection.TakeDamage(weapon, position, StarboardDamage, ignoreShields, ignoreArmor, ignoreArmorRating); } else { CenterSection.TakeDamage(weapon, position, StarboardDamage, ignoreShields, ignoreArmor, ignoreArmorRating); } } if (!Destroyed) { if (!AftSection.isDestroyed()) { AftSection.TakeDamage(weapon, position, AftDamage, ignoreShields, ignoreArmor, ignoreArmorRating); } else { CenterSection.TakeDamage(weapon, position, AftDamage, ignoreShields, ignoreArmor, ignoreArmorRating); } } } else { //Center shield take damage first if (!ignoreShields) { damage = CenterSection.TakeShieldDamage(weapon, position, damage); } if (quad == QuadrantTypes.Fore && !ForeSection.isDestroyed()) { ForeSection.TakeDamage(weapon, position, damage, ignoreShields, ignoreArmor, ignoreArmorRating); } else if (quad == QuadrantTypes.Aft && !AftSection.isDestroyed()) { AftSection.TakeDamage(weapon, position, damage, ignoreShields, ignoreArmor, ignoreArmorRating); } else if (quad == QuadrantTypes.Port && !PortSection.isDestroyed()) { PortSection.TakeDamage(weapon, position, damage, ignoreShields, ignoreArmor, ignoreArmorRating); } else if (quad == QuadrantTypes.Starboard && !StarboardSection.isDestroyed()) { StarboardSection.TakeDamage(weapon, position, damage, ignoreShields, ignoreArmor, ignoreArmorRating); } else { CenterSection.TakeDamage(weapon, position, damage, ignoreShields, ignoreArmor, ignoreArmorRating); } } }
public void TakeDamage(AttachedWeapon weapon, Vector3 position, float damage, bool ignoreShields, bool ignoreArmor, bool ignoreArmorRating) { //Apply defense bonus damage -= damage * GetDefenseBonus(); //Record damage taken damageTaken += damage; if (CurrentUnit == null) { return; } if (weapon.baseWeapon.PowerDamageModifier != 0) { power -= damage * weapon.baseWeapon.PowerDamageModifier; if (power < 0) { power = 0; } } //shield absord damage if (!ignoreShields && damage > 0 && shieldHealth > 0 && shieldRating > 0) { float effectiveDamage; if (weapon.baseWeapon.ShieldDamageModifier != 1f) { effectiveDamage = damage * weapon.baseWeapon.ShieldDamageModifier; } else { effectiveDamage = damage; } if (effectiveDamage > 0) { float absorbDamage = effectiveDamage * Mathf.Clamp(shieldRating / effectiveDamage, ResourceManager.instance.GetGameConstants().MinShieldAbsorb, 1f); float damageUseRatio; if (shieldHealth > absorbDamage) { if (GameManager.instance.GetShowCombatDamage()) { CreateShieldDamagePopup(position, absorbDamage); } shieldHealth -= absorbDamage; damageUseRatio = 1f - absorbDamage / effectiveDamage; } else { if (GameManager.instance.GetShowCombatDamage()) { CreateShieldDamagePopup(position, shieldHealth); } damageUseRatio = 1f - shieldHealth / effectiveDamage; shieldHealth = 0; shieldTimer = shieldRechargeDelay; } damage *= damageUseRatio; } else { return; } } //Armor takes reduced damage based on armor rating if (!ignoreArmor && damage > 0 && armorHealth > 0) { float effectiveDamage; if (weapon.baseWeapon.ArmorDamageModifier != 1f) { effectiveDamage = damage * weapon.baseWeapon.ArmorDamageModifier; } else { effectiveDamage = damage; } if (effectiveDamage > 0) { if (!ignoreArmorRating && armorRating > 0) { float damageCoeff = Mathf.Min(0.99f, Mathf.Pow(effectiveDamage / armorRating, 0.366f) * 0.5f); //float damageReduction = 1f - damageCoeff; effectiveDamage *= damageCoeff; } if (armorHealth > effectiveDamage) { if (GameManager.instance.GetShowCombatDamage()) { CreateArmorDamagePopup(position, effectiveDamage); } armorHealth -= effectiveDamage; return; } else { if (GameManager.instance.GetShowCombatDamage()) { CreateArmorDamagePopup(position, armorHealth); } float ratio = 1f - armorHealth / effectiveDamage; damage *= ratio; armorHealth = 0; } } else { return; } } //Apply remaining damage to health if (damage > 0) { if (weapon.baseWeapon.HealthDamageModifier != 1f) { damage *= weapon.baseWeapon.HealthDamageModifier; } if (damage > 0) { DamageCrew(damage); if (GameManager.instance.GetShowCombatDamage()) { CreateHealthDamagePopup(position, damage); } health -= damage; if (health < 0) { health = 0; weapon.GetKill(CurrentUnit); (CurrentUnit as Station).Die(); } } } }
protected override void DrawAt(Vec2 pos) { AttachedWeapon.Draw(_sprite, pos); }
void Die(AttachedWeapon weapon, float damage, bool ignoreShields, bool ignoreArmor, bool ignoreArmorRating) { Destroyed = true; parentShip.QuadrantDestroyed(this, weapon, damage, ignoreShields, ignoreArmor, ignoreArmorRating); }
public void TakeDamage(AttachedWeapon weapon, Vector3 position, float damage, bool ignoreShields, bool ignoreArmor, bool ignoreArmorRating) { //shield absord damage if (!ignoreShields && damage > 0 && shieldHealth > 0 && shieldRating > 0) { float effectiveDamage; if (weapon.baseWeapon.ShieldDamageModifier != 1f) { effectiveDamage = damage * weapon.baseWeapon.ShieldDamageModifier; } else { effectiveDamage = damage; } if (effectiveDamage > 0) { float absorbDamage = effectiveDamage * Mathf.Clamp(shieldRating / effectiveDamage, ResourceManager.instance.GetGameConstants().MinShieldAbsorb, 1f); float damageUseRatio; if (shieldHealth > absorbDamage) { if (GameManager.instance.GetShowCombatDamage()) { parentShip.CreateShieldDamagePopup(position, absorbDamage); } shieldHealth -= absorbDamage; damageUseRatio = 1f - absorbDamage / effectiveDamage; } else { if (GameManager.instance.GetShowCombatDamage()) { parentShip.CreateShieldDamagePopup(position, shieldHealth); } damageUseRatio = 1f - shieldHealth / effectiveDamage; shieldHealth = 0; shieldTimer = shieldDelay; } damage *= damageUseRatio; } else { return; } } //Armor takes reduced damage based on armor rating if (!ignoreArmor && damage > 0 && armorHealth > 0) { float effectiveDamage; if (weapon.baseWeapon.ArmorDamageModifier != 1f) { effectiveDamage = damage * weapon.baseWeapon.ArmorDamageModifier; } else { effectiveDamage = damage; } if (effectiveDamage > 0) { if (!ignoreArmorRating && armorRating > 0) { float damageCoeff = Mathf.Min(0.99f, Mathf.Pow(effectiveDamage / armorRating, 0.366f) * 0.5f); effectiveDamage *= damageCoeff; } if (armorHealth > effectiveDamage) { if (GameManager.instance.GetShowCombatDamage()) { parentShip.CreateArmorDamagePopup(position, effectiveDamage); } armorHealth -= effectiveDamage; return; } else { if (GameManager.instance.GetShowCombatDamage()) { parentShip.CreateArmorDamagePopup(position, armorHealth); } float ratio = 1f - armorHealth / effectiveDamage; damage *= ratio; armorHealth = 0; } } else { return; } } //Apply remaining damage to health if (damage > 0) { if (weapon.baseWeapon.HealthDamageModifier != 1f) { damage *= weapon.baseWeapon.HealthDamageModifier; } if (damage > 0) { parentShip.DamageCrew(damage); if (GameManager.instance.GetShowCombatDamage()) { parentShip.CreateHealthDamagePopup(position, damage); } health -= damage; if (health < 0) { health = 0; Die(weapon, damage, ignoreShields, ignoreArmor, ignoreArmorRating); } } } }
public Vector3[] GetWeaponHardPoints(AttachedWeapon weapon, Vector2 Direct) { return(hardPoints.GetRandomHardpoints(weapon.baseWeapon, GetQuadrantDirection(Direct))); }