public void OnHit(DamagePackage pack) { if (damageManage) { damageManage.ApplyDamage((int)((float)pack.Damage * DamageMult), pack.Direction, pack.ID, pack.Team); } ParticleFX(pack.Position, pack.Normal); }
public override void OnHit(RaycastHit hit, AS_Bullet bullet) { float distance = Vector3.Distance(bullet.pointShoot, hit.point); if (damageManage) { int damage = (int)((float)bullet.Damage * DamageMult); damageManage.ApplyDamage(damage, bullet.transform.forward * bullet.HitForce, distance, Suffix); } AddAudio(hit.point); base.OnHit(hit, bullet); }
public override void OnHit(RaycastHit hit, AS_Bullet bullet) { AddAudio(hit.point); if (damageManage) { damageManage.ApplyDamage(bullet.Damage, bullet.transform.forward * bullet.HitForce, 0f); vp_DamageInfo info = new vp_DamageInfo(bullet.Damage, bullet.source, vp_DamageInfo.DamageType.Bullet); // SendMessageUpwards("OnMessage_HUDDamageFlash", info, SendMessageOptions.DontRequireReceiver); gameObject.BroadcastMessage("OnMessage_HUDDamageFlash", info, SendMessageOptions.DontRequireReceiver); } base.OnHit(hit, bullet); }
public void OnHit(DamagePackage pack) { if (DamageManage) { float damageReducer = 1; if (Armor != null) { ItemEquipment armor = Armor.GetEquipped(); if (armor != null) { damageReducer = 1 - armor.Armor; } } //造成伤害 float alldamage = (byte)((pack.Damage * DamageMult) * damageReducer); if (alldamage > byte.MaxValue) { alldamage = byte.MaxValue; } DamageManage.ApplyDamage((byte)alldamage, pack.Direction, pack.ID, pack.Team); //在十字准线中显示击中效果 if (UnitZ.gameManager != null && UnitZ.gameManager.PlayerNetID == pack.ID) { if (UnitZ.playerManager.PlayingCharacter != null && UnitZ.playerManager.PlayingCharacter.inventory != null) { if (UnitZ.playerManager.PlayingCharacter.inventory.FPSEquipment != null) { if (UnitZ.playerManager.PlayingCharacter.inventory.FPSEquipment.GetComponent <Crosshair>()) { UnitZ.playerManager.PlayingCharacter.inventory.FPSEquipment.GetComponent <Crosshair>().Hit(); } } } } } //击中位置添加粒子特效 ParticleFX(pack.Position, pack.Normal); }
void shootRay() { Vector3 direction = this.transform.forward; if (rigidBody) { direction = rigidBody.velocity.normalized; } RaycastHit hit; if (Physics.Raycast(this.transform.position, direction, out hit, 1000)) { if (hit.collider) { DamageManager damage = hit.collider.GetComponent <DamageManager> (); if (damage) { damage.ApplyDamage(10, rigidBody.velocity, null, Vector3.Distance(positionTmp, hit.point)); } Destroy(this.gameObject); if (hit.collider.CompareTag("Player")) { if (BodyHitFX) { GameObject fx = (GameObject)GameObject.Instantiate(BodyHitFX, hit.point, Quaternion.identity); fx.transform.forward = hit.normal; GameObject.Destroy(fx, 2); } } else { if (GroundHitFX) { GameObject fx = (GameObject)GameObject.Instantiate(GroundHitFX, hit.point, Quaternion.identity); fx.transform.forward = hit.normal; GameObject.Destroy(fx, 2); } } } } }