예제 #1
0
        public GameState Map(Tuple<int, char>[] playerMoves, string status)
        {
            var gs = new GameState { Board = new char[Configuration.Instance.Dimension, Configuration.Instance.Dimension], Status = status };

            foreach (var playerMove in playerMoves)
            {
                var posX = playerMove.Item1 % Configuration.Instance.Dimension;
                var posY = playerMove.Item1 / Configuration.Instance.Dimension;
                gs.Board[posX, posY] = playerMove.Item2;
            }

            return gs;
        }
예제 #2
0
        public void Display(GameState gameState)
        {
            uxStatus.Text = gameState.Status;

            for (int y = 0; y < Configuration.Instance.Dimension; y++)
            {
                for (int x = 0; x < Configuration.Instance.Dimension; x++)
                {
                    _buttons[x + y * Configuration.Instance.Dimension].Content = gameState.Board[x, y];
                }
            }

            if (gameState.Status.Contains("gewonnen"))
            {
                // someone won
                SetActive(false);
            }
            else if (gameState.Status.Contains("ist dran"))
            {
                SetActive(true);
            }
            InvalidateVisual();
        }