Beispiel #1
0
    //up = true, down = false
    void ThrusterFill(bool direction)
    {
        _thrusterFill.fillAmount = 1.0f - (_player._currentThruster / _player.getMaxThruster());
        thrusterShaker.ChangeFrequencies(maxThrusterFreq * (1f - _thrusterFill.fillAmount));

        //if we hit 0...we are on cooldown mode...call on an IEnumerator
        if (_thrusterFill.fillAmount == 0.0f)
        {
            _isThrusterCooldown = true;
            StartCoroutine(_overHeatBlink);
        }

        if (direction)
        {
            thrusterShaker.Shake(0.1f);
        }


        //when we reach back to 1... we out of cooldown mode...stop the IEnumerator
        if (_isThrusterCooldown && _thrusterFill.fillAmount == 1.0f)
        {
            _isThrusterCooldown = false;
            StopCoroutine(_overHeatBlink);
            _overheatText.gameObject.SetActive(false);
            thrusterShaker.ChangeFrequencies(0);
        }
    }
Beispiel #2
0
 void HealthUpdate(int health)
 {
     //if took damage
     if (health < _lifeBar.childCount + 1)
     {
         deckShaker.Shake(1f);
         Camera.main.GetComponent <CameraShaker>().Shake(1f); //optimize this
         if (health == 0)
         {
             StopCoroutine(_dangerBlink);
             _dangerText.gameObject.SetActive(false);
             return;
         }
         Destroy(_lifeBar.GetChild(_lifeBar.childCount - 1).gameObject);
         //if(_lifeBar.childCount == 0){
         if (health == 1)
         {
             Debug.Log("no more children...starting corrotuine");
             StartCoroutine(_dangerBlink);
         }
     }
     else
     {
         //recovered health
         if (_lifeBar.childCount == 0)
         {
             StopCoroutine(_dangerBlink);
             _dangerText.gameObject.SetActive(false);
         }
         GameObject temp = Instantiate(_healthBarUIPrefab);
         temp.transform.parent = _lifeBar;
         //temp.transform.SetSiblingIndex(_lifeBar.childCount-1);
     }
 }
    IEnumerator RunShaker()
    {
        UIShaker shaker = GameObject.FindObjectOfType <UIShaker> ();

        while (true)
        {
            shaker.Shake(2.0f, Random.Range(1.0f, 10.0f));
            yield return(new WaitForSeconds(3.0f));
        }
    }
Beispiel #4
0
 void AmmoDequeueUpdate(bool critical)
 {
     Destroy(_ammoBar.GetChild(0).gameObject);
     //Destroy(_ammoBar.GetChild(_ammoBar.childCount-1).gameObject);
     if (critical)
     {
         //do some animation thingy. do that thing that keeps it alive until animation done
         ammoBarShaker.Shake(1f);
     }
 }