Example #1
0
 private void EmergencyCase()
 {
     Explode += () => CrashStatus = true;
     if (Explode != null)
     {
         Explode.Invoke();
     }
     Explode -= () => CrashStatus = true;
 }
Example #2
0
    void Update()
    {
        _currentLife = Mathf.MoveTowards(_currentLife, _targetLife, Time.deltaTime * _lifeAnimationSpeed);
        var lifeRect = _lifeImage.rectTransform.rect;

        lifeRect.width = (_currentLife / _initialLife) * _lifeWidth;
        _lifeImage.rectTransform.sizeDelta        = lifeRect.size;
        _lifeImage.rectTransform.anchoredPosition = new Vector2(lifeRect.width / 2.0f, 0.0f);

        if (_currentLife <= 0.001f)
        {
            Explode?.Invoke();
            Instantiate(_explosion, transform.position, transform.rotation);
            Destroy(gameObject);
        }
    }
Example #3
0
 public override void Hit(float _fDamage)
 {
     m_fCurrentHp -= _fDamage;
     if(m_fCurrentHp <= 0)
     {
         GameObject explodePrefab = UnitPool.Instance.GetExplodePrefab();
         explodePrefab.transform.position = this.transform.position;
         if (m_explode != null)
         {
             m_explode.Invoke(this.gameObject);
         }
         else
         {
             Destroy(this.gameObject);
         }
     }
 }