/// <summary> /// Породить врага. /// </summary> /// <param name="type">Тип порождаемого врага.</param> public void SpawnEnemy(EnemyType type) { var enemy = new EnemyLogic(EnemiesLibrary.GetEnemyByType(type), _path, this); _spawnedEnemies.Add(enemy); _controller.AddEnemy(enemy); }
private void Attack(EnemyLogic enemy) { var shot = new ShotLogic(_tower.Weapon, enemy, _cellSize, _position); _shots.Add(shot); _gameLogic.Shoot(shot); Cooldown(); }
public ShotLogic(IWeapon weapon, EnemyLogic target, float cellSize, Vector3 position) { _weapon = weapon; _target = target; _position = position; BulletPosition = position; var to = target.GetPosition(); _totalTime = 0; _calcTime = Vector3.Magnitude(to - _position) / cellSize / weapon.BulletSpeed; _targetPosition = _target.GetPosition(_calcTime); }
/// <summary> /// Враг умер. /// </summary> /// <param name="enemy">Умерший враг.</param> public void EnemyDie(EnemyLogic enemy) { if (_spawnedEnemies.Contains(enemy)) { _spawnedEnemies.Remove(enemy); GameModel.Instance.Money += enemy.Model.Price; } else { Debug.LogWarning("Enemy already was destroyed."); } if (_targetHealth > 0 && !_spawnedEnemies.Any() && !_workingWaves.Any() && _waveIterator == null) { // Закончились враги и волны. _controller.Win(GetResult()); } }