Esempio n. 1
0
 // This method is equivalent to have the trigger pressed.
 public void PressTriger()
 {
     #if UNITY_EDITOR
     Assert.IsNotNull(gunControllerDelegate);
     if (gunControllerDelegate == null)
     {
         return;
     }
     #endif
     if (firing == GUN_MODE.IDLE)
     {
         if (currentMagsize > 0)
         {
             if (projectileOrigins.Count > 0)
             {
                 gunControllerDelegate.OnShootProjectile(projectileOrigins[originCounter++]);
                 if (originCounter >= projectileOrigins.Count)
                 {
                     originCounter = 0;
                 }
             }
             else
             {
                 gunControllerDelegate.OnShootProjectile(Vector3.zero);
             }
             firing = GUN_MODE.FIRING;
             currentMagsize--;
         }
         else
         {
             gunControllerDelegate.OnStartReloading();
             firing = GUN_MODE.RELOADING;
         }
         counter = 0f;
     }
     else
     {
         if (firing != GUN_MODE.IDLE)
         {
             // We can use this spot to play some sound, you
             // are pressing the trigger but the gun is doing
             // something right now, maybe firing or reloading
         }
     }
 }
Esempio n. 2
0
    // This method is equivalent to have the trigger pressed.
    public void PressTriger()
    {
#if UNITY_EDITOR
        Assert.IsNotNull(gunControllerDelegate);
        if (gunControllerDelegate == null)
        {
            return;
        }
#endif
        if (firing == GUN_MODE.IDLE)
        {
            if (currentMagsize > 0)
            {
                if (projectileOrigins.Count > 0)
                {
                    gunControllerDelegate.OnShootProjectile(projectileOrigins[originCounter++]);
                    if (originCounter >= projectileOrigins.Count)
                    {
                        originCounter = 0;
                    }
                }
                else
                {
                    gunControllerDelegate.OnShootProjectile(Vector3.zero);
                }
                firing = GUN_MODE.FIRING;
                currentMagsize--;
            }
            else
            {
                gunControllerDelegate.OnStartReloading();
                firing = GUN_MODE.RELOADING;
            }
            counter = 0f;
        }
        else
        {
            if (firing != GUN_MODE.IDLE)
            {
                // We can use this spot to play some sound, you
                // are pressing the trigger but the gun is doing
                // something right now, maybe firing or reloading
            }
        }
    }
Esempio n. 3
0
 // Update is called once per frame
 void Update()
 {
     counter += Time.deltaTime;
     if (firing == GUN_MODE.FIRING)
     {
         if (counter >= rechamberTime)
         {
             counter = 0f;
             firing  = GUN_MODE.IDLE;
         }
     }
     else if (firing == GUN_MODE.RELOADING)
     {
         if (counter >= reloadTime)
         {
             counter             = 0f;
             firing              = GUN_MODE.IDLE;
             currentMagsize      = defaultMagSize;
             currentReserveSize -= defaultMagSize;
         }
     }
 }
Esempio n. 4
0
 // Update is called once per frame
 void Update()
 {
     counter += Time.deltaTime;
     if (firing == GUN_MODE.FIRING)
     {
         if (counter >= rechamberTime)
         {
             counter = 0f;
             firing = GUN_MODE.IDLE;
         }
     }
     else if (firing == GUN_MODE.RELOADING)
     {
         if (counter >= reloadTime)
         {
             counter = 0f;
             firing = GUN_MODE.IDLE;
             currentMagsize = defaultMagSize;
             currentReserveSize -= defaultMagSize;
         }
     }
 }