Exemple #1
0
        private void UpdateHealthLogic()
        {
            // Shield
            if (_shield > 0 && !_isShieldBlock)
            {
                _isShieldBlock = true;

                var sh = _shildFactory.Create();
                sh.transform.SetParent(gameObject.transform);
                sh.transform.localPosition = new Vector3(0, 0, -2);

                _delayService.DelayedCall(1f, () =>
                {
                    _shield--;
                    _isShieldBlock = false;
                    UpdateHealthDisplay();
                });
            }

            //armor
            if (_shield <= 0)
            {
                var dmg = 1f;
                if (_arm < _weapon.Damage)
                {
                    dmg = _weapon.Damage - _arm;
                }

                _health -= dmg;

                UpdateHealthDisplay();

                if (_health <= 0)
                {
                    var expl = _explosionFactory.Create();
                    expl.transform.SetParent(_gameManager.GamePresenter.transform);
                    expl.transform.localPosition = new Vector3
                                                       (gameObject.transform.position.x, gameObject.transform.position.y, -2);

                    var btObj = GetComponent <BaseTank>();

                    if (btObj.Id > 0)
                    {
                        var etObj = GetComponent <EnemyTank>();

                        var bDisplay = _bonusDisplay.Create();
                        bDisplay.transform.SetParent(_gameManager.GamePresenter.transform);
                        bDisplay.transform.localPosition = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, -4);
                        bDisplay.AddBonus(etObj.GetBonus);

                        _onRespaunEnemy.Fire(etObj);
                    }
                    else
                    {
                        _onRespaunUser.Fire();
                    }
                }
            }
        }
        void Die()
        {
            var explosion = _explosionFactory.Create();

            explosion.transform.position = _model.Position;

            GameObject.Destroy(_context.gameObject);

            _killedSignal.Fire();
        }
        void Die()
        {
            _model.IsDead = true;

            var explosion = _explosionFactory.Create();

            explosion.transform.position = _model.Position;

            _model.Renderer.enabled = false;

            _killedSignal.Fire();
        }
Exemple #4
0
 public virtual void SpawnExplosion()
 {
     try
     {
         var explosion = ExplosionFactory.Create();
         explosion.transform.position = Position;
     }
     catch
     {
         Debug.Log("object position missing");
     }
 }
 private void Start()
 {
     this.UpdateAsObservable().Where(_ => !_gameManager.gameOver).Timestamp()
     .Where(x => x.Timestamp > _lastExplosion.AddSeconds(_explosionRate))
     .Skip(TimeSpan.FromSeconds(_explosionRate))
     .Subscribe(
         x =>
     {
         var xPos                     = Random.Range(-15f, 15f);
         var zPos                     = Random.Range(-30f, 30f);
         var randomPosition           = new Vector3(xPos, 0, zPos);
         var explosion                = _explosionFactory.Create();
         explosion.transform.position = randomPosition;
         explosion.transform.SetParent(transform);
         _explosionRate *= .9f;
         _lastExplosion  = x.Timestamp;
     });
 }
 private void OnCollisionEnter2D(Collision2D _)
 {
     Explode();
     _explosionPool.Create(transform.position, DestructionBenefitsPlayer);
 }
        public virtual void Die()
        {
            var explosion = _explosionFactory.Create();

            explosion.transform.position = _view.Position;
        }