Example #1
0
 public void ShowOutOfAmmo()
 {
     if (_canFlashAmmoText)
     {
         CanFlash handler = CanFlashAmmo;
         StartCoroutine(FlashText(_ammoText, handler, RedText, 3));
     }
 }
Example #2
0
 public void UpdateAmmo(int newAmmo)
 {
     if (_canFlashAmmoText && newAmmo > _currentAmmo)
     {
         CanFlash handler = CanFlashAmmo;
         StartCoroutine(FlashText(_ammoText, handler, GreenText));
     }
     _currentAmmo   = newAmmo;
     _ammoText.text = "Ammo: " + _currentAmmo;
 }
Example #3
0
    IEnumerator OverHeatRoutine()
    {
        while (_overHeat)
        {
            if (_canFlashEngineOverHeatText)
            {
                CanFlash handler = CanFlashOverHeat;
                StartCoroutine(FlashText(_engineOverHeatText, handler, RedText));
            }

            yield return(new WaitForSeconds(_textFlashOnDelay + _textFlashBetweenDelay + 0.01f)); // total runtime of FlashText plus a small buffer
        }
    }
Example #4
0
    public void UpdateScore(int newScore)
    {
        if (_canFlashScoreText && newScore != _currentScore)
        {
            Color color;
            if (newScore > _currentScore)
            {
                color = GreenText;
            }
            else
            {
                color = RedText;
            }

            CanFlash handler = CanFlashScore;
            StartCoroutine(FlashText(_scoreText, handler, color));
        }
        _currentScore   = newScore;
        _scoreText.text = "Score: " + _currentScore;
    }
Example #5
0
    IEnumerator FlashText(Text text, CanFlash canFlash, Color flashColor, int count = 1)
    {
        canFlash(false);

        Color originalColor = text.color;

        while (count > 0)
        {
            count--;
            text.color = flashColor;

            yield return(new WaitForSeconds(_textFlashOnDelay));

            text.color = originalColor;

            yield return(new WaitForSeconds(_textFlashBetweenDelay));
        }

        canFlash(true);
    }