//////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> // /// </summary> private void OnParticleCollision(GameObject other) { // Does this particle belong to a weapon (used for damages) if (_WeaponAttached != null) { WorldObject worldObject = other.GetComponentInParent <WorldObject>(); int i = 0; int numCollisionEvents = _ParticleSystem.GetCollisionEvents(other, _CollisionEvents); while (i < numCollisionEvents) { // Valid world object? if (worldObject != null) { // Cant damage self if (worldObject == _WeaponAttached.GetUnitAttached()) { return; } DifficultyManager dm = DifficultyManager.Instance; DifficultyManager.EDifficultyModifiers mod = DifficultyManager.EDifficultyModifiers.Damage; WaveManager wm = WaveManager.Instance; // Damaging a unit? Unit unitObj = worldObject.GetComponent <Unit>(); if (unitObj != null) { // Friendly fire is OFF if (unitObj.Team != _WeaponAttached.GetUnitAttached().Team) { Unit unitA = _WeaponAttached.GetUnitAttached(); // Damage based on unit type switch (unitObj.UnitType) { case Unit.EUnitType.Undefined: { unitObj.Damage(((_WeaponAttached.Damages.DamageDefault * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.CoreMarine: { unitObj.Damage(((_WeaponAttached.Damages.DamageCoreInfantry * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.AntiInfantryMarine: { unitObj.Damage(((_WeaponAttached.Damages.DamageAntiInfantryMarine * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.Hero: { unitObj.Damage(((_WeaponAttached.Damages.DamageHero * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.CoreVehicle: { unitObj.Damage(((_WeaponAttached.Damages.DamageCoreVehicle * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.AntiAirVehicle: { unitObj.Damage(((_WeaponAttached.Damages.DamageAntiAirVehicle * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.MobileArtillery: { unitObj.Damage(((_WeaponAttached.Damages.DamageMobileArtillery * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.BattleTank: { unitObj.Damage(((_WeaponAttached.Damages.DamageBattleTank * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.CoreAirship: { unitObj.Damage(((_WeaponAttached.Damages.DamageCoreAirship * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.SupportShip: { unitObj.Damage(((_WeaponAttached.Damages.DamageSupportShip * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.HeavyAirship: { unitObj.Damage(((_WeaponAttached.Damages.DamageHeavyAirship * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } default: break; } } } // Damage the object (its not a unit so use the default damage value) else { worldObject.Damage((_WeaponAttached.Damages.DamageDefault * wm.GetWaveDamageModifier(worldObject)) * dm.GetDifficultyModifier(Unit.EUnitType.Undefined, worldObject.Team == GameManager.Team.Defending, mod)); } } i++; } _ParticleSystem.Stop(); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> // Fires a hitscan based projectile. /// </summary> private void ProjectileRaycast() { // Weapon is attached to a unit if (_UnitAttached != null) { RaycastHit hit; Vector3 attackPos = _UnitAttached.GetAttackTarget().transform.position; attackPos.y = attackPos.y + _UnitAttached.GetAttackTarget().GetObjectHeight() / 2; Vector3 attackDir = attackPos - _UnitAttached.MuzzleLaunchPoints[0].transform.position; attackDir.Normalize(); if (Physics.Raycast(_UnitAttached.MuzzleLaunchPoints[0].transform.position, attackDir, out hit, _UnitAttached.MaxAttackingRange)) { Debug.DrawLine(_UnitAttached.MuzzleLaunchPoints[0].transform.position, hit.point, Color.red); // Damage target WorldObject worldObj = hit.transform.GetComponentInParent <WorldObject>(); if (hit.transform.gameObject.layer == LayerMask.NameToLayer("Ignore Raycast")) { return; } else if (worldObj != null) { DifficultyManager dm = DifficultyManager.Instance; DifficultyManager.EDifficultyModifiers mod = DifficultyManager.EDifficultyModifiers.Damage; WaveManager wm = WaveManager.Instance; // Check if object is of type unit Unit unitObj = worldObj.GetComponent <Unit>(); if (unitObj != null) { // Cannot damage self if (unitObj.Team != _UnitAttached.Team) { // Damage based on unit type switch (unitObj.UnitType) { case Unit.EUnitType.Undefined: { unitObj.Damage(((Damages.DamageDefault * _UnitAttached.VetDamages[_UnitAttached.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _UnitAttached); break; } case Unit.EUnitType.CoreMarine: { unitObj.Damage(((Damages.DamageCoreInfantry * _UnitAttached.VetDamages[_UnitAttached.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _UnitAttached); break; } case Unit.EUnitType.AntiInfantryMarine: { unitObj.Damage(((Damages.DamageAntiInfantryMarine * _UnitAttached.VetDamages[_UnitAttached.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _UnitAttached); break; } case Unit.EUnitType.Hero: { unitObj.Damage(((Damages.DamageHero * _UnitAttached.VetDamages[_UnitAttached.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _UnitAttached); break; } case Unit.EUnitType.CoreVehicle: { unitObj.Damage(((Damages.DamageCoreVehicle * _UnitAttached.VetDamages[_UnitAttached.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _UnitAttached); break; } case Unit.EUnitType.AntiAirVehicle: { unitObj.Damage(((Damages.DamageAntiAirVehicle * _UnitAttached.VetDamages[_UnitAttached.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _UnitAttached); break; } case Unit.EUnitType.MobileArtillery: { unitObj.Damage(((Damages.DamageMobileArtillery * _UnitAttached.VetDamages[_UnitAttached.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _UnitAttached); break; } case Unit.EUnitType.BattleTank: { unitObj.Damage(((Damages.DamageBattleTank * _UnitAttached.VetDamages[_UnitAttached.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _UnitAttached); break; } case Unit.EUnitType.CoreAirship: { unitObj.Damage(((Damages.DamageCoreAirship * _UnitAttached.VetDamages[_UnitAttached.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _UnitAttached); break; } case Unit.EUnitType.SupportShip: { unitObj.Damage(((Damages.DamageSupportShip * _UnitAttached.VetDamages[_UnitAttached.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _UnitAttached); break; } case Unit.EUnitType.HeavyAirship: { unitObj.Damage(((Damages.DamageHeavyAirship * _UnitAttached.VetDamages[_UnitAttached.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _UnitAttached); break; } default: break; } } } // Damage the object (its not a unit so use the default damage value) else { worldObj.Damage((Damages.DamageDefault * wm.GetWaveDamageModifier(worldObj)) * dm.GetDifficultyModifier(Unit.EUnitType.Undefined, worldObj.Team == GameManager.Team.Defending, mod), _UnitAttached); } } } } // Weapon is attached to a tower if (_TowerAttached != null) { RaycastHit hit; Vector3 attackPos = _TowerAttached.GetAttackTarget().transform.position; attackPos.y = attackPos.y + _TowerAttached.GetAttackTarget().GetObjectHeight() / 2; Vector3 attackDir = attackPos - _TowerAttached.MuzzleLaunchPoints[0].transform.position; attackDir.Normalize(); if (Physics.Raycast(_TowerAttached.MuzzleLaunchPoints[0].transform.position, attackDir, out hit, _TowerAttached.MaxAttackingRange)) { Debug.DrawLine(_TowerAttached.MuzzleLaunchPoints[0].transform.position, hit.point, Color.red); // Damage target WorldObject worldObj = hit.transform.GetComponentInParent <WorldObject>(); if (hit.transform.gameObject.layer == LayerMask.NameToLayer("Ignore Raycast")) { return; } else if (worldObj != null) { DifficultyManager dm = DifficultyManager.Instance; DifficultyManager.EDifficultyModifiers mod = DifficultyManager.EDifficultyModifiers.Damage; WaveManager wm = WaveManager.Instance; // Check if object is of type unit Unit unitObj = worldObj.GetComponent <Unit>(); if (unitObj != null) { // Cannot damage self if (unitObj.Team != _TowerAttached.Team) { // Damage based on unit type switch (unitObj.UnitType) { case Unit.EUnitType.Undefined: { unitObj.Damage((Damages.DamageDefault * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _TowerAttached); break; } case Unit.EUnitType.CoreMarine: { unitObj.Damage((Damages.DamageCoreInfantry * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _TowerAttached); break; } case Unit.EUnitType.AntiInfantryMarine: { unitObj.Damage((Damages.DamageAntiInfantryMarine * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _TowerAttached); break; } case Unit.EUnitType.Hero: { unitObj.Damage((Damages.DamageHero * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _TowerAttached); break; } case Unit.EUnitType.CoreVehicle: { unitObj.Damage((Damages.DamageCoreVehicle * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _TowerAttached); break; } case Unit.EUnitType.AntiAirVehicle: { unitObj.Damage((Damages.DamageAntiAirVehicle * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _TowerAttached); break; } case Unit.EUnitType.MobileArtillery: { unitObj.Damage((Damages.DamageMobileArtillery * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _TowerAttached); break; } case Unit.EUnitType.BattleTank: { unitObj.Damage((Damages.DamageBattleTank * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _TowerAttached); break; } case Unit.EUnitType.CoreAirship: { unitObj.Damage((Damages.DamageCoreAirship * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _TowerAttached); break; } case Unit.EUnitType.SupportShip: { unitObj.Damage((Damages.DamageSupportShip * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _TowerAttached); break; } case Unit.EUnitType.HeavyAirship: { unitObj.Damage((Damages.DamageHeavyAirship * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _TowerAttached); break; } default: break; } } } // Damage the object (its not a unit so use the default damage value) else { worldObj.Damage((Damages.DamageDefault * wm.GetWaveDamageModifier(worldObj)) * dm.GetDifficultyModifier(Unit.EUnitType.Undefined, worldObj.Team == GameManager.Team.Defending, mod), _TowerAttached); } } } } // Weapon is attached to a gunner seat if (_GunnerAttached != null) { RaycastHit hit; Vector3 attackPos = _GunnerAttached.GetAttackTarget().transform.position; attackPos.y = attackPos.y + _GunnerAttached.GetAttackTarget().GetObjectHeight() / 2; Vector3 attackDir = attackPos - _GunnerAttached.MuzzleLaunchPoints[0].transform.position; attackDir.Normalize(); if (Physics.Raycast(_GunnerAttached.MuzzleLaunchPoints[0].transform.position, attackDir, out hit, _GunnerAttached.MaxAttackRange)) { Debug.DrawLine(_GunnerAttached.MuzzleLaunchPoints[0].transform.position, hit.point, Color.red); // Damage target WorldObject worldObj = hit.transform.GetComponentInParent <WorldObject>(); if (hit.transform.gameObject.layer == LayerMask.NameToLayer("Ignore Raycast")) { return; } else if (worldObj != null) { DifficultyManager dm = DifficultyManager.Instance; DifficultyManager.EDifficultyModifiers mod = DifficultyManager.EDifficultyModifiers.Damage; WaveManager wm = WaveManager.Instance; // Check if object is of type unit Unit unitObj = worldObj.GetComponent <Unit>(); if (unitObj != null) { // Cannot damage self if (unitObj.Team != _GunnerAttached._VehicleAttached.Team) { Vehicle vehicleA = _GunnerAttached._VehicleAttached; // Damage based on unit type switch (unitObj.UnitType) { case Unit.EUnitType.Undefined: { unitObj.Damage(((Damages.DamageDefault * vehicleA.VetDamages[vehicleA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), vehicleA); break; } case Unit.EUnitType.CoreMarine: { unitObj.Damage(((Damages.DamageCoreInfantry * vehicleA.VetDamages[vehicleA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), vehicleA); break; } case Unit.EUnitType.AntiInfantryMarine: { unitObj.Damage(((Damages.DamageAntiInfantryMarine * vehicleA.VetDamages[vehicleA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), vehicleA); break; } case Unit.EUnitType.Hero: { unitObj.Damage(((Damages.DamageHero * vehicleA.VetDamages[vehicleA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), vehicleA); break; } case Unit.EUnitType.CoreVehicle: { unitObj.Damage(((Damages.DamageCoreVehicle * vehicleA.VetDamages[vehicleA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), vehicleA); break; } case Unit.EUnitType.AntiAirVehicle: { unitObj.Damage(((Damages.DamageAntiAirVehicle * vehicleA.VetDamages[vehicleA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), vehicleA); break; } case Unit.EUnitType.MobileArtillery: { unitObj.Damage(((Damages.DamageMobileArtillery * vehicleA.VetDamages[vehicleA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), vehicleA); break; } case Unit.EUnitType.BattleTank: { unitObj.Damage(((Damages.DamageBattleTank * vehicleA.VetDamages[vehicleA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), vehicleA); break; } case Unit.EUnitType.CoreAirship: { unitObj.Damage(((Damages.DamageCoreAirship * vehicleA.VetDamages[vehicleA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), vehicleA); break; } case Unit.EUnitType.SupportShip: { unitObj.Damage(((Damages.DamageSupportShip * vehicleA.VetDamages[vehicleA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), vehicleA); break; } case Unit.EUnitType.HeavyAirship: { unitObj.Damage(((Damages.DamageHeavyAirship * vehicleA.VetDamages[vehicleA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), vehicleA); break; } default: break; } } } // Damage the object (its not a unit so use the default damage value) else { worldObj.Damage((Damages.DamageDefault * wm.GetWaveDamageModifier(worldObj)) * dm.GetDifficultyModifier(Unit.EUnitType.Undefined, worldObj.Team == GameManager.Team.Defending, mod), _GunnerAttached._VehicleAttached); } } } } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> // When the trigger overlaps another collider (entry only) /// </summary> /// <param name="other"></param> protected void OnTriggerEnter(Collider other) { // Check for terrain collision if (other.gameObject.CompareTag("Ground")) { OnDestroy(); } // Get object type GameObject gameObj = other.gameObject; WorldObject worldObj = gameObj.GetComponentInParent <WorldObject>(); ///if (gameObj.layer == LayerMask.NameToLayer("Ignore Raycast")) { return; } // Successful WorldObject cast if (worldObj != null) { DifficultyManager dm = DifficultyManager.Instance; DifficultyManager.EDifficultyModifiers mod = DifficultyManager.EDifficultyModifiers.Damage; WaveManager wm = WaveManager.Instance; // Check if object is of type unit Unit unitObj = worldObj.GetComponent <Unit>(); if (unitObj != null) { if (_WeaponAttached != null) { // Does this projectile belong to a unit? if (_WeaponAttached.GetUnitAttached() != null) { // Cant damage self if (worldObj == _WeaponAttached.GetUnitAttached()) { return; } // Friendly fire is OFF if (unitObj.Team != _WeaponAttached.GetUnitAttached().Team) { Unit unitA = _WeaponAttached.GetUnitAttached(); // Damage based on unit type switch (unitObj.UnitType) { case Unit.EUnitType.Undefined: { unitObj.Damage(((_Damages.DamageDefault * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.DwfSoldier: { unitObj.Damage(((_Damages.DamageCoreInfantry * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.DwfSpecialistInfantry: { unitObj.Damage(((_Damages.DamageAntiInfantryMarine * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.DwfSpecialistVehicle: { unitObj.Damage(((_Damages.DamageHero * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.Grumblebuster: { unitObj.Damage(((_Damages.DamageCoreVehicle * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.Skylancer: { unitObj.Damage(((_Damages.DamageAntiAirVehicle * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.Catapult: { unitObj.Damage(((_Damages.DamageMobileArtillery * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.SiegeEngine: { unitObj.Damage(((_Damages.DamageBattleTank * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.LightAirship: { unitObj.Damage(((_Damages.DamageCoreAirship * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.SupportShip: { unitObj.Damage(((_Damages.DamageSupportShip * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } case Unit.EUnitType.HeavyAirship: { unitObj.Damage(((_Damages.DamageHeavyAirship * unitA.VetDamages[unitA.GetVeterancyLevel()]) * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), unitA); break; } default: break; } } } // Does this projectile belong to a tower? if (_WeaponAttached.GetTowerAttached() != null) { // Cant damage self if (worldObj == _WeaponAttached.GetTowerAttached()) { return; } // Friendly fire is OFF if (unitObj.Team != _WeaponAttached.GetTowerAttached().Team) { // Damage based on unit type switch (unitObj.UnitType) { case Unit.EUnitType.Undefined: { unitObj.Damage((_Damages.DamageDefault * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _WeaponAttached.GetTowerAttached()); break; } case Unit.EUnitType.DwfSoldier: { unitObj.Damage((_Damages.DamageCoreInfantry * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _WeaponAttached.GetTowerAttached()); break; } case Unit.EUnitType.DwfSpecialistInfantry: { unitObj.Damage((_Damages.DamageAntiInfantryMarine * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _WeaponAttached.GetTowerAttached()); break; } case Unit.EUnitType.DwfSpecialistVehicle: { unitObj.Damage((_Damages.DamageHero * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _WeaponAttached.GetTowerAttached()); break; } case Unit.EUnitType.Grumblebuster: { unitObj.Damage((_Damages.DamageCoreVehicle * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _WeaponAttached.GetTowerAttached()); break; } case Unit.EUnitType.Skylancer: { unitObj.Damage((_Damages.DamageAntiAirVehicle * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _WeaponAttached.GetTowerAttached()); break; } case Unit.EUnitType.Catapult: { unitObj.Damage((_Damages.DamageMobileArtillery * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _WeaponAttached.GetTowerAttached()); break; } case Unit.EUnitType.SiegeEngine: { unitObj.Damage((_Damages.DamageBattleTank * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _WeaponAttached.GetTowerAttached()); break; } case Unit.EUnitType.LightAirship: { unitObj.Damage((_Damages.DamageCoreAirship * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _WeaponAttached.GetTowerAttached()); break; } case Unit.EUnitType.SupportShip: { unitObj.Damage((_Damages.DamageSupportShip * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _WeaponAttached.GetTowerAttached()); break; } case Unit.EUnitType.HeavyAirship: { unitObj.Damage((_Damages.DamageHeavyAirship * wm.GetWaveDamageModifier(unitObj)) * dm.GetDifficultyModifier(unitObj, mod), _WeaponAttached.GetTowerAttached()); break; } default: break; } } } } // Destroy projectile OnDestroy(); } // Damage the world object else { // Destroy projectile worldObj.Damage((_Damages.DamageDefault * wm.GetWaveDamageModifier(worldObj)) * dm.GetDifficultyModifier(Unit.EUnitType.Undefined, worldObj.Team == GameManager.Team.Defending, mod)); OnDestroy(); } } }