public void StopMatch() { bool isWin = !PlayerController.I.Player.Health.Hp.IsZero; bool allEnemies = this.killCount == this.preset.count; bool noDamage = PlayerController.I.Player.Health.Hp.IsMax; var progress = LevelProgressData.GetProgress(this.preset.id); progress.complete |= isWin; progress.allEnemies |= allEnemies; progress.noDamage |= noDamage; var popup = PopupManager.OpenPopup <EndLevelPopup>(); popup.SetWindow(isWin); if (isWin) { popup.SetStars(1 + (allEnemies ? 1 : 0) + (noDamage ? 1 : 0)); } popup.OnRemoving += GameManager.StopLevel; }
protected override void OnInit() { foreach (var btn in this.returnBtns) { btn.onClick.AddListener(() => Hide(null)); } this.cellReference.GO.SetActive(false); var points = this.levelPoints; var count = points.Length; for (int i = 0; i < count; ++i) { int id = i; var preset = LevelPresetData.GetPreset(id); var progress = LevelProgressData.GetProgress(id); var cell = Instantiate(this.cellReference, points[id]); cell.GO.SetActive(true); cell.Name.text = $"Level {id + 1}"; cell.SetStars(progress.Stars); bool active = id == 0 || LevelProgressData.GetProgress(id - 1).complete; cell.SetActive(active); if (active) { cell.StartBtn.onClick.AddListener(() => { var popup = PopupManager.OpenPopup <StartLevelPopup>(); popup.SetDescription($"Level {id + 1}\nasteroids: {preset.count}\ntime: {preset.duration}"); popup.SetStars(progress.Stars); popup.OnStart += () => { Hide(null); GameManager.StartLevel(id); }; }); } } }