예제 #1
0
        private Dictionary <BrickPosition, IBrick> RestoreColumnFromGameDataAndMergeWithGameField(
            ICurrentGameData currentGameData,
            GameField gameField)
        {
            Dictionary <BrickPosition, IBrick> column;

            if (currentGameData.Column == null)
            {
                column = null;
            }
            else
            {
                column = new Dictionary <BrickPosition, IBrick>();

                foreach (var pair in currentGameData.Column)
                {
                    var brickPosition = BrickPosition.FromTuple(pair.Key);

                    if (gameField.TryGetValue(brickPosition, out var brick))
                    {
                        column.Add(brickPosition, brick);
                    }
                }
            }

            return(column);
        }
예제 #2
0
        private GameField RestoreGameFieldFromGameData(ICurrentGameData currentGameData)
        {
            var settings = ContainerProvider.Resolve <ISettingsProvider>().GetSettingsInstance();

            var gameField = new GameField(settings.FieldWidth, settings.FieldHeight);

            foreach (var pair in currentGameData.GameField)
            {
                gameField.Add(BrickPosition.FromTuple(pair.Key), new Brick {
                    BrickKind = pair.Value
                });
            }

            return(gameField);
        }