// Use this for initialization private IEnumerator Start() { var rewards = PlayModel.GetReward(); int rewardStars = PlayModel.GetRewardStars(); // verify that player has been passed this level if (Profile.IsLevelPassed(PlayModel.level.season, PlayModel.level.index)) { rewards.gems = rewards.bombs = rewards.hammers = rewards.missiles = 0; } Profile.SetLevelStars(PlayModel.level.season, PlayModel.level.index, rewardStars); int totalBalls = PlayModel.result.totalBalls + PlayModel.level.startBallCount; desc.SetFormatedText(PlayModel.result.totalTurn.ToString(), PlayModel.result.totalBlocks.ToString(), totalBalls); if (rewards.exist) { continueButton.gameObject.SetActive(true); nextLevelButton.gameObject.SetActive(false); goHomeButton.gameObject.SetActive(false); } else { continueButton.gameObject.SetActive(false); nextLevelButton.gameObject.SetActive(true); goHomeButton.gameObject.SetActive(true); } nextLevelButton.onClick.AddListener(() => { base.Back(); nextTaskFunc?.Invoke(true); }); goHomeButton.onClick.AddListener(() => { base.Back(); nextTaskFunc?.Invoke(false); }); continueButton.onClick.AddListener(() => { continueButton.gameObject.SetActive(false); Profile.EarnGems(rewards.gems); Profile.Bombs += rewards.bombs; Profile.Hammers += rewards.hammers; Profile.Missiles += rewards.missiles; Game.Instance.OpenPopup <Popup_Rewards>().Setup(0, rewards.gems, rewards.bombs, rewards.hammers, rewards.missiles, true, true, () => { continueButton.gameObject.SetActive(false); nextLevelButton.gameObject.SetActive(true); goHomeButton.gameObject.SetActive(true); }); GlobalAnalytics.SourceGem(rewards.gems, "level"); }); UiShowHide.ShowAll(transform); var wait = new WaitForSeconds(0.3f); yield return(wait); yield return(wait); yield return(wait); stars[0].SetActive(rewardStars > 0); yield return(wait); stars[1].SetActive(rewardStars > 1); yield return(wait); stars[2].SetActive(rewardStars > 2); yield return(wait); // Incentive text { var index = BaloonIndex++ % 25; var incentiveStr = LocalizationService.Get(111090 + index); if (BaloonIndex < 25 || Random.Range(0, 100) < rewardStars * 25) { baloon.SetText(incentiveStr); baloon.gameObject.SetActive(true); } } }
public static bool Reset() { if (Profile.Hearts < 1) { Game.Instance.OpenPopup <Popup_BuyHearts>(); return(false); } else { Profile.Hearts--; } PlayModel.Reset(PlayModel.Type.Levels); PlayModel.ballId = Profile.Avatar.BallId; PlayModel.level = season.GetLevelModel(index, Profile.Skill); PlayModel.onWin = exitplaying => { Game.Instance.ClosePopup(true); Profile.Hearts++; GlobalAnalytics.Levels.Complete(season.id, index, PlayModel.GetRewardStars()); if (season.id > 0) { Profile.Skill += (Profile.Skill < 0) ? GlobalConfig.Difficulty.winFactorNegative : GlobalConfig.Difficulty.winFactorPositive; } CheckCinematics(CinematicConfig.Point.End, () => { Game.Instance.OpenPopup <Popup_Win>().SetNextTask(nextlevel => { if (nextlevel && NextLevel()) { StartPlaying(() => { var levelmodel = season.GetLevelModel(index, Profile.Skill); if (levelmodel.IsTargetExist) { Game.Instance.OpenPopup <Popup_LevelInfo>().Setup(season, index, false); } }); } else { exitplaying(true); } }); }); }; PlayModel.onLose = exitplaying => { GlobalAnalytics.Levels.Fail(season.id, index); if (season.id > 0) { Profile.Skill = Profile.Skill - GlobalConfig.Difficulty.loseFactor; } exitplaying(true); }; PlayModel.onPreLose = exitplaying => { //Game.Instance.OpenPopup<Popup_Confirm>().Setup(111005, true, true, exitplaying).GetComponent<UiCharacter>(true, true).SetBody(1).SetFace(2); exitplaying(false); if (Reset()) { StartPlaying(() => { }); } }; return(true); }