private void Start()
 {
     shootSource = GetComponent <AudioSource>();
     mainCam     = Camera.main;
     ammoCounter = FindObjectOfType <AmmoCounter>();
     ammoCounter.ChangeAmmoCount(Data.WeaponType, 0, false);
     OnEnable();
 }
示例#2
0
 public override void Pickup()
 {
     if (ammoCounter.CanAdd(WeaponType))
     {
         ammoCounter.ChangeAmmoCount(WeaponType, AmmoCount, false);
         PlaySound();
         Destroy(gameObject);
     }
 }
 private void RayCastShooting(int bulletCount, int shootCost, float damage, Vector2 dispersion, GameObject decal, AudioClip shootClip)
 {
     for (int i = 0; i < bulletCount; i++)
     {
         Vector3    rayOrigin    = mainCam.ViewportToWorldPoint(new Vector2(0.5f, 0.5f));
         Vector3    rayDirection = GetDirection(dispersion);
         RaycastHit shootHit     = new RaycastHit();
         if (Physics.Raycast(rayOrigin, rayDirection, out shootHit, 100f, ~(1 << 8)))
         {
             HitboxComponent tempHitbox = shootHit.collider.GetComponent <HitboxComponent>();
             if (tempHitbox != null)
             {
                 tempHitbox.ApllyDamage(damage);
             }
             else
             {
                 Instantiate(decal, shootHit.point + shootHit.normal * 0.001f, Quaternion.FromToRotation(Vector3.forward, shootHit.normal));
             }
         }
     }
     ammoCounter.ChangeAmmoCount(Data.WeaponType, -shootCost);
 }
 public override void Pickup()
 {
     weaponChanger.AddWeapon(WeaponIndex, PlayerWeaponInstance);
     ammoCounter.ChangeAmmoCount(WeaponType, AdditionalAmmo);
     Destroy(gameObject);
 }