コード例 #1
0
        /// <summary>
        /// Стандартный конструктор без параметров
        /// </summary>
        public AppModel()
        {
            //загружаем основные настройки
            AppSettingsPath = AppInfoConsts.GameplaySettingsPath;
            bool settingsLoadingResult =
                AppSerializationManager.LoadDataFromFileSafe <GameplaySettingsData>(AppSettingsPath,
                                                                                    out _appGameplaySettingsData);

            if (!settingsLoadingResult)
            {
                _appGameplaySettingsData = GameplaySettingsData.GetDefaultSettings();
            }

            //настройки (даже свежезагруженные) нужно сохранить, чтобы убедится, что новые добавленные разработчиком
            //пункты также были отражены в файле
            AppSerializationManager.SaveDataToFile <GameplaySettingsData>(_appGameplaySettingsData, AppSettingsPath);


            //загружаем рекорды игроков
            bool recordsLoadingResult =
                AppSerializationManager.LoadDataFromFileSafe(AppRecordsPath, out _appRecordsData);

            if (!recordsLoadingResult)
            {
                _appRecordsData = RecordsData.GetStandardRecords();
            }

            _appRecordsData.CheckAndApplyConstraints();
            //рекорды (даже свежезагруженные) нужно сохранить, чтобы убедится, что новые добавленные разработчиком
            //дополнительные поля также были отражены в файле

            AppSerializationManager.SaveDataToFile(_appRecordsData, AppRecordsPath);
        }
コード例 #2
0
ファイル: EndTrial.cs プロジェクト: Gryzbastian/Tunelstein
    public void UpdateRecordsBoard()
    {
        int         currentLevel = SceneManager.GetActiveScene().buildIndex - 1;
        RecordsData savedRecords = Save.GetCurrentLevelRecords(currentLevel);

        float[] playerRecords = savedRecords.GetRecords();

        for (int i = 0; i < playerRecords.Length; i++)
        {
            _scoreboardTimes[i].text = TimeTrialManager.FormatTime(playerRecords[i]);
        }
    }
コード例 #3
0
 public static RecordsData[] GenerateDefaultPlayerTimes()
 {
     RecordsData[] defaultTimes = new RecordsData[Save.levelCount];
     for (int i = 0; i < defaultTimes.Length; i++)
     {
         defaultTimes[i] = new RecordsData();
         defaultTimes[i]._playerTimes = new float[Save.maxRecords];
         for (int j = 0; j < Save.maxRecords; j++)
         {
             defaultTimes[i]._playerTimes[j] = 36000.0f;
         }
     }
     return(defaultTimes);
 }
コード例 #4
0
    public bool EvaluateRecords()
    {
        float       finishTime   = _timeTrialManager.PlayerTime;
        int         currentLevel = SceneManager.GetActiveScene().buildIndex - 1;
        RecordsData records      = Save.GetCurrentLevelRecords(currentLevel);

        _newRecord = false;

        if (records.IsNewRecord(finishTime))
        {
            records.SetNewRecord(finishTime);
            _newRecord = true;
        }
        return(_newRecord);
    }
コード例 #5
0
    public void LoadPlayerRecords()
    {
        Text[][] _levelScoreBoards = new Text[3][]
        {
            _level1Scoreboard,
            _level2Scoreboard,
            _level3Scoreboard
        };

        for (int i = 0; i < _levelScoreBoards.GetLength(0); i++)
        {
            RecordsData recordsData = Save.GetCurrentLevelRecords(i);
            float[]     records     = recordsData.GetRecords();
            for (int j = 0; j < records.Length; j++)
            {
                _levelScoreBoards[i][j].text = TimeTrialManager.FormatTime(records[j]);
            }
        }
    }
        /// <summary>
        /// Обработка состояния элементов интерфейса
        /// </summary>
        private void ProcessUiElementsList()
        {
            //добавить фон
            _currentMenuElements = new List <RenderingData.RenderingData?>();
            _currentMenuElements.Add(new RenderingData.RenderingData(
                                         new RenderingSprite(
                                             ActualSubassetsDataLibrary.GetSprite(MainMenuControlComponentViewRenderableComponent.MAIN_MENU_BG),
                                             0, 0, 0, Color.White, 1)));

            //добавить псевдо-кнопки рекордов с текущими значениями
            int currentMenuY = MainMenuControlComponentViewRenderableComponent.Y_OFFSET_MENU_START;

            if (_modelProviderComponent.MenuUiElements != null)
            {
                void ProcessButton(UiElementButton parButton, int parY, string parCaptionPrimary, string parCaptionSecondary)
                {
                    string chosenFontKey = parButton.IsHovered
            ? ViewBehaviourConsts.DEFAULT_APP_FONT
            : ViewBehaviourConsts
                                           .MENU_DARK_INACTIVE_APP_FONT;

                    bool isCentered = parCaptionSecondary == null;

                    if (isCentered)
                    {
                        _currentMenuElements.Add(new RenderingData.RenderingData(new RenderingString(-1,
                                                                                                     MainMenuControlComponentViewRenderableComponent.X_CENTERED_OFFSET_MENU, parY,
                                                                                                     parCaptionPrimary, ActualSubassetsDataLibrary.GetFont(chosenFontKey), Color.White, 1, 1,
                                                                                                     EHorizontalAlign.Middle, EVerticalAlign.Top)));
                    }
                    else
                    {
                        _currentMenuElements.Add(new RenderingData.RenderingData(new RenderingString(-1,
                                                                                                     OptionsMenuControlComponentViewRenderableComponent.MENU_LEFT_SIDE_X_OFFSET, parY,
                                                                                                     parCaptionPrimary, ActualSubassetsDataLibrary.GetFont(chosenFontKey), Color.White, 1, 1,
                                                                                                     EHorizontalAlign.Left, EVerticalAlign.Top)));
                        _currentMenuElements.Add(new RenderingData.RenderingData(new RenderingString(-1,
                                                                                                     OptionsMenuControlComponentViewRenderableComponent.MENU_RIGHT_SIDE_X_OFFSET, parY,
                                                                                                     parCaptionSecondary, ActualSubassetsDataLibrary.GetFont(chosenFontKey), Color.White, 1, 1,
                                                                                                     EHorizontalAlign.Right, EVerticalAlign.Top)));
                    }
                }

                RecordsData recordsData     = _modelProviderComponent.ParentGameObject.LinkedAppModel.GetRecordsData();
                int         currentRecordId = 0;
                ProcessButton(_modelProviderComponent.RecordOne, currentMenuY,
                              $"{recordsData.PlayerRecordsInfo[currentRecordId].PlayerName}",
                              recordsData.PlayerRecordsInfo[currentRecordId].PointsEarned.ToString());
                currentRecordId++;

                currentMenuY += MainMenuControlComponentViewRenderableComponent.Y_OFFSET_MENU_ELEMENTS;

                ProcessButton(_modelProviderComponent.RecordTwo, currentMenuY,
                              $"{recordsData.PlayerRecordsInfo[currentRecordId].PlayerName}",
                              recordsData.PlayerRecordsInfo[currentRecordId].PointsEarned.ToString());
                currentRecordId++;

                currentMenuY += MainMenuControlComponentViewRenderableComponent.Y_OFFSET_MENU_ELEMENTS;

                ProcessButton(_modelProviderComponent.RecordThree, currentMenuY,
                              $"{recordsData.PlayerRecordsInfo[currentRecordId].PlayerName}",
                              recordsData.PlayerRecordsInfo[currentRecordId].PointsEarned.ToString());
                currentRecordId++;

                currentMenuY += MainMenuControlComponentViewRenderableComponent.Y_OFFSET_MENU_ELEMENTS;

                ProcessButton(_modelProviderComponent.RecordsClearButton, currentMenuY, "Clear", null);

                currentMenuY += MainMenuControlComponentViewRenderableComponent.Y_OFFSET_MENU_ELEMENTS;

                ProcessButton(_modelProviderComponent.ReturnBackButton, currentMenuY, "Back", null);
            }
        }