Beispiel #1
0
        public void Setup(List <string> playerNames, ImagePool.FrontTypes frontType, ImagePool.BackTypes backType, Board.Layouts layout)
        {
            Done = false;

            initialPlayerNames = playerNames;
            initialFrontType   = frontType;
            initialBackType    = backType;
            initialLayout      = layout;

            // Make board
            board.Setup(initialLayout, frontType, backType);
            board.MatchMade    += OnMatchMade;
            board.GameFinished += OnGameFinished;

            // Make players
            players.Clear();

            for (int i = 0; i < initialPlayerNames.Count; i++)
            {
                Player player = new Player(initialPlayerNames[i]);
                players.Add(player);
            }

            BindPlayersToViews();

            CurrentPlayerIndex = 0;
        }
Beispiel #2
0
 public Data(List <string> initialPlayerNames, Board.Layouts initialLayout, int currentPlayerIndex, Board.Data boardData, List <Player.Data> playerDatas)
 {
     this.initialPlayerNames = initialPlayerNames;
     this.initialLayout      = initialLayout;
     this.currentPlayerIndex = currentPlayerIndex;
     this.boardData          = boardData;
     this.playerDatas        = playerDatas;
 }
Beispiel #3
0
        public Session(Board board, List <PlayerView> playerViews, List <string> playerNames, Board.Layouts layout)
        {
            this.board       = board;
            this.playerViews = playerViews;

            initialPlayerNames = playerNames;
            initialLayout      = layout;

            Start();
        }
Beispiel #4
0
        public void Load(Data data)
        {
            Done = false;

            initialPlayerNames = data.initialPlayerNames;
            initialLayout      = data.initialLayout;

            board.Load(data.boardData);
            board.MatchMade    += OnMatchMade;
            board.GameFinished += OnGameFinished;

            foreach (Player.Data playerData in data.playerDatas)
            {
                Player player = new Player(playerData);
                players.Add(player);
            }

            BindPlayersToViews();

            CurrentPlayerIndex = data.currentPlayerIndex;
        }
Beispiel #5
0
        /// <summary>
        /// Starts a game session
        /// </summary>
        /// <param name="playerNames">List of player names</param>
        public void Setup(List <string> playerNames, ImagePool.FrontTypes frontType, ImagePool.BackTypes backType, Board.Layouts layout)
        {
            currentSession = new Session(board, playerViews);
            currentSession.Setup(playerNames, frontType, backType, layout);

            currentSession.GameFinished += FinishGame;
        }
Beispiel #6
0
        /// <summary>
        /// Navigate to the game
        /// </summary>
        /// <param name="playerNames">List of all player names</param>
        /// <param name="frontType">Fronttype for the cards</param>
        /// <param name="backType">Backtype for the cards</param>
        /// <param name="layout">Layout for the board</param>
        public void NavigateToGame(List <string> playerNames, ImagePool.FrontTypes frontType, ImagePool.BackTypes backType, Board.Layouts layout)
        {
            PageGame game = new PageGame(this);

            currentPage = game;
            Navigate(game);
            game.Setup(playerNames, frontType, backType, layout);
        }
Beispiel #7
0
 public Data(string name, int score, Board.Layouts layout)
 {
     this.name   = name;
     this.score  = score;
     this.layout = layout;
 }
        /// <summary>
        /// On play button clicked
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">Events</param>
        private void OnButtonPlayClicked(object sender, MouseEventArgs e)
        {
            // Create lists of players
            List <string> playerNames = new List <string>();

            foreach (CustomTextbox textBox in textBoxes)
            {
                playerNames.Add(textBox.textbox.Text);
            }

            // Create front type
            ImagePool.FrontTypes frontType = default;

            if (selectedForeCard == cardForePokemon)
            {
                frontType = ImagePool.FrontTypes.POKEMON;
            }
            else if (selectedForeCard == cardForeAnimals)
            {
                frontType = ImagePool.FrontTypes.ANIMALS;
            }
            else if (selectedForeCard == cardForeMario)
            {
                frontType = ImagePool.FrontTypes.MARIO;
            }

            // Create back type
            ImagePool.BackTypes backType = default;

            if (selectedBackCard == cardBackPokemon)
            {
                backType = ImagePool.BackTypes.POKEMON;
            }
            else if (selectedBackCard == cardBackVintage)
            {
                backType = ImagePool.BackTypes.VINTAGE;
            }
            else if (selectedBackCard == cardBackMario)
            {
                backType = ImagePool.BackTypes.MARIO;
            }

            // Create boar layout
            Board.Layouts layout = default;

            if (selectedGridSizeButton == buttonFourByFour)
            {
                layout = Board.Layouts.FourByFour;
            }
            else if (selectedGridSizeButton == buttonFiveByFive)
            {
                layout = Board.Layouts.FiveByFive;
            }
            else if (selectedGridSizeButton == buttonSixByFour)
            {
                layout = Board.Layouts.SixByFour;
            }
            else if (selectedGridSizeButton == buttonSixBySix)
            {
                layout = Board.Layouts.SixBySix;
            }

            // Navigate
            window.NavigateToGame(playerNames, frontType, backType, layout);
        }