コード例 #1
0
        private void MultiplayerButton_Click(object sender, EventArgs e)
        {
            f = new MainWindow();
            m = new MemoryGameMultiplayer(f);

            q.Close();
            m.AddPictures();
            f.Show();
            f.Refresh();
            if (p.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                f.player1TurnLbl.Text    = p.player1NameTxtBox.Text + "'s Turn";
                f.scorePlayer1Label.Text = p.player1NameTxtBox.Text + "'s Score";
                f.player2TurnLbl.Text    = p.player2NameTxtBox.Text + "'s Turn";
                f.scorePlayer2Label.Text = p.player2NameTxtBox.Text + "'s Score";
                p.player1NameTxtBox.Text = " ";
                p.player2NameTxtBox.Text = " ";
            }
            m.TurnFaceCard();
            f.Refresh();
            f.countdownLbl.Visible      = false;
            showFaceCardsTimer.Interval = 3000;
            showFaceCardsTimer.Enabled  = true;
            PlaySinglePlayerBtn.Text    = "Play";
            playMultiplayerBtn.Text     = "Replay";
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: IvanaJ/MemoryGame
        private void btnPlay_Click(object sender, EventArgs e)
        {
            MemoryGame newform = new MemoryGame();

            this.Hide();
            newform.ShowDialog();
        }
コード例 #3
0
ファイル: UI.cs プロジェクト: yairdana/MemoryGame
        public static void RunGame()
        {
            Console.WriteLine(" ======== Welcome to Our Memory Game ======== ");
            int    width, lenght;
            bool   isUserOneHuman = true, isUserTwoHuman = false;
            string userName1 = GetUserName();
            string userName2 = null;

            MemoryGame.eGameType gameType = ChooseAGameType();
            if (gameType == MemoryGame.eGameType.AgainstAnotherUser)
            {
                userName2      = GetUserName();
                isUserTwoHuman = true;
            }

            GetBoardSize(out width, out lenght);
            MemoryGame game = new MemoryGame(userName1, userName2, isUserOneHuman, isUserTwoHuman, gameType, lenght, width);

            PlayGame(game);

            bool anotherGame = isTostartAnotherGame();

            if (anotherGame)
            {
                Ex02.ConsoleUtils.Screen.Clear();
                RunGame();
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine("Thank You and have a nice day :)");
                System.Threading.Thread.Sleep(3000);
            }
        }
コード例 #4
0
ファイル: UI.cs プロジェクト: yairdana/MemoryGame
        private static void PlayGame(MemoryGame i_Game)
        {
            while (!i_Game.IsTheGameOver())
            {
                gameRound(i_Game);
                if (i_Game.Turn == MemoryGame.eGameTurn.FirstUser)
                {
                    i_Game.Turn = MemoryGame.eGameTurn.SecondUser;
                }
                else
                {
                    i_Game.Turn = MemoryGame.eGameTurn.FirstUser;
                }
            }

            User Winner = i_Game.DetermineWinner();

            if (Winner == null)
            {
                PrintEqualPoints(i_Game.Board.MaxPairCards / 2, i_Game.Board);
            }
            else
            {
                PrintWinner(Winner.Name, Winner.Points, i_Game.Board);
            }
        }
コード例 #5
0
ファイル: UI.cs プロジェクト: yairdana/MemoryGame
        private static void gameRound(MemoryGame i_Game)
        {
            bool isUserFindMatch;

            if (i_Game.Turn == MemoryGame.eGameTurn.FirstUser)
            {
                userTurn(i_Game, i_Game.PlayerOne, out isUserFindMatch);
            }
            else
            {   // second user - Human Player or Computer Player
                if (i_Game.Type == MemoryGame.eGameType.AgainstAnotherUser)
                {
                    userTurn(i_Game, i_Game.PlayerTwo, out isUserFindMatch);
                }
                else
                {
                    computerTurn(i_Game, i_Game.PlayerTwo, out isUserFindMatch);
                }
            }

            if (isUserFindMatch && !i_Game.IsTheGameOver())
            {
                gameRound(i_Game);
            }
        }
コード例 #6
0
ファイル: memoryGame.cs プロジェクト: cintiayurika/MemoryGame
        public static MemoryGame getSingleton(String username, UserSelect u)
        {
            if (instance == null)
            {
                instance = new MemoryGame(username, u);
            }
            else
            {
                if (instance.hsTable.ContainsKey(username))
                {
                    instance.hsTable[username] = 0;
                }
                else
                {
                    instance.hsTable.Add(username, 0);
                }

                instance.username       = username;
                instance.score          = 0;
                instance.lbl_score.Text = "0";
                instance.startOver(null, null);
            }

            return(instance);
        }
コード例 #7
0
ファイル: UI.cs プロジェクト: yairdana/MemoryGame
        private static void userTurn(MemoryGame i_Game, User i_Player, out bool o_IsAMacth)
        {
            string firstCardIndex, secondCardIndex;

            userSelectACard(i_Game, i_Player, out firstCardIndex);
            userSelectACard(i_Game, i_Player, out secondCardIndex);
            checkMatchingCardsAndUpdateBoard(i_Game, firstCardIndex, secondCardIndex, out o_IsAMacth);
        }
コード例 #8
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var screen = new MemoryGame();

            screen.Width  = 800;
            screen.Height = 600;
            Application.Run(screen);
        }
コード例 #9
0
ファイル: UserSelect.cs プロジェクト: cintiayurika/MemoryGame
 private void btn_reg_player_start_Click(object sender, EventArgs e)
 {
     if (cb_select_player.Text.Equals(""))
     {
         MessageBox.Show("Please select a user ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         //MemoryGame form = MemoryGame(cb_select_player.Text.Trim(), this);
         MemoryGame.getSingleton(cb_select_player.Text.Trim(), this).Show();
         this.Hide();
     }
 }
コード例 #10
0
ファイル: Card.cs プロジェクト: andreeapurta/MemoryGame
 public Card(int X, int Y, int value, MemoryGame F)
 {
     picture          = new PictureBox();
     picture.Top      = X;                       //distanta dintre marginea de sus a pozei si marginea de sus a containerului
     picture.Left     = Y;                       //distanta dintre marginea din stanga a pozei si marginea din stanga a containerului
     picture.Width    = 150;                     //lungime
     picture.Height   = 150;                     //inaltime
     picture.SizeMode = PictureBoxSizeMode.Zoom; //ca a incapa in picture box
     back             = @"resources\\Cover.png";
     face             = @"resources\\" + value.ToString() + ".png";
     picture.Click   += ClickOnPicture; //! click-event, se apeleaza cand dai click pe picturebox
     this.Value       = value;
     this.F           = F;
 }
コード例 #11
0
ファイル: UI.cs プロジェクト: yairdana/MemoryGame
        private static void computerTurn(MemoryGame i_Game, User i_Player, out bool o_IsAMacth)
        {
            string firstCardIndex, secondCardIndex;

            Ex02.ConsoleUtils.Screen.Clear();
            PrintUserDetails(i_Player.Name, i_Player.Points);
            PrintGameBoard(i_Game.Board);
            i_Player.AI.ChooseCardsComputer(i_Game.Board, out firstCardIndex, out secondCardIndex);
            i_Game.ExposedCard(firstCardIndex);
            printComputerSelection(i_Game.Board, firstCardIndex, i_Player);
            i_Game.ExposedCard(secondCardIndex);
            printComputerSelection(i_Game.Board, secondCardIndex, i_Player);
            checkMatchingCardsAndUpdateBoard(i_Game, firstCardIndex, secondCardIndex, out o_IsAMacth);
        }
コード例 #12
0
ファイル: UI.cs プロジェクト: yairdana/MemoryGame
        private static void userSelectACard(MemoryGame i_Game, User i_Player, out string o_CardIndex)
        {
            Ex02.ConsoleUtils.Screen.Clear();
            PrintUserDetails(i_Player.Name, i_Player.Points);
            PrintGameBoard(i_Game.Board);
            ChooseACard(i_Game.Board, out o_CardIndex);
            i_Game.ExposedCard(o_CardIndex);
            printUserSelection(i_Game.Board, i_Player);

            if (i_Game.Type == MemoryGame.eGameType.AgainstTheComputer)
            {
                i_Game.UpdateComputerAI(o_CardIndex);
            }
        }
コード例 #13
0
ファイル: UserSelect.cs プロジェクト: cintiayurika/MemoryGame
        private void btn_new_start_Click(object sender, EventArgs e)
        {
            if (txt_user_name.Text.Equals(""))
            {
                MessageBox.Show("Please type a user name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                users.Add(txt_user_name.Text.Trim());
                fillComboBox(users, cb_select_player);
                MemoryGame.getSingleton(txt_user_name.Text.Trim(), this).Show();

                this.Hide();
            }
        }
コード例 #14
0
ファイル: UI.cs プロジェクト: yairdana/MemoryGame
 private static void checkMatchingCardsAndUpdateBoard(MemoryGame i_Game, string i_FirstCardIndex, string i_SecondCardIndex, out bool io_IsAMacth)
 {
     io_IsAMacth = i_Game.IsCardsMatch(i_FirstCardIndex, i_SecondCardIndex);
     if (io_IsAMacth)
     {
         PrintGoodMatch();
         i_Game.IncreasePoints();
     }
     else
     {
         PrintBadMatch();
         i_Game.Board.HideCard(i_FirstCardIndex);
         i_Game.Board.HideCard(i_SecondCardIndex);
     }
 }
コード例 #15
0
        private void SinglePlayerButton_Click(object sender, EventArgs e)
        {
            counter = 60;
            f       = new MainWindow();
            m       = new MemoryGameSinglePlayer(f);

            q.Close();
            m.AddPictures();
            f.Show();
            f.Refresh();
            m.TurnFaceCard();
            f.Refresh();
            showFaceCardsTimer.Interval = 3000;
            showFaceCardsTimer.Enabled  = true;

            f.countdownLbl.Visible = true;

            CountdownTimer.Start();
            playMultiplayerBtn.Text  = "Play Multiplayer";
            PlaySinglePlayerBtn.Text = "Replay";
        }
コード例 #16
0
ファイル: MemoryGame.cs プロジェクト: IvanaJ/MemoryGame
        private void timer2_Tick(object sender, EventArgs e)
        {
            time        -= 1;
            label18.Text = "Time = " + time;
            if (time == 0)
            {
                SoundPlayer sound1 = new SoundPlayer(Properties.Resources.game_over);
                sound1.Play();
                if (MessageBox.Show("Дали сакате нова игра?", "Нова игра", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    sound1.Stop();
                    MemoryGame newform = new MemoryGame();
                    this.Hide();
                    newform.ShowDialog();
                }
                else
                {
                    Application.Exit();
                }
                label18.Text = "Game finished";

                this.Enabled = false;
            }
        }