示例#1
0
        public void LoadGame(string fileName)
        {
            var history = _historyFetchService.Load(fileName);
            var info    = new GameInfo(_gameSettings)
            {
                Dimension             = history.Info.Dimension,
                StepSize              = history.Info.StepSize,
                BadgesToWin           = history.Info.BadgesToWin,
                GlobalStep            = history.Info.GlobalStep,
                GameState             = history.Info.GameState,
                ActivePlayerMadeSteps = history.Info.ActivePlayerMadeSteps,
                TimerTime             = history.Info.TimerTime,
                GameSettings          =
                {
                    GameOverAfterFirstWinner = history.Info.GameSettings.GameOverAfterFirstWinner,
                    TimerType                = history.Info.GameSettings.TimerType
                },
                PlayerCanWin = history.Info.PlayerCanWin,
                HistoryItems = history.HistoryItems,
                Players      = history.Info.Players,
                ActivePlayer = history.Info.Players.First(x => x == history.Info.ActivePlayer)
            };

            _sceneLoader.LoadScene("GameBoard", LoadSceneMode.Single, container =>
            {
                container.BindInstance(info).WhenInjectedInto <GameBoardInstaller>();
            });
        }
示例#2
0
        public void Initialize()
        {
            var dir = new DirectoryInfo(Application.dataPath + "/Stats/");

            if (dir.Exists && File.Exists(Application.dataPath + "/Stats/Stats.json"))
            {
                var statsInstance = _statsFetchService.Load("Stats");
                StatsItems = statsInstance.StatsItems;
            }
            else
            {
                StatsItems = new List <StatsItem>();
            }

            _info.PropertyChanged += OnGameInfoPropertyChanged;
        }
示例#3
0
        private void UpdateHighscores()
        {
            _highscoresRegistry.Clear();
            if (File.Exists(Application.dataPath + "/Stats/Stats.json") == false)
            {
                return;
            }
            var statsInstance = _statsFetchService.Load("Stats");

            statsInstance.StatsItems.Sort();

            foreach (var stat in statsInstance.StatsItems)
            {
                var highscoreItem = _highscoreItemFactory.Create();
                highscoreItem.transform.SetParent(View.TableContent, false);
                highscoreItem.PlayerNameText.text = stat.PlayerName;
                highscoreItem.TotalScoreText.text = stat.TotalScore.ToString();
                highscoreItem.WonRoundsText.text  = stat.WonRounds.ToString();
            }
        }
        private void UpdateSaves()
        {
            View.SaveInformationText.text = string.Empty;
            _saveItemsRegistry.Clear();
            var dir = new DirectoryInfo(Application.dataPath + "/Saves/");

            if (dir.Exists == false)
            {
                return;
            }
            var saves = dir.GetFiles("*.json");

            foreach (var save in saves)
            {
                var saveItem = _saveItemFactory.Create();
                saveItem.transform.SetParent(View.SavesToggleGroup.transform, false);
                saveItem.SaveItemToggle.group    = View.SavesToggleGroup;
                saveItem.SaveItemToggleText.text = Path.GetFileNameWithoutExtension(save.Name);
                saveItem.SaveItemToggle.onValueChanged.AddListener(OnSaveItemChecked);
                saveItem.History = _fetchService.Load(saveItem.SaveItemToggleText.text);
            }
        }