Example #1
0
 public void MainAttack()
 {
     if (maxAmmo != 0 && curAmmo <= 0)
     {
         Reload();
         return;
     }
     if (toNextShot <= 0)
     {
         if (weaponType == WeaponType.Range)
         {
             GameObject bull = Instantiate(bullet);
             bull.transform.position = spawnBulletPosition.position;
             bull.GetComponent <ProjectileAttack>().precision = precision;
             bull.GetComponent <ProjectileAttack>().Launch(GetComponentInParent <Camera>());
             Destroy(bull, 5);
             curAmmo--;
         }
         if (weaponType == WeaponType.ThrowingLeft && isAiming)
         {
             GameObject spear = GameObject.Instantiate(bullet);
             spear.transform.position = spawnBulletPosition.position;
             spear.GetComponent <ProjectileAttack>().precision = precision;
             spear.GetComponent <ProjectileAttack>().Launch(GetComponentInParent <Camera>());
             Destroy(gameObject);
         }
         else
         {
             weaponHandler.MainAttack();
         }
         toNextShot += delayBetweenShoots;
     }
 }