Ejemplo n.º 1
0
 /// <summary>
 /// Init with specified moveLine and releaseObject.
 /// </summary>
 /// <param name="moveLine">Move line.</param>
 /// <param name="releaseObject">Release object.</param>
 public void Init(MoveLine moveLine, EnemySpawnChance releaseObject)
 {
     _hp    = _startHP;
     _speed = _startSpeed;
     _cachedTransform.position = moveLine.StartLineWp.position;
     _releaseObject            = releaseObject;
     StartMove(moveLine.EndLineWp);
     UpdateHpBar();
 }
Ejemplo n.º 2
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);
        }