示例#1
0
        public CellsGraph([NotNull] GameModel initialModel)
        {
            Validate.ArgumentIsNotNull(initialModel, nameof(initialModel));

            _initialModel = initialModel;

            _cellsCount = initialModel.Data.Colors.Length;
            _triangleSize = PositionHelper.GetMaxTriangleSize(_cellsCount);

            _datas = Enumerable.Range(0, _cellsCount).Select(GetCellData).ToImmutableList();
        }
示例#2
0
        public async Task InitGameAsync(bool forceNewGame)
        {
            _settings = await SettingsManager.Instance.GetCurrentData().ConfigureAwait(true);

            if (forceNewGame || ReferenceEquals(_settings.CurrentGame, null))
            {
                _currentModel = CreateNewGame();
                _settings.CurrentGame = _currentModel.Data;

                await SettingsManager.Instance.SaveCurrentAsync().ConfigureAwait(true);
            }
            else
            {
                _currentModel = new GameModel(_settings.CurrentGame);
            }

            var gameColors = _currentModel.Data.Colors;
            GameColors = gameColors.Select((v, i) => new GameColorViewModel(gameColors, i)).ToArray();
        }