public override GameObject FireAmmo(IDamager damager, Ray damageRay, LayerMask layerMask, float damageMultiplier) { Shrapnel spear = Shrapnel.pool.GetPrefabInstance(prefab); System.Action <PhysicsHit> onHitReach = (physicsHit) => { if (physicsHit != null) { Damageable damageable = physicsHit.mainCollider.GetComponent <Damageable>(); if (damageable) { damageable.SendDamage(new DamageMessage(damager, baseDamage * damageMultiplier, 0)); } } }; PhysicsHit hit = spear.Launch(velocity, damageRay, maxDistance, radiusCheck, layerMask, lifeTime, hitObjectVelocityMultiplier, simulateArc, onHitReach); // if (hit != null) { // Damageable damageable = hit.mainCollider.GetComponent<Damageable>(); // if (damageable) { // damageable.SendDamage(new DamageMessage(damager, baseDamage * damageMultiplier)); // } // } return(spear.gameObject); }
public override GameObject FireAmmo(IDamager damager, Ray damageRay, LayerMask layerMask, float damageMultiplier) { Impaler impaler = Impaler.pool.GetPrefabInstance(impalerPrefab); System.Action <PhysicsHit> onHitReach = (physicsHit) => { }; List <PhysicsHit> hits = impaler.ShootImpaler(velocity, hitObjectVelocityMultiplier, zMovementLimit, damageRay, maxDistance, layerMask, impalerRadius, kinematicOnReach, useColliderOnReach, lifeTime, onHitReach); for (int i = 0; i < hits.Count; i++) { Damageable damageable = hits[i].hitElements[0].rigidbody.GetComponent <Damageable>(); if (damageable) { damageable.SendDamage(new DamageMessage(damager, baseDamage * damageMultiplier, 0)); } } return(impaler.gameObject); }
IEnumerator ShootBullet(Game.Combat.IDamager damager, Ray damageRay, LayerMask layerMask, float damageMultiplier) { yield return(new WaitForFixedUpdate()); RaycastHit hit; if (Physics.Raycast(damageRay, out hit, maxDistance, layerMask, QueryTriggerInteraction.Ignore)) { Damageable damageable = hit.transform.GetComponent <Damageable>(); if (damageable) { damageable.SendDamage(new DamageMessage(damager, baseDamage * damageMultiplier, severity)); } Rigidbody rb = hit.transform.GetComponent <Rigidbody>(); if (rb) { rb.AddForceAtPosition(damageRay.direction.normalized * force, hit.point, ForceMode.VelocityChange); } } }
public override GameObject FireAmmo(IDamager damager, Ray damageRay, LayerMask layerMask, float damageMultiplier) { Spear spear = Spear.pool.GetPrefabInstance(spearPrefab); System.Action <PhysicsHit, bool> onHitReach = (physicsHit, isImpaled) => { }; List <PhysicsHit> hits = spear.ShootSpear(velocity, damageRay, maxDistance, layerMask, lifeTime, skewerSeperation, minSpaceFromWall, skeweredVelocityMultiplier, onHitReach); for (int i = 0; i < hits.Count; i++) { Damageable damageable = hits[i].hitElements[0].rigidbody.GetComponent <Damageable>(); if (damageable) { damageable.SendDamage(new DamageMessage(damager, baseDamage * damageMultiplier, 0)); } } return(spear.gameObject); }