Beispiel #1
0
        private void Fire(BaseEnemy enemy)
        {
            TowerBullet bullet = BulletPool.GetBullet();

            bullet.FireToEnemy(this, enemy);

            _currentFireCooldown = 1 / _fireSpeed;
            _enableToFire        = false;
        }
Beispiel #2
0
        //выстрел по противнику
        public void FireToEnemy(BaseTower tower, BaseEnemy enemy)
        {
            _bulletSprite.color = _matDedaultColor;

            _isFired       = true;
            _isTargetAlive = true;

            _tower          = tower;
            _enemy          = enemy;
            _target         = enemy.transform;
            _enemy.OnDeath += DeathTarget;

            transform.position = _tower.transform.position;
        }
Beispiel #3
0
        //спав проихожит по таблице вероятности заложенной в _spawnChanceTable
        private void SpawnEnemy()
        {
            int chance = Random.Range(0, 100);
            EnemySpawnChance enemyToSpawn = _spawnChanceTable.FirstOrDefault(a => a.MinChance <= chance && a.MaxChance > chance);

            if (enemyToSpawn == null)
            {
                Debug.LogException(new System.Exception("Missing enemy spawn chance zone, set to _spawnChanceTable[0] element"));
                enemyToSpawn = _spawnChanceTable[0];
            }

            int       lineId   = Random.Range(0, _lines.Count);
            BaseEnemy newEnemy = enemyToSpawn.GetNewEnemy();

            newEnemy.Init(_lines[lineId], enemyToSpawn);
        }
Beispiel #4
0
        private void Update()
        {
            if (_enableToFire)
            {
                List <RaycastHit> hits = _getAllTargets.GetAllHits(_fireDistance);

                //если в радиусе есть противники
                if (hits.Count > 0)
                {
                    BaseEnemy enemy = _getTargetToFire.GetTargetToFire(hits);
                    if (enemy != null)
                    {
                        Fire(enemy);
                    }
                    else
                    {
                        Debug.LogException(new System.Exception("Missing BaseEnemy script on Enemy"));
                    }
                }
            }

            //обратный отсчет стрельбы
            FireCooldown();
        }
Beispiel #5
0
 public void ReleaseEnemy(BaseEnemy enemy)
 {
     _enemyPool.ReleaseObject(enemy);
 }
Beispiel #6
0
 public void DealDamage(BaseEnemy enemy)
 {
     enemy.GettingDamage(_fireDamage);
 }