public void UpdateTick() { for (int i = 0; i < _pointsForSpawn.Count; i++) { Collider[] hits = Physics.OverlapSphere(_pointsForSpawn[i].position, _radius); if (hits.Length > 0) { foreach (var hit in hits) { if (hit.gameObject == ServiceLocator.GetDependency <GameObject>()) { var enemy = GameObject.Instantiate(_data.gameObject, _pointsForSpawn[i].position, Quaternion.identity); var model = new EnemyModel(_data.EnemyStruct); var controller = new EnemyController(model, enemy); var enemySprite = Resources.Load <GameObject>("Textures/EnemyRadar"); ServiceLocator.GetDependency <RadarController>().AddingObject(enemy, enemySprite); ServiceLocator.GetDependency <Repository>().AddDataToList(new EnemySaveData(model, enemy.transform)); var point = _pointsForSpawn[i]; _pointsForSpawn.Remove(point); GameObject.Destroy(point.gameObject); } } } } }
public EnemySaveData(EnemyModel model, Transform transform) { _enemyTransform = transform; _model = model; EnemyStruct = new EnemyStruct() { Damage = _model.Damage, Speed = _model.Speed }; Position = transform.position; Rotation = transform.rotation; }
public void FromLoad() { _model = new EnemyModel(EnemyStruct); _enemyTransform.position = Position; _enemyTransform.rotation = Rotation; }
public EnemyController(EnemyModel model, GameObject go) : base(model, go) { ControllersUpdater.AddUpdate(this); _transform = go.transform; _model = model; }