public void DealDamage(HitReciever hitReciever, Vector3 hitPos, Bullet Bullet) { if (hitReciever != null) { int trueDamage = hitReciever.RecieveHit(Bullet.damageTemp); } }
private void HitScanShoot(Bullet Bullet, Character character) { int layerMask = 1 << 10; layerMask = ~layerMask; Vector3 dir = GetShootDir(); RaycastHit hit; if (Physics.Raycast(bulletSpawnTransform.position, dir, out hit, 100f, layerMask)) { GameObject hitObj = hit.collider.gameObject; HitReciever hitReciever = hitObj.GetComponent <HitReciever>(); //简化为发射射线 character.hitSender.DealDamage(hitReciever, hit.point, Bullet); HitFeedBack hitFeedBack = hitObj.GetComponent <HitFeedBack>(); if (hitFeedBack != null) { hitFeedBack.Reflect(hit.point, Quaternion.LookRotation(Vector3.Lerp(hit.normal, -dir, 0.7f))); } } }