public void Init(FortView fortView, FortViewUi fortViewUi, LevelModel levelModel) { this.fortView = fortView; this.fortViewUi = fortViewUi; this.levelModel = levelModel; fortModel = new FortModel(); this.fortViewUi.Inititalization(fortModel); this.fortView.SetFortState(FortModel.DestructionState.None); }
public FortController(FortView fortView, FortViewUi fortViewUi, LevelModel levelModel) { this.fortView = fortView; this.fortViewUi = fortViewUi; this.fortView.OnHit += OnHitHandler; this.levelModel = levelModel; fortModel = new FortModel(); this.fortViewUi.Inititalization(fortModel); this.fortView.SetFortState(FortModel.DestructionState.None); }
public void InitCurrentLevel(int level) { ClearLevel(); CurrentGameLevel = level; DefenderSetting defenderSetting = Resources.Load <DefenderSetting>("DefenderSetting"); DefenderViewFactory defenderViewFactory = new DefenderViewFactory(defSpawnPoints); DefenderViewUi[] defenderViewUiList = FindObjectsOfType <DefenderViewUi>(); FortView fortView = FindObjectOfType <FortView>(); fortView.OnKill += OnKillEnemy; for (int i = 0; i < defenderViewFactory.Views.Count; i++) { objectsToClear.Add(defenderViewFactory.Views[i].gameObject); defenderControllers.Add(new DefenderController(defenderViewFactory.Views[i], new DefenderModel(defenderSetting), defenderViewUiList[i])); defenderViewFactory.Views[i].OnKill += OnKillEnemy; } EnemySetting enemySettings = Resources.Load <EnemySetting>("EnemySetting"); EnemyViewFactory EnemyViewFactory = new EnemyViewFactory(LevelModels[CurrentGameLevel].EnemiesOnLevelCount, enemySpot); LevelModels[CurrentGameLevel].InitCurrentLevel(enemySettings.ExpForKill, LevelClearedGameOver); if (fortController != null) { fortController.Init(FindObjectOfType <FortView>(), FindObjectOfType <FortViewUi>(), LevelModels[CurrentGameLevel]); } else { FortController.OnFortDestroyed += LevelLossGameOver; fortController = new FortController(fortView, FindObjectOfType <FortViewUi>(), LevelModels[CurrentGameLevel]); } foreach (var view in EnemyViewFactory.Views) { objectsToClear.Add(view.gameObject); EnemyController enemyController = new EnemyController(view, new EnemyModel(enemySettings)); foreach (var defender in defenderControllers) { enemyController.OnDie += defender.OnTargetDieHandler; } enemyControllers.Add(enemyController); } }
private void Start() { fortView = FindObjectOfType <FortView>(); Invoke("Explode", Random.Range(0.9f, 1.3f)); }