public Popup_LevelInfo Setup(SeasonModel season, int index, bool startLevelButton) { var levelmodel = season.GetLevelModel(index, Profile.Skill); title.SetFormatedText(season.id + 1, GlobalFactory.Seasons.GetLevelNumber(season.id, index + 1)); ballsLabel.SetFormatedText(levelmodel.startBallCount); allitemsDesc.SetActive(levelmodel.IsTargetExist == false); targetItemsDesc.SetActive(levelmodel.IsTargetExist == true); var ballsprite = GlobalFactory.Balls.GetSprite(Profile.Avatar.BallId); foreach (var ballimage in ballImages) { ballimage.sprite = ballsprite; } targetItem0Image.sprite = GlobalFactory.Theme.Selected.items[0]; targetItem1Image.sprite = GlobalFactory.Theme.Selected.items[1]; targetItem0Label.text = levelmodel.targetItem0.ToString(); targetItem1Label.text = levelmodel.targetItem1.ToString(); targetBallsLabel.text = levelmodel.targetBalls.ToString(); targetBlocksLabel.text = levelmodel.targetBlocks.ToString(); targetItem0Label.transform.parent.gameObject.SetActive(levelmodel.targetItem0 > 0); targetItem1Label.transform.parent.gameObject.SetActive(levelmodel.targetItem1 > 0); targetBallsLabel.transform.parent.gameObject.SetActive(levelmodel.targetBalls > 0); targetBlocksLabel.transform.parent.gameObject.SetActive(levelmodel.targetBlocks > 0); startButton.onClick.AddListener(() => { if (startLevelButton) { if (StoryLogic.SetPlayModel(season, index)) { Back(); StoryLogic.StartPlaying(null); } } else { Back(); } }); return(this); }
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); }