コード例 #1
0
    internal void BulletHit(Collider hitObject, Vector3 bulletForward)
    {
        if (hitObject == null)
        {
            return;
        }

        BodyPart hitBodyPart = hitObject.GetComponent <BodyPart>();

        if (hitBodyPart != null && this.shooter != null)
        {
            bool isPlayerWeapon = this.shooter.CompareTag("Player");
            if (LogicUtils.CanBeHitByBullet(hitBodyPart, isPlayerWeapon))
            {
                hitBodyPart.TakeDamage(-this.damagePerBullet, this);
            }
        }
        else
        {
            BaseEntity hitEntity = hitObject.GetComponent <BaseEntity>();
            if (hitEntity)
            {
                bool isPlayerWeapon = this.shooter.CompareTag("Player");
                if (LogicUtils.CanBeHitByBullet(hitEntity, isPlayerWeapon))
                {
                    hitEntity.ChangeHealth(-this.damagePerBullet, this);
                }
            }
        }
    }
コード例 #2
0
 private void OnTriggerEnter(Collider other)
 {
     if (LogicUtils.IsShootable(other) == false || LogicUtils.CanBeHitByBullet(other, _isPlayerWeapon) == false)
     {
         return;
     }
     this.BulletHitSomething(other, shootLocation);
 }