示例#1
0
    public static bool SetPlayModel()
    {
        if (Profile.Hearts < 1)
        {
            Game.Instance.OpenPopup <Popup_BuyHearts>();
            return(false);
        }
        else
        {
            Profile.Hearts--;
        }

        PlayModel.Reset(PlayModel.Type.Classic);
        PlayModel.ballId               = Profile.Avatar.BallId;
        PlayModel.level.name           = string.Format(LocalizationService.Get(111127), Profile.MaxClassicScore);
        PlayModel.level.theme          = Random.Range(0, 1000);
        PlayModel.level.pattern        = GlobalFactory.Patterns.Classic.Get();
        PlayModel.level.startBallCount = 5;
        PlayModel.level.minBlockHealth = 1;
        PlayModel.level.maxBlockHealth = 10;

        PlayModel.onPreLose = OnPreLose;
        PlayModel.onLose    = OnLose;

        return(true);
    }
示例#2
0
    public static bool SetPlayerModel()
    {
        if (Profile.Hearts < 1)
        {
            Game.Instance.OpenPopup <Popup_BuyHearts>();
            return(false);
        }
        else
        {
            Profile.Hearts--;
        }

        PlayModel.Reset(info.playType);
        PlayModel.ballId               = Profile.Avatar.BallId;
        PlayModel.level.name           = info.name;
        PlayModel.level.theme          = Random.Range(0, 1000);
        PlayModel.level.pattern        = GlobalFactory.Patterns.Leagues.Get();
        PlayModel.level.startBallCount = Random.Range(info.startBallCount.x, info.startBallCount.y);
        PlayModel.level.minBlockHealth = PlayModel.level.startBallCount / 2;
        PlayModel.level.maxBlockHealth = PlayModel.level.startBallCount * 3 / 2;

        PlayModel.onPreLose = OnPreLose;
        PlayModel.onLose    = OnLose;

        return(true);
    }
示例#3
0
    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);
    }