public override float getAmmoPercentage()
    {
        if (primaryReloadTimer != null)
        {
            if (primaryReloadTimer.isTimeout())
            {
                int ammoRequired = maxActiveAmmo - activeAmmo;
                if (reserveAmmo >= ammoRequired)
                {
                    activeAmmo  += ammoRequired;
                    reserveAmmo -= ammoRequired;
                }
                else
                {
                    activeAmmo += reserveAmmo;
                    reserveAmmo = 0;
                }
                primaryReloadTimer = null;
            }
            else
            {
                return(primaryReloadTimer.getDisplayResetPercent());
            }
        }
        if (maxActiveAmmo == 0)
        {
            return(primaryReloadTimer?.getDisplayResetPercent() ?? 1);
        }

        return(activeAmmo / (maxActiveAmmo * 1.0f));
    }
Exemple #2
0
 // Update is called once per frame
 void Update()
 {
     if (timer != null && timer.isTimeout())
     {
         Destroy(gameObject);
     }
 }
Exemple #3
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (killTimer.isTimeout())
     {
         Destroy(gameObject);
     }
 }
Exemple #4
0
 private void Update()
 {
     if (timer.isTimeout())
     {
         weapon.usePrimaryActionDown();
     }
     else
     {
         weapon.usePrimaryActionUp();
     }
 }
    private bool canSecondaryFire()
    {
        if (!secondaryResetTimer.isTimeout())
        {
            return(false);
        }
        if (!secondaryAutomaticFire && fired)
        {
            return(false);
        }

        fired = true;
        return(true);
    }
    private bool canPrimaryFire()
    {
        if (!primaryResetTimer.isTimeout())
        {
            return(false);
        }
        if (!primaryAutomaticFire && fired)
        {
            return(false);
        }
        fired = true;
        if (!infiniteAmmo && activeAmmo <= 0)
        {
            return(false);
        }

        return(true);
    }
 /**
  * Update is called once per frame
  */
 void Update()
 {
     if (!started)
     {
         return;
     }
     if (lifeTimer != null && lifeTimer.isTimeout())
     {
         endEffect(END_EFFECT_TIME_OUT);
     }
     if (!effectEnded && tick())
     {
         if (manager.stateChanged)
         {
             compareState();
         }
         affectObject();
     }
 }
    private void FixedUpdate()
    {
        if (timer == null)
        {
            return;
        }
        waveText.text = "Next wave: " + (int)(timer.getTimeLeft());
        if (timer.isTimeout())
        {
            waveText.text = "Wave: " + waveNo;
            noDeaths      = 0;
            timer         = null;

            numberSpawned += waveNo + waveNo / 2;
            numberSpawned  = (numberSpawned / spawners.Length);
            numberSpawned *= spawners.Length;
            foreach (var spawner in spawners)
            {
                spawner.spawnObjects(numberSpawned / spawners.Length, objects);
            }
        }
    }
 /**
  * Checks if a tick must occur. If tickTimer is null returns true for continuous affect.
  */
 private bool tick()
 {
     return(tickTimer == null || tickTimer.isTimeout());
 }