Wednesday, August 3, 2011

Find Items (Game) [www.ScriptHood.com]

This is a small game in which player finds the given items from the list of items.I hope you will enjoy.






Download this project from: www.ScriptHood.com

Thursday, July 28, 2011

Tic Tac Toe (Game) [www.ScriptHood.com]

Tic-Tac-Toe, is a classic game for two players, X and O, who take turns marking the spaces in a 3×3 grid. The X player usually goes first. The player who succeeds in placing three respective marks in a horizontal, vertical, or diagonal row wins the game.Below are the source code of this game which I wrote in C#.




Tic Tac Toe :

Download this project from: www.ScriptHood.com


Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TicTacToe
{
    /// 
    /// Interaction logic for MainWindow.xaml
    /// 
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            for (int i = 0; i < 9; i++)
            {
                isClicked[i] = false;
            }

            msgBox.Text = "X starts first!";
            scoreX.Text = scrX.ToString();
            scoreO.Text = scrO.ToString();

        }

        int scrX = 0;
        int scrO = 0;

        bool X = true;
        bool O = false;

        bool signal = false;
        bool[] isClicked = new bool[9];

        int counter = 0;
        string[] array={"0","0","0","0","0","0","0","0","0"};


        private void winnerX()
        {
            MessageBox.Show("Winner is X", "Winner", MessageBoxButton.OK, MessageBoxImage.Information);
            msgBox.Text = "Winner is X. Restart game !";
            scrX++;
            scoreX.Text = scrX.ToString();
            
        }
        private void winnerO()
        {
            MessageBox.Show("Winner is O","Winner",MessageBoxButton.OK,MessageBoxImage.Information);
            msgBox.Text = "Winner is O. Restart game !";
            scrO++;
            scoreO.Text = scrO.ToString();
 
        }
        private void isDrawBattle()
        {
            if ((counter == 9) && !(CheckForWin()))
            {
                MessageBox.Show("Draw battle", "Winner", MessageBoxButton.OK, MessageBoxImage.Information);
                msgBox.Text = "Draw battle";
            }
 
        }
        
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            int button = 0;

            if (signal)
            {
                return;
            }

            if (isClicked[0])
            {
                return;
            }
            
            if (X && (counter < 9))
            {
                msgBox.Text="Now its X's turn !";
                button1.Content = "X";
                array[button] = "x";
                X = false;
                O = true;
                if (!signal)
                {
                    msgBox.Text = "Now its O's turn !";
                }
            }
            else if (O && (counter < 9))
            {
                msgBox.Text = "Not its O's turn !";
                button1.Content = "O";
                array[button] = "o";
                O = false;
                X = true;
                if (!signal)
                {
                    msgBox.Text = "Now its X's turn !";
                }
            }
            else return;
            counter++;

            isClicked[0] = true;

            if (CheckForWin())
            {
                return;
            }

            isDrawBattle();
        }
                
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            int button = 1;

            if (signal)
            {
                return;
            }
            if (isClicked[1])
            {
                return;
            }

            if (X && (counter < 9))
            {
                msgBox.Text = "Now its X's turn !";
                button2.Content = "X";
                array[button] = "x";
                X = false;
                O = true;
                if (!signal)
                {
                    msgBox.Text = "Now its O's turn !";
                }
            }
            else if (O && (counter < 9))
            {
                msgBox.Text = "Now its O's turn !";
                button2.Content = "O";
                array[button] = "o";
                O = false;
                X = true;
                if (!signal)
                {
                    msgBox.Text = "Now its X's turn !";
                }
            }
            else return;
            counter++;
            isClicked[1] = true;

            if (CheckForWin())
            {
                return;
            }

            isDrawBattle();
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            int button = 2;

            if (signal)
            {
                return;
            }
            if (isClicked[2])
            {
                return;
            }

            if (X && (counter < 9))
            {
                msgBox.Text = "Now its X's turn !";
                button3.Content = "X";
                array[button] = "x";
                X = false;
                O = true;
                if (!signal)
                {
                    msgBox.Text = "Now its O's turn !";
                }
            }
            else if (O && (counter < 9))
            {
                msgBox.Text = "Now its O's turn !";
                button3.Content = "O";
                array[button] = "o";
                O = false;
                X = true;
                if (!signal)
                {
                    msgBox.Text = "Now its X's turn !";
                }
            }
            else return;
            counter++;
            isClicked[2] = true;

            if (CheckForWin())
            {
                return;
            }

            isDrawBattle();
        }

        private void button4_Click(object sender, RoutedEventArgs e)
        {
            int button = 3;

            if (signal)
            {
                return;
            }
            if (isClicked[3])
            {
                return;
            }

            if (X && (counter < 9))
            {
                msgBox.Text = "Now its X's turn !";
                button4.Content = "X";
                array[button] = "x";
                X = false;
                O = true;
                if (!signal)
                {
                    msgBox.Text = "Now its O's turn !";
                }
            }
            else if (O && (counter < 9))
            {
                msgBox.Text = "Now its O's turn !";
                button4.Content = "O";
                array[button] = "o";
                O = false;
                X = true;
                if (!signal)
                {
                    msgBox.Text = "Now its X's turn !";
                }
            }
            else return;
            counter++;
            isClicked[3] = true;

            if (CheckForWin())
            {
                return;
            }
            isDrawBattle();
        }

        private void button5_Click(object sender, RoutedEventArgs e)
        {
            int button = 4;

            if (signal)
            {
                return;
            }
            if (isClicked[4])
            {
                return;
            }

            if (X   &&  (counter < 9))
            {
                msgBox.Text = "Now its X's turn !";
                button5.Content = "X";
                array[button] = "x";
                X = false;
                O = true;
                if (!signal)
                {
                    msgBox.Text = "Now its O's turn !";
                }
            }
            else if (O && (counter < 9))
            {
                msgBox.Text = "Now its O's turn !";
                button5.Content = "O";
                array[button] = "o";
                O = false;
                X = true;
                if (!signal)
                {
                    msgBox.Text = "Now its X's turn !";
                }
            }
            else return;
            counter++;
            isClicked[4] = true;

            if (CheckForWin())
            {
                return;
            }

            isDrawBattle();
        }

        private void button6_Click(object sender, RoutedEventArgs e)
        {
            int button = 5;

            if (signal)
            {
                return;
            }
            if (isClicked[5])
            {
                return;
            }

            if (X && (counter<9))
            {
                msgBox.Text = "Now its X's turn !";
                button6.Content = "X";
                array[button] = "x";
                X = false;
                O = true;
                if (!signal)
                {
                    msgBox.Text = "Now its O's turn !";
                }
            }
            else if (O && (counter < 9))
            {
                msgBox.Text = "Now its O's turn !";
                button6.Content = "O";
                array[button] = "o";
                O = false;
                X = true;
                if (!signal)
                {
                    msgBox.Text = "Now its X's turn !";
                }
            }

            else return;
            counter++;
            isClicked[5] = true;

            if (CheckForWin())
            {
                return;
            }

            isDrawBattle();
        }

        private void button7_Click(object sender, RoutedEventArgs e)
        {
            int button = 6;

            if (signal)
            {
                return;
            }
            if (isClicked[6])
            {
                return;
            }

            if (X && (counter < 9))
            {
                msgBox.Text = "Now its X's turn !";
                button7.Content = "X";
                array[button] = "x";
                X = false;
                O = true;
                if (!signal)
                {
                    msgBox.Text = "Now its O's turn !";
                }
            }
            else if (O && (counter < 9))
            {
                msgBox.Text = "Now its O's turn !";
                button7.Content = "O";
                array[button] = "o";
                O = false;
                X = true;
                if (!signal)
                {
                    msgBox.Text = "Now its X's turn !";
                }
            }
            else return;
            counter++;
            isClicked[6] = true;

            if (CheckForWin())
            {
                return;
            }
            isDrawBattle();
        }

        private void button8_Click(object sender, RoutedEventArgs e)
        {
            int button = 7;

            if (signal)
            {
                return;
            }
            if (isClicked[7])
            {
                return;
            }

            if (X && (counter < 9))
            {
                msgBox.Text = "Now its X's turn !";
                button8.Content = "X";
                array[button] = "x";
                X = false;
                O = true;
                if (!signal)
                {
                    msgBox.Text = "Now its O's turn !";
                }
            }
            else if (O && (counter < 9))
            {
                msgBox.Text = "Now its O's turn !";
                button8.Content = "O";
                array[button] = "o";
                O = false;
                X = true;
                if (!signal)
                {
                    msgBox.Text = "Now its X's turn !";
                }
            }
            else return;
            counter++;
            isClicked[7] = true;

            if (CheckForWin())
            {
                return;
            }
            isDrawBattle();
        }

        private void button9_Click(object sender, RoutedEventArgs e)
        {
            int button = 8;

            if (signal)
            {
                return;
            }
            if (isClicked[8])
            {
                return;
            }

            if (X && (counter < 9))
            {
                msgBox.Text = "Now its X's turn !";
                button9.Content = "X";
                array[button] = "x";
                X = false;
                O = true;
                if (!signal)
                {
                    msgBox.Text = "Now its O's turn !";
                }
            }
            else if (O && (counter < 9))
            {
                msgBox.Text = "Now its O's turn !";
                button9.Content = "O";
                array[button] = "o";
                O = false;
                X = true;
                if (!signal)
                {
                    msgBox.Text = "Now its X's turn !";
                }
            }
            else return;
            counter++;
            isClicked[8] = true;

            if (CheckForWin())
            {
                return;
            }
            isDrawBattle();
        }

        private void button10_Click(object sender, RoutedEventArgs e) /*Restart*/
        {
            button1.Content = button2.Content = button3.Content = button4.Content = button5.Content = button6.Content = button7.Content = button8.Content = button9.Content = "";
            
            for (int i = 0; i < 9; i++)
            {
                isClicked[i] = false;
            }

            msgBox.Text = "X starts first!";
            counter = 0;
            signal = false;

            X = true;
            O = false;

            for (int i = 0; i < 9; i++)
            {
                array[i] = "0";
            } 
        }

        private void button11_Click(object sender, RoutedEventArgs e)
        {
            scrX = scrO = 0;
            scoreX.Text = scrX.ToString();
            scoreO.Text = scrO.ToString();
            msgBox.Text = "Scores are reseted!";
        }


        private bool CheckForWin()
        {
            bool flag = false;

            if ((array[0] == array[1]) && (array[0] == array[2]) && (array[1] == array[2]) && (array[0] == "x"))
            {
                winnerX();
                flag = true;
            }
            else if ((array[0] == array[1]) && (array[0] == array[2]) && (array[1] == array[2]) && (array[0] == "o"))
            {
                winnerO();
                flag = true;
            }
            else if ((array[3] == array[4]) && (array[3] == array[5]) && (array[4] == array[5]) && (array[3] == "x"))
            {
                winnerX();
                flag = true;
            }
            else if ((array[3] == array[4]) && (array[3] == array[5]) && (array[4] == array[5]) && (array[3] == "o"))
            {
                winnerO();
                flag = true;
            }
            else if ((array[6] == array[7]) && (array[6] == array[8]) && (array[7] == array[8]) && (array[6] == "x"))
            {
                winnerX();
                flag = true;
            }
            else if ((array[6] == array[7]) && (array[6] == array[8]) && (array[7] == array[8]) && (array[6] == "o"))
            {
                winnerO();
                flag = true;
            }
            else if ((array[0] == array[3]) && (array[0] == array[6]) && (array[3] == array[6]) && (array[0] == "x"))
            {
                winnerX();
                flag = true;
            }
            else if ((array[0] == array[3]) && (array[0] == array[6]) && (array[3] == array[6]) && (array[0] == "o"))
            {
                winnerO();
                flag = true;
            }
            else if ((array[1] == array[4]) && (array[1] == array[7]) && (array[4] == array[7]) && (array[1] == "x"))
            {
                winnerX();
                flag = true;
            }
            else if ((array[1] == array[4]) && (array[1] == array[7]) && (array[4] == array[7]) && (array[1] == "o"))
            {
                winnerO();
                flag = true;
            }
            else if ((array[2] == array[5]) && (array[2] == array[8]) && (array[5] == array[8]) && (array[2] == "x"))
            {
                winnerX();
                flag = true;
            }
            else if ((array[2] == array[5]) && (array[2] == array[8]) && (array[5] == array[8]) && (array[2] == "o"))
            {
                winnerO();
                flag = true;
            }
            else if ((array[0] == array[4]) && (array[0] == array[8]) && (array[4] == array[8]) && (array[0] == "x"))
            {
                winnerX();
                flag = true;
            }
            else if ((array[0] == array[4]) && (array[0] == array[8]) && (array[4] == array[8]) && (array[0] == "o"))
            {
                winnerO();
                flag = true;
            }
            else if ((array[2] == array[4]) && (array[2] == array[6]) && (array[4] == array[6]) && (array[2] == "x"))
            {
                winnerX();
                flag = true;
            }
            else if ((array[2] == array[4]) && (array[2] == array[6]) && (array[4] == array[6]) && (array[2] == "o"))
            {
                winnerO();
                flag = true;
            }

            signal = flag;
            return flag;
        }

    }


}


Wednesday, July 27, 2011

Memory Game [www.ScriptHood.com]

Hello Everyone,
This is a C# code for Memory Game. The objective is to find all matching images within shortest time. I hope you will enjoy.






Memory Game :

Download this project from: www.ScriptHood.com


Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MemoryGameWFA
{
    public partial class Form1 : Form
    {

/*Images...*/

        System.Drawing.Bitmap defaultImage = MemoryGameWFA.Properties.Resources.Image1;

        System.Drawing.Bitmap bitmap11 = MemoryGameWFA.Properties.Resources.Finder;
        System.Drawing.Bitmap bitmap12 = MemoryGameWFA.Properties.Resources.Finder___Copy;
        System.Drawing.Bitmap bitmap21 = MemoryGameWFA.Properties.Resources.Folder;
        System.Drawing.Bitmap bitmap22 = MemoryGameWFA.Properties.Resources.Folder___Copy;
        System.Drawing.Bitmap bitmap31 = MemoryGameWFA.Properties.Resources.Folder_Star;
        System.Drawing.Bitmap bitmap32 = MemoryGameWFA.Properties.Resources.Folder_Star___Copy;
        System.Drawing.Bitmap bitmap41 = MemoryGameWFA.Properties.Resources.Hard_Disk;
        System.Drawing.Bitmap bitmap42 = MemoryGameWFA.Properties.Resources.Hard_Disk___Copy;
        System.Drawing.Bitmap bitmap51 = MemoryGameWFA.Properties.Resources.Hat;
        System.Drawing.Bitmap bitmap52 = MemoryGameWFA.Properties.Resources.Hat___Copy;
        System.Drawing.Bitmap bitmap61 = MemoryGameWFA.Properties.Resources.Rocket;
        System.Drawing.Bitmap bitmap62 = MemoryGameWFA.Properties.Resources.Rocket___Copy;
        System.Drawing.Bitmap bitmap71 = MemoryGameWFA.Properties.Resources.Star_Blue;
        System.Drawing.Bitmap bitmap72 = MemoryGameWFA.Properties.Resources.Star_Blue___Copy;
        System.Drawing.Bitmap bitmap81 = MemoryGameWFA.Properties.Resources.Star_Red;
        System.Drawing.Bitmap bitmap82 = MemoryGameWFA.Properties.Resources.Star_Red___Copy;

        Object[] imageObjects;
        int[] buttonList=new int[16];
        int[] tempList = new int[16];

        StringBuilder stringBuilder = new StringBuilder();
        int[] hide = new int[2];

        bool gameStart = false;
        bool[] flag=new bool[16];

        int[] buttonId = new int[3]{-1,-2,-3};
        string[] matchingItems=new string [2];

        int timeCount=0;
        int counter=0;
        int counter2 = 0;
        int hold;
/*Game over...*/

        public bool GameOver()
        {
            bool signal=true;

            for (int i = 0; i < 16; i++)
            {
                if(flag[i]!=true)
                {
                    signal=false;
                    return signal;
                }
            }
            return signal;
        }
/*Restarting...*/

        private void button17_Click(object sender, EventArgs e)
        {
            textBox1.Text = "Game is restarted";
            
            counter = 0;
            counter2 = 0;

            /*Timer initialization*/
            gameStart = false;
            timer2.Stop();
            label2.Text = "0";
            timeCount = 0;
            button18.Enabled = true;

            buttonId[0] = -1;
            buttonId[1] = -2;
            for (int i = 0; i < 16; i++)
            {
                button1.BackgroundImage = button2.BackgroundImage = button3.BackgroundImage = button3.BackgroundImage = button4.BackgroundImage = button5.BackgroundImage = button6.BackgroundImage = button7.BackgroundImage =  button8.BackgroundImage= button9.BackgroundImage= button10.BackgroundImage= button11.BackgroundImage= button12.BackgroundImage= button13.BackgroundImage= button14.BackgroundImage= button15.BackgroundImage= button16.BackgroundImage=defaultImage; 
            }
            this.Reset();
        }

/*Default Constructor*/
        public Form1()
        {
            InitializeComponent();
            this.Reset();
        }

              
/*Initializations...*/

        public void Reset()
        {
            int temp;
            imageObjects = new Object[16] { bitmap11, bitmap12, bitmap21, bitmap22, bitmap31, bitmap32, bitmap41, bitmap42, bitmap51, bitmap52, bitmap61, bitmap62, bitmap71, bitmap72, bitmap81, bitmap82 };

            
            Random randomizer = new Random();

            for (int i = 0; i < 16; i++)
            {
                flag[i] = false;
            }

            for (int i = 0; i < 16; i++)
            {
                tempList[i] = -1;
            }

            for (int i = 0; i < 16; i++)
            {
                temp = randomizer.Next(16);


                while (IsUsed(temp))
                {
                    temp = randomizer.Next(16);

                }

                buttonList[i] = temp;
                tempList[i] = temp;

            }

          
        }

        private bool IsUsed(int temp)
        {
            bool flags = false;

            for (int i = 0; i < 16; i++)
            {
                if (tempList[i] == temp)
                {
                    flags = true;
                }

            }
            return flags;
        }

/*Timer...*/
        private void button18_Click(object sender, EventArgs e)
        {
            gameStart = true;
            timer2.Enabled = true;
            button18.Enabled = false;
            timeCount = 0;
            textBox1.Text = "Game is started.Hurry up ! :-)";
            label2.Text = timeCount.ToString();
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            label2.Text = (++timeCount).ToString();
        }

/*Matching pairs...*/
        public void HideImage(int num)
        {
            switch (num)
            {
                case 0: button1.BackgroundImage = defaultImage;
                    break;
                case 1: button2.BackgroundImage = defaultImage;
                    break;
                case 2: button3.BackgroundImage = defaultImage;
                    break;
                case 3: button4.BackgroundImage = defaultImage;
                    break;
                case 4: button5.BackgroundImage = defaultImage;
                    break;
                case 5: button6.BackgroundImage = defaultImage;
                    break;
                case 6: button7.BackgroundImage = defaultImage;
                    break;
                case 7: button8.BackgroundImage = defaultImage;
                    break;
                case 8: button9.BackgroundImage = defaultImage;
                    break;
                case 9: button10.BackgroundImage = defaultImage;
                    break;
                case 10: button11.BackgroundImage = defaultImage;
                    break;
                case 11: button12.BackgroundImage = defaultImage;
                    break;
                case 12: button13.BackgroundImage = defaultImage;
                    break;
                case 13: button14.BackgroundImage = defaultImage;
                    break;
                case 14: button15.BackgroundImage = defaultImage;
                    break;
                case 15: button16.BackgroundImage = defaultImage;
                    break;

            }
 
        }
        public string isMatching(int num)
        {
            string result="";

            switch(num)
            {
                case 0: result= "finder";
                    break;
                case 1: result= "finder";
                    break;
                case 2: result = "folder";
                    break;
                case 3: result = "folder";
                    break;
                case 4: result = "folderstar";
                    break;
                case 5: result = "folderstar";
                    break;
                case 6: result = "hard";
                    break;
                case 7: result = "hard";
                    break;
                case 8: result = "hat";
                    break;
                case 9: result = "hat";
                    break;
                case 10: result = "rocket";
                    break;
                case 11: result = "rocket";
                    break;
                case 12: result = "starblue";
                    break;
                case 13: result = "starblue";
                    break;
                case 14: result = "starred";
                    break;
                case 15: result = "starred";
                    break;
                
            }

            return result;

         }

/* Buttons...*/

        private void button1_Click(object sender, EventArgs e)
        {
            if (!gameStart)
            {
                textBox1.Text = "Please start game!";
                return;
            }   
            
            if (flag[0])
            {
                return;
            }

//////////////////////////////////////////
            if (counter2 > 1)
            {
                counter2 = 0;
            }
            buttonId[counter2] = 1;
            if (buttonId[0] == buttonId[1])
            {
                textBox1.Text = "same button twice";
                buttonId[counter2] = -10;
                
                return;
            }
            else if ((counter == 1) && buttonId[0] != buttonId[1])
            {
                buttonId[0] = -1;
                buttonId[1] = -2;
            }
            counter2++;
///////////////////////////////////////////

            textBox1.Text = "";

            if ( (counter>1) && (matchingItems[0] != matchingItems[1]))
            {
                HideImage(hide[0]);
                HideImage(hide[1]);
               
                counter = 0;
            }
            else if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;
 
            }

            if (counter > 1)
            { counter = 0; }

                                  
            hold=buttonList[0];
            matchingItems[counter] = isMatching(hold);
            

            hide[counter] = 0;
           
            button1.BackgroundImage = (Bitmap)imageObjects[buttonList[0]];


            if ((matchingItems[0] != matchingItems[1]) && counter==1)
            {
                textBox1.Text = "Images don't match :(";

            }
            else if ((matchingItems[0] == matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Good job :)";
            }

            counter++;

            if (GameOver())
            {
                timer2.Stop();
                stringBuilder.AppendLine("You are done :-)");
                stringBuilder.AppendLine("You finished in");
                stringBuilder.Append(label2.Text);
                stringBuilder.Append(" seconds");
                MessageBox.Show(stringBuilder.ToString(), "Game Over");
            }


            ////////////////////////////
            if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }
            ///////////////////////////
        }

        private void button2_Click(object sender, EventArgs e)
        {
            
            if (!gameStart)
            {
                textBox1.Text = "Please start game!";
                return;
            }
            
            if (flag[1])
            {
                return;
            }

            //////////////////////////////////////////
            if (counter2 > 1)
            {
                counter2 = 0;
            }
            buttonId[counter2] = 2;
            if (buttonId[0] == buttonId[1])
            {
                textBox1.Text = "same button twice";
                buttonId[counter2] = -10;
                return;
            }
            else if ((counter == 1) && buttonId[0] != buttonId[1])
            {
                buttonId[0] = -1;
                buttonId[1] = -2;
            }
            counter2++;
            ///////////////////////////////////////////

            textBox1.Text = "";

            if ( (counter>1) && (matchingItems[0] != matchingItems[1]))
            {
                HideImage(hide[0]);
                HideImage(hide[1]);
                
                counter = 0;
            }
            else if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }

            if (counter > 1)
            { counter = 0; }
                                                
            hold=buttonList[1];
            matchingItems[counter] = isMatching(hold);


            hide[counter] = 1;
            
            button2.BackgroundImage = (Bitmap)imageObjects[buttonList[1]];

            if ((matchingItems[0] != matchingItems[1]) && counter==1)
            {
                textBox1.Text = "Images don't match :(";

            }
            else if ((matchingItems[0] == matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Good job :)";
            }
            counter++;

            //////////////
            if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }
            //////////////

            if (GameOver())
            {
                timer2.Stop();
                stringBuilder.AppendLine("You are done :-)");
                stringBuilder.AppendLine("You finished in");
                stringBuilder.Append(label2.Text);
                stringBuilder.Append(" seconds");
                MessageBox.Show(stringBuilder.ToString(), "Game Over");
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (!gameStart)
            {
                textBox1.Text = "Please start game!";
                return;
            }
            
            if (flag[2])
            {
                return;
            }

            //////////////////////////////////////////
            if (counter2 > 1)
            {
                counter2 = 0;
            }
            buttonId[counter2] = 3;
            if (buttonId[0] == buttonId[1])
            {
                textBox1.Text = "same button twice";
                buttonId[counter2] = -10;
                return;
            }
            else if ((counter == 1) && buttonId[0] != buttonId[1])
            {
                buttonId[0] = -1;
                buttonId[1] = -2;
            }
            counter2++;
            ///////////////////////////////////////////
            textBox1.Text = "";

            if ((counter>1) && (matchingItems[0] != matchingItems[1]))
            {
                HideImage(hide[0]);
                HideImage(hide[1]);
                
                counter = 0;
            }
            else if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }

            if (counter > 1)
            { counter = 0; }

            
            hold = buttonList[2];
            matchingItems[counter] = isMatching(hold);


            hide[counter] = 2;
            button3.BackgroundImage = (Bitmap)imageObjects[buttonList[2]];
            if ((matchingItems[0] != matchingItems[1]) && counter==1)
            {
                textBox1.Text = "Images don't match :(";

            }
            else if ((matchingItems[0] == matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Good job :)";
            }
            counter++;

            //////////////
            if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }
            //////////////

            if (GameOver())
            {
                timer2.Stop();
                stringBuilder.AppendLine("You are done :-)");
                stringBuilder.AppendLine("You finished in");
                stringBuilder.Append(label2.Text);
                stringBuilder.Append(" seconds");
                MessageBox.Show(stringBuilder.ToString(), "Game Over");
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (!gameStart)
            {
                textBox1.Text = "Please start game!";
                return;
            }  
            if (flag[3])
            {
                return;
            }

            //////////////////////////////////////////
            if (counter2 > 1)
            {
                counter2 = 0;
            }
            buttonId[counter2] = 4;
            if (buttonId[0] == buttonId[1])
            {
                textBox1.Text = "same button twice";
                buttonId[counter2] = -10;
                return;
            }
            else if ((counter == 1) && buttonId[0] != buttonId[1])
            {
                buttonId[0] = -1;
                buttonId[1] = -2;
            }
            counter2++;
            ///////////////////////////////////////////
            textBox1.Text = "";

            if ((counter > 1) && (matchingItems[0] != matchingItems[1]))
            {
                HideImage(hide[0]);
                HideImage(hide[1]);
                
                counter = 0;
            }
            else if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }

            if (counter > 1)
            { counter = 0; }

            hold = buttonList[3];
            matchingItems[counter] = isMatching(hold);

            hide[counter] = 3;

            button4.BackgroundImage = (Bitmap)imageObjects[buttonList[3]];

            if ((matchingItems[0] != matchingItems[1]) && counter==1)
            {
                textBox1.Text = "Images don't match :(";

            }
            else if ((matchingItems[0] == matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Good job :)";
            }
            counter++;

            //////////////
            if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }
            //////////////

            if (GameOver())
            {
                timer2.Stop();
                stringBuilder.AppendLine("You are done :-)");
                stringBuilder.AppendLine("You finished in");
                stringBuilder.Append(label2.Text);
                stringBuilder.Append(" seconds");
                MessageBox.Show(stringBuilder.ToString(), "Game Over");
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            if (!gameStart)
            {
                return;
            }  
            if (flag[4])
            {
                return;
            }

            //////////////////////////////////////////
            if (counter2 > 1)
            {
                counter2 = 0;
            }
            buttonId[counter2] = 5;
            if (buttonId[0] == buttonId[1])
            {
                textBox1.Text = "same button twice";
                buttonId[counter2] = -10;
                return;
            }
            else if ((counter == 1) && buttonId[0] != buttonId[1])
            {
                buttonId[0] = -1;
                buttonId[1] = -2;
            }
            counter2++;
            ///////////////////////////////////////////
            textBox1.Text = "";

            if ((counter > 1) && (matchingItems[0] != matchingItems[1]))
            {
                HideImage(hide[0]);
                HideImage(hide[1]);

                counter = 0;
            }
            else if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }

            if (counter > 1)
            { counter = 0; }

            hold = buttonList[4];
            matchingItems[counter] = isMatching(hold);

            hide[counter] = 4;

            button5.BackgroundImage = (Bitmap)imageObjects[buttonList[4]];
            if ((matchingItems[0] != matchingItems[1]) && counter==1)
            {
                textBox1.Text = "Images don't match :(";

            }
            else if ((matchingItems[0] == matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Good job :)";
            }
            counter++;
            //////////////
            if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }
            //////////////
            if (GameOver())
            {
                timer2.Stop();
                stringBuilder.AppendLine("You are done :-)");
                stringBuilder.AppendLine("You finished in");
                stringBuilder.Append(label2.Text);
                stringBuilder.Append(" seconds");
                MessageBox.Show(stringBuilder.ToString(), "Game Over");
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            if (!gameStart)
            {
                textBox1.Text = "Please start game!";
                return;
            }  
            if (flag[5])
            {
                return;
            }

            //////////////////////////////////////////
            if (counter2 > 1)
            {
                counter2 = 0;
            }
            buttonId[counter2] = 6;
            if (buttonId[0] == buttonId[1])
            {
                textBox1.Text = "same button twice";
                buttonId[counter2] = -10;
                return;
            }
            else if ((counter == 1) && buttonId[0] != buttonId[1])
            {
                buttonId[0] = -1;
                buttonId[1] = -2;
            }
            counter2++;
            ///////////////////////////////////////////
            textBox1.Text = "";

            if ((counter > 1) && (matchingItems[0] != matchingItems[1]))
            {
                HideImage(hide[0]);
                HideImage(hide[1]);

                counter = 0;
            }

            else if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }

            if (counter > 1)
            { counter = 0; }

            hold = buttonList[5];
            matchingItems[counter] = isMatching(hold);

            hide[counter] = 5;

            button6.BackgroundImage = (Bitmap)imageObjects[buttonList[5]];
            if ((matchingItems[0] != matchingItems[1]) && counter==1)
            {
                textBox1.Text = "Images don't match :(";

            }
            else if ((matchingItems[0] == matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Good job :)";
            }
            counter++;
            //////////////
            if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }
            //////////////
            if (GameOver())
            {
                timer2.Stop();
                stringBuilder.AppendLine("You are done :-)");
                stringBuilder.AppendLine("You finished in");
                stringBuilder.Append(label2.Text);
                stringBuilder.Append(" seconds");
                MessageBox.Show(stringBuilder.ToString(), "Game Over");
            }
        }

        private void button7_Click(object sender, EventArgs e)
        {
            if (!gameStart)
            {
                textBox1.Text = "Please start game!";
                return;
            }  
            if (flag[6])
            {
                return;
            }

            //////////////////////////////////////////
            if (counter2 > 1)
            {
                counter2 = 0;
            }
            buttonId[counter2] = 7;
            if (buttonId[0] == buttonId[1])
            {
                textBox1.Text = "same button twice";
                buttonId[counter2] = -10;
                return;
            }
            else if ((counter == 1) && buttonId[0] != buttonId[1])
            {
                buttonId[0] = -1;
                buttonId[1] = -2;
            }
            counter2++;
            ///////////////////////////////////////////
            textBox1.Text = "";

            if ((counter > 1) && (matchingItems[0] != matchingItems[1]))
            {
                HideImage(hide[0]);
                HideImage(hide[1]);

                counter = 0;
            }

            else if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }

            if (counter > 1)
            { counter = 0; }

            hold = buttonList[6];
            matchingItems[counter] = isMatching(hold);

            hide[counter] = 6;

            button7.BackgroundImage = (Bitmap)imageObjects[buttonList[6]];
            if ((matchingItems[0] != matchingItems[1]) && counter==1)
            {
                textBox1.Text = "Images don't match :(";

            }
            else if ((matchingItems[0] == matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Good job :)";
            }
            counter++;
            //////////////
            if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }
            //////////////
            if (GameOver())
            {
                timer2.Stop();
                stringBuilder.AppendLine("You are done :-)");
                stringBuilder.AppendLine("You finished in");
                stringBuilder.Append(label2.Text);
                stringBuilder.Append(" seconds");
                MessageBox.Show(stringBuilder.ToString(), "Game Over");
            }
        }

        private void button8_Click(object sender, EventArgs e)
        {
            if (!gameStart)
            {
                textBox1.Text = "Please start game!";
                return;
            }  
            if (flag[7])
            {
                return;
            }

            //////////////////////////////////////////
            if (counter2 > 1)
            {
                counter2 = 0;
            }
            buttonId[counter2] = 8;
            if (buttonId[0] == buttonId[1])
            {
                textBox1.Text = "same button twice";
                buttonId[counter2] = -10;
                return;
            }
            else if ((counter == 1) && buttonId[0] != buttonId[1])
            {
                buttonId[0] = -1;
                buttonId[1] = -2;
            }
            counter2++;
            ///////////////////////////////////////////
            textBox1.Text = "";

            if ((counter > 1) && (matchingItems[0] != matchingItems[1]))
            {
                HideImage(hide[0]);
                HideImage(hide[1]);

                counter = 0;
            }

            if (counter > 1)
            { counter = 0; }

            hold = buttonList[7];
            matchingItems[counter] = isMatching(hold);

            hide[counter] = 7;

            button8.BackgroundImage = (Bitmap)imageObjects[buttonList[7]];

            if ((matchingItems[0] != matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Images don't match :(";

            }
            else if ((matchingItems[0] == matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Good job :)";
            }
            counter++;
            //////////////
            if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }
            //////////////
            if (GameOver())
            {
                timer2.Stop();
                stringBuilder.AppendLine("You are done :-)");
                stringBuilder.AppendLine("You finished in");
                stringBuilder.Append(label2.Text);
                stringBuilder.Append(" seconds");
                MessageBox.Show(stringBuilder.ToString(), "Game Over");
            }
            
        }

        private void button9_Click(object sender, EventArgs e)
        {
            if (!gameStart)
            {
                textBox1.Text = "Please start game!";
                return;
            }  
            if (flag[8])
            {
                return;
            }

            //////////////////////////////////////////
            if (counter2 > 1)
            {
                counter2 = 0;
            }
            buttonId[counter2] = 9;
            if (buttonId[0] == buttonId[1])
            {
                textBox1.Text = "same button twice";
                buttonId[counter2] = -10;
                return;
            }
            else if ((counter == 1) && buttonId[0] != buttonId[1])
            {
                buttonId[0] = -1;
                buttonId[1] = -2;
            }
            counter2++;
            ///////////////////////////////////////////
            textBox1.Text = "";

            if ((counter > 1) && (matchingItems[0] != matchingItems[1]))
            {
                HideImage(hide[0]);
                HideImage(hide[1]);

                counter = 0;
            }

            else if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }

            if (counter > 1)
            { counter = 0; }

            hold = buttonList[8];
            matchingItems[counter] = isMatching(hold);

            hide[counter] = 8;
            button9.BackgroundImage = (Bitmap)imageObjects[buttonList[8]];

            if ((matchingItems[0] != matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Images don't match :(";

            }
            else if ((matchingItems[0] == matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Good job :)";
            }

            counter++;
            //////////////
            if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }
            //////////////
            if (GameOver())
            {
                timer2.Stop();
                stringBuilder.AppendLine("You are done :-)");
                stringBuilder.AppendLine("You finished in");
                stringBuilder.Append(label2.Text);
                stringBuilder.Append(" seconds");
                MessageBox.Show(stringBuilder.ToString(), "Game Over");
            }
        }

        private void button10_Click(object sender, EventArgs e)
        {
            if (!gameStart)
            {
                textBox1.Text = "Please start game!";
                return;
            }  
            if (flag[9])
            {
                return;
            }

            //////////////////////////////////////////
            if (counter2 > 1)
            {
                counter2 = 0;
            }
            buttonId[counter2] = 10;
            if (buttonId[0] == buttonId[1])
            {
                textBox1.Text = "same button twice";
                buttonId[counter2] = -10;
                return;
            }
            else if ((counter == 1) && buttonId[0] != buttonId[1])
            {
                buttonId[0] = -1;
                buttonId[1] = -2;
            }
            counter2++;
            ///////////////////////////////////////////
            textBox1.Text = "";

            if ((counter > 1) && (matchingItems[0] != matchingItems[1]))
            {
                HideImage(hide[0]);
                HideImage(hide[1]);

                counter = 0;
            }

            if (counter > 1)
            { counter = 0; }

            hold = buttonList[9];
            matchingItems[counter] = isMatching(hold);

            hide[counter] = 9;

            button10.BackgroundImage = (Bitmap)imageObjects[buttonList[9]];
            if ((matchingItems[0] != matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Images don't match :(";

            }
            else if ((matchingItems[0] == matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Good job :)";
            }

            counter++;
            //////////////
            if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }
            //////////////
            if (GameOver())
            {
                timer2.Stop();
                stringBuilder.AppendLine("You are done :-)");
                stringBuilder.AppendLine("You finished in");
                stringBuilder.Append(label2.Text);
                stringBuilder.Append(" seconds");
                MessageBox.Show(stringBuilder.ToString(), "Game Over");
            }
        }

        private void button11_Click(object sender, EventArgs e)
        {
            if (!gameStart)
            {
                textBox1.Text = "Please start game!";
                return;
            }  
            if (flag[10])
            {
                return;
            }

            //////////////////////////////////////////
            if (counter2 > 1)
            {
                counter2 = 0;
            }
            buttonId[counter2] = 11;
            if (buttonId[0] == buttonId[1])
            {
                textBox1.Text = "same button twice";
                buttonId[counter2] = -10;
                return;
            }
            else if ((counter == 1) && buttonId[0] != buttonId[1])
            {
                buttonId[0] = -1;
                buttonId[1] = -2;
            }
            counter2++;
            ///////////////////////////////////////////
            textBox1.Text = "";

            if ((counter > 1) && (matchingItems[0] != matchingItems[1]))
            {
                HideImage(hide[0]);
                HideImage(hide[1]);

                counter = 0;
            }

            else if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }

            if (counter > 1)
            { counter = 0; }

            hold = buttonList[10];
            matchingItems[counter] = isMatching(hold);

            hide[counter] = 10;

            button11.BackgroundImage = (Bitmap)imageObjects[buttonList[10]];
            if ((matchingItems[0] != matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Images don't match :(";

            }
            else if ((matchingItems[0] == matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Good job :)";
            }

            counter++;
            //////////////
            if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }
            //////////////
            if (GameOver())
            {
                timer2.Stop();
                stringBuilder.AppendLine("You are done :-)");
                stringBuilder.AppendLine("You finished in");
                stringBuilder.Append(label2.Text);
                stringBuilder.Append(" seconds");
                MessageBox.Show(stringBuilder.ToString(), "Game Over");
            }
        }

        private void button12_Click(object sender, EventArgs e)
        {
            if (!gameStart)
            {
                textBox1.Text = "Please start game!";
                return;
            }  
            if (flag[11])
            {
                return;
            }

            //////////////////////////////////////////
            if (counter2 > 1)
            {
                counter2 = 0;
            }
            buttonId[counter2] = 12;
            if (buttonId[0] == buttonId[1])
            {
                textBox1.Text = "same button twice";
                buttonId[counter2] = -10;
                return;
            }
            else if ((counter == 1) && buttonId[0] != buttonId[1])
            {
                buttonId[0] = -1;
                buttonId[1] = -2;
            }
            counter2++;
            ///////////////////////////////////////////
            textBox1.Text = "";

            if ((counter > 1) && (matchingItems[0] != matchingItems[1]))
            {
                HideImage(hide[0]);
                HideImage(hide[1]);

                counter = 0;
            }

            else if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }

            if (counter > 1)
            { counter = 0; }

            hold = buttonList[11];
            matchingItems[counter] = isMatching(hold);

            hide[counter] = 11;

            button12.BackgroundImage = (Bitmap)imageObjects[buttonList[11]];
            if ((matchingItems[0] != matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Images don't match :(";

            }
            else if ((matchingItems[0] == matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Good job :)";
            }

            counter++;
            //////////////
            if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }
            //////////////
            if (GameOver())
            {
                timer2.Stop();
                stringBuilder.AppendLine("You are done :-)");
                stringBuilder.AppendLine("You finished in");
                stringBuilder.Append(label2.Text);
                stringBuilder.Append(" seconds");
                MessageBox.Show(stringBuilder.ToString(), "Game Over");
            }
        }

        private void button13_Click(object sender, EventArgs e)
        {
            if (!gameStart)
            {
                textBox1.Text = "Please start game!";
                return;
            }  
            if (flag[12])
            {
                return;
            }

            //////////////////////////////////////////
            if (counter2 > 1)
            {
                counter2 = 0;
            }
            buttonId[counter2] = 13;
            if (buttonId[0] == buttonId[1])
            {
                textBox1.Text = "same button twice";
                buttonId[counter2] = -10;
                return;
            }
            else if ((counter == 1) && buttonId[0] != buttonId[1])
            {
                buttonId[0] = -1;
                buttonId[1] = -2;
            }
            counter2++;
            ///////////////////////////////////////////
            textBox1.Text = "";

            if ((counter > 1) && (matchingItems[0] != matchingItems[1]))
            {
                HideImage(hide[0]);
                HideImage(hide[1]);

                counter = 0;
            }

            else if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }

            if (counter > 1)
            { counter = 0; }

            hold = buttonList[12];
            matchingItems[counter] = isMatching(hold);

            hide[counter] = 12;

            button13.BackgroundImage = (Bitmap)imageObjects[buttonList[12]];

            if ((matchingItems[0] != matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Images don't match :(";

            }
            else if ((matchingItems[0] == matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Good job :)";
            }

            counter++;
            //////////////
            if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }
            //////////////
            if (GameOver())
            {
                timer2.Stop();
                stringBuilder.AppendLine("You are done :-)");
                stringBuilder.AppendLine("You finished in");
                stringBuilder.Append(label2.Text);
                stringBuilder.Append(" seconds");
                MessageBox.Show(stringBuilder.ToString(), "Game Over");
            }
        }

        private void button14_Click(object sender, EventArgs e)
        {
            if (!gameStart)
            {
                textBox1.Text = "Please start game!";
                return;
            }  
            if (flag[13])
            {
                return;
            }

            //////////////////////////////////////////
            if (counter2 > 1)
            {
                counter2 = 0;
            }
            buttonId[counter2] = 14;
            if (buttonId[0] == buttonId[1])
            {
                textBox1.Text = "same button twice";
                buttonId[counter2] = -10;
                return;
            }
            else if ((counter == 1) && buttonId[0] != buttonId[1])
            {
                buttonId[0] = -1;
                buttonId[1] = -2;
            }
            counter2++;
            ///////////////////////////////////////////
            textBox1.Text = "";

            if ((counter > 1) && (matchingItems[0] != matchingItems[1]))
            {
                HideImage(hide[0]);
                HideImage(hide[1]);

                counter = 0;
            }

            else if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }

            if (counter > 1)
            { counter = 0; }

            hold = buttonList[13];
            matchingItems[counter] = isMatching(hold);

            hide[counter] = 13;

            button14.BackgroundImage = (Bitmap)imageObjects[buttonList[13]];
            if ((matchingItems[0] != matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Images don't match :(";

            }
            counter++;
            //////////////
            if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }
            //////////////
            if (GameOver())
            {
                timer2.Stop();
                stringBuilder.AppendLine("You are done :-)");
                stringBuilder.AppendLine("You finished in");
                stringBuilder.Append(label2.Text);
                stringBuilder.Append(" seconds");
                MessageBox.Show(stringBuilder.ToString(), "Game Over");
            }
        }

        private void button15_Click(object sender, EventArgs e)
        {
            if (!gameStart)
            {
                textBox1.Text = "Please start game!";
                return;
            }  
            if (flag[14])
            {
                return;
            }
            //////////////////////////////////////////
            if (counter2 > 1)
            {
                counter2 = 0;
            }
            buttonId[counter2] = 15;
            if (buttonId[0] == buttonId[1])
            {
                textBox1.Text = "same button twice";
                buttonId[counter2] = -10;
                return;
            }
            else if ((counter == 1) && buttonId[0] != buttonId[1])
            {
                buttonId[0] = -1;
                buttonId[1] = -2;
            }
            counter2++;
            ///////////////////////////////////////////
            textBox1.Text = "";

            if ((counter > 1) && (matchingItems[0] != matchingItems[1]))
            {
                HideImage(hide[0]);
                HideImage(hide[1]);

                counter = 0;
            }

            else if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }

            if (counter > 1)
            { counter = 0; }

            hold = buttonList[14];
            matchingItems[counter] = isMatching(hold);

            hide[counter] = 14;

            button15.BackgroundImage = (Bitmap)imageObjects[buttonList[14]];

            if ((matchingItems[0] != matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Images don't match :(";

            }
            else if ((matchingItems[0] == matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Good job :)";
            }

            counter++;
            //////////////
            if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }
            //////////////
            if (GameOver())
            {
                timer2.Stop();
                stringBuilder.AppendLine("You are done :-)");
                stringBuilder.AppendLine("You finished in");
                stringBuilder.Append(label2.Text);
                stringBuilder.Append(" seconds");
                MessageBox.Show(stringBuilder.ToString(), "Game Over");
            }
        }

        private void button16_Click(object sender, EventArgs e)
        {
            if (!gameStart)
            {
                textBox1.Text = "Please start game!";
                return;
            }  
            if (flag[15])
            {
                return;
            }

            //////////////////////////////////////////
            if (counter2 > 1)
            {
                counter2 = 0;
            }
            buttonId[counter2] = 16;
            if (buttonId[0] == buttonId[1])
            {
                textBox1.Text = "same button twice";
                buttonId[counter2] = -10;
                return;
            }
            else if ((counter == 1) && buttonId[0] != buttonId[1])
            {
                buttonId[0] = -1;
                buttonId[1] = -2;
            }
            counter2++;
            ///////////////////////////////////////////
            textBox1.Text = "";

            if ((counter > 1) && (matchingItems[0] != matchingItems[1]))
            {
                HideImage(hide[0]);
                HideImage(hide[1]);

                counter = 0;
            }

            else if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }

            if (counter > 1)
            { counter = 0; }

            hold = buttonList[15];
            matchingItems[counter] = isMatching(hold);

            hide[counter] = 15;

            button16.BackgroundImage = (Bitmap)imageObjects[buttonList[15]];

            if ((matchingItems[0] != matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Images don't match :(";

            }
            else if ((matchingItems[0] == matchingItems[1]) && counter == 1)
            {
                textBox1.Text = "Good job :)";
            }

            counter++;
            //////////////
            if ((counter > 1) && (matchingItems[0] == matchingItems[1]))
            {
                flag[hide[0]] = true;
                flag[hide[1]] = true;

            }
            //////////////
            if (GameOver())
            {
                timer2.Stop();
                stringBuilder.AppendLine("You are done :-)");
                stringBuilder.AppendLine("You finished in");
                stringBuilder.Append(label2.Text);
                stringBuilder.Append(" seconds");
                MessageBox.Show(stringBuilder.ToString(), "Game Over");
            }
        }

        
        
              
               
    }
}

Deal or No Deal (Game) [www.ScriptHood.com]

This is C# code for Deal or No Deal game. The player chooses a boxes to knock an amount of money off the board.The objective is to leave the game with greatest amount.There are 21 boxes. Each time a player opens 3 boxes her or she receives an offer with an option to accept or reject an offer.The last box will be the amount the player leaves with.I hope you will find it useful.






Deal or No Deal :

Download this project from: www.ScriptHood.com


Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DealNotDeal
{
    /// 
    /// Interaction logic for MainWindow.xaml
    /// 
    public partial class MainWindow : Window
    {
        long[] scoreList = new long[21] { 100, 200, 300, 400, 500, 800, 1000, 5000, 8000, 10000, 15000, 20000, 30000, 50000, 60000, 80000, 100000, 130000, 160000, 180000, 200000 };
        long[] buttonList = new long[21];
        long[] offerGen = new long[21] { 100, 200, 300, 400, 500, 800, 1000, 5000, 8000, 10000, 15000, 20000, 30000, 50000, 60000, 80000, 100000, 130000, 160000, 180000, 200000 };
        int[] tempList=new int[21];

        long finalValue;

        bool[] buttonFlag = new bool[21];

        long newOffer;
        bool accept = false;

        int offerCounter=0;
        int offerRemainder;
        string tempLabel;
        Random random = new Random();

        

        public MainWindow()
        {
            int temp;

                for (int i = 0; i < 21; i++)
                {
                    buttonFlag[i] = false;
                }

                for (int i = 0; i < 21; i++)
                {
                    tempList[i] = 30;
                }

                for (int i = 0; i < 21; i++)
                {
                    temp = random.Next(21);


                    while (IsUsed(temp))
                    {
                        temp = random.Next(21);

                    }

                    buttonList[i] = scoreList[temp];
                    tempList[i] = temp;

                }

                InitializeComponent();

        }

        private bool IsUsed(int temp)
        {
            bool flag = false;

            for (int i = 0; i < 21; i++)
            {
                if (tempList[i] == temp)
                {
                    flag= true;
                }
                
            }
            return flag;
        }
        private void LostValues(string p)
        {
            if (label1.Content.ToString() == p)
            {
                label1.Content += "     (lost)";
 
            }
            else if (label2.Content.ToString() == p)
            {
                label2.Content += "     (lost)";

            }
            else if (label3.Content.ToString() == p)
            {
                label3.Content += "     (lost)";

            }
            else if (label4.Content.ToString() == p)
            {
                label4.Content += "     (lost)";

            }
            else if (label5.Content.ToString() == p)
            {
                label5.Content += "     (lost)";

            }
            else if (label6.Content.ToString() == p)
            {
                label6.Content += "     (lost)";

            }
            else if (label7.Content.ToString() == p)
            {
                label7.Content += "   (lost)";

            }
            else if (label8.Content.ToString() == p)
            {
                label8.Content += "   (lost)";

            }
            else if (label9.Content.ToString() == p)
            {
                label9.Content += "   (lost)";

            }
            else if (label10.Content.ToString() == p)
            {
                label10.Content += " (lost)";

            }
            else if (label11.Content.ToString() == p)
            {
                label11.Content += "     (lost)";

            }
            else if (label12.Content.ToString() == p)
            {
                label12.Content += "     (lost)";

            }
            else if (label13.Content.ToString() == p)
            {
                label13.Content += "     (lost)";

            }
            else if (label14.Content.ToString() == p)
            {
                label14.Content += "     (lost)";

            }
            else if (label15.Content.ToString() == p)
            {
                label15.Content += "     (lost)";

            }
            else if (label16.Content.ToString() == p)
            {
                label16.Content += "     (lost)";

            }
            else if (label17.Content.ToString() == p)
            {
                label17.Content += "   (lost)";

            }
            else if (label18.Content.ToString() == p)
            {
                label18.Content += "   (lost)";

            }
            else if (label19.Content.ToString() == p)
            {
                label19.Content += "   (lost)";

            }
            else if (label20.Content.ToString() == p)
            {
                label20.Content += "   (lost)";

            }
            else if (label21.Content.ToString() == p)
            {
                label21.Content += "   (lost)";

            }


        }

        private void GenerateNewOffer()
        {
            long sum = 0;
            long avg;
            
            for (int i = 0; i < 21; i++)
            {
                sum += offerGen[i];
                
            }
            avg = sum / (21 - offerCounter);
            newOffer = avg;

        }
        private void CallZero(string tempLabel)
        {
            long val = Convert.ToInt64(tempLabel);
            for (int i = 0; i < 21; i++)
            {
                if (offerGen[i] == val)
                {
                    offerGen[i] = 0;
                }
 
            }
        }

        private long GetFinalValue()
        {
            for (int i = 0; i < 21; i++)
            {
                if (offerGen[i] != 0)
                {
                    finalValue = offerGen[i];
                }
            }

            return finalValue;
        }
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[0])
            {
                return;
            }
            buttonFlag[0] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;


            button1.Content=tempLabel=buttonList[0].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel+"\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue= GetFinalValue();
                MessageBox.Show("Game is over.You won "+finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
            
        }

             

                        
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[1])
            {
                return;
            }
            buttonFlag[1] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button2.Content =tempLabel= buttonList[1].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[2])
            {
                return;
            }
            buttonFlag[2] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button3.Content=tempLabel = buttonList[2].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button4_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[3])
            {
                return;
            }
            buttonFlag[3] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button4.Content = tempLabel = buttonList[3].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button5_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[4])
            {
                return;
            }
            buttonFlag[4] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button5.Content = tempLabel = buttonList[4].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button6_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[5])
            {
                return;
            }
            buttonFlag[5] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button6.Content = tempLabel = buttonList[5].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button7_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[6])
            {
                return;
            }
            buttonFlag[6] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button7.Content = tempLabel = buttonList[6].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button8_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[7])
            {
                return;
            }
            buttonFlag[7] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button8.Content = tempLabel = buttonList[7].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button9_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[8])
            {
                return;
            }
            buttonFlag[8] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button9.Content = tempLabel = buttonList[8].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button10_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[9])
            {
                return;
            }
            buttonFlag[9] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button10.Content = tempLabel = buttonList[9].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button11_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[10])
            {
                return;
            }
            buttonFlag[10] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button11.Content = tempLabel = buttonList[10].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button12_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[11])
            {
                return;
            }
            buttonFlag[11] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button12.Content = tempLabel = buttonList[11].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button13_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[12])
            {
                return;
            }
            buttonFlag[12] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button13.Content = tempLabel = buttonList[12].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button14_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[13])
            {
                return;
            }
            buttonFlag[13] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button14.Content = tempLabel = buttonList[13].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button15_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[14])
            {
                return;
            }
            buttonFlag[14] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button15.Content = tempLabel = buttonList[14].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button16_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[15])
            {
                return;
            }
            buttonFlag[15] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button16.Content = tempLabel = buttonList[15].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button17_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[16])
            {
                return;
            }
            buttonFlag[16] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button17.Content = tempLabel = buttonList[16].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button18_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[17])
            {
                return;
            }
            buttonFlag[17] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button18.Content = tempLabel = buttonList[17].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button19_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[18])
            {
                return;
            }
            buttonFlag[18] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button19.Content = tempLabel = buttonList[18].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button20_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[19])
            {
                return;
            }
            buttonFlag[19] = true;
            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button20.Content = tempLabel = buttonList[19].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button21_Click(object sender, RoutedEventArgs e)
        {
            if (buttonFlag[20])
            {
                return;
            }
            buttonFlag[20] = true;

            if (accept)
            {
                return;
            }
            textBox2.Text = "";
            textBox1.Text = "";
            offerCounter++;

            button21.Content = tempLabel = buttonList[20].ToString();
            LostValues(tempLabel);
            textBox1.Text = "-> You just opened " + tempLabel + "\n";

            CallZero(tempLabel);

            if (offerCounter == 20)
            {
                finalValue = GetFinalValue();
                MessageBox.Show("Game is over.You won " + finalValue.ToString());

                textBox1.Text = "Game is over" + "\n";
                textBox1.Text += "You Won: " + finalValue.ToString();
                label28.Content = "You Won:";
                label29.Content = finalValue.ToString();
                textBlock1.Text = "Game Over";
                accept = true;
            }

            if (offerCounter <= 18)
            {
                if ((offerCounter % 3) == 0)
                {
                    GenerateNewOffer();
                    textBox1.Text += "-> You have a new offer ";
                    MessageBox.Show("You received an offer !");
                    textBox2.Text = newOffer.ToString();
                }
                else
                {
                    offerRemainder = 3 - (offerCounter % 3);
                    textBox1.Text += "-> Open " + offerRemainder.ToString() + " more box(es) for a new offer";

                }
            }
            else textBox2.Text = "";
        }

        private void button24_Click(object sender, RoutedEventArgs e) // REJECT
        {
            if (accept)
            {
                return;
            }
            if (textBox2.Text == "")
            {
                return;
            }
            accept = false;
            textBox1.Text = "Open new box(es)";
            textBox2.Text = "";
        }

        private void button22_Click(object sender, RoutedEventArgs e) // ACCEPT
        {
            if (textBox2.Text == "")
            {
                return;
            }
            accept = true;
            textBox1.Text = "Game is over"+"\n";
            textBox1.Text += "You Won: " + textBox2.Text;
            label28.Content = "You Won:";
            label29.Content = textBox2.Text;
            textBlock1.Text = "Game Over";
        }

        private void button23_Click(object sender, RoutedEventArgs e)// RESTART
        {
            int temp;
            // Declarations...

            
            newOffer = 0;
            accept = false;
            offerCounter = 0;
            offerRemainder=0;
            tempLabel = "";

           
            
            textBox1.Text = textBox2.Text = "";
            textBlock1.Text = "";
            label28.Content = label29.Content = "";
            
            // Initializations...
            for (int i = 0; i < 21; i++)
            {
                buttonFlag[i] = false;
            }

            for (int i = 0; i < 21; i++)
            {
                tempList[i] = 30;
            }

            for (int i = 0; i < 21; i++)
            {
                temp = random.Next(21);


                while (IsUsed(temp))
                {
                    temp = random.Next(21);

                }

                buttonList[i] = scoreList[temp];
                tempList[i] = temp;

            }
            //Buttons...
            button1.Content = "1";
            button2.Content = "2";
            button3.Content = "3";
            button4.Content = "4";
            button5.Content = "5";
            button6.Content = "6";
            button7.Content = "7";
            button8.Content = "8";
            button9.Content = "9";
            button10.Content = "10";
            button11.Content = "11";
            button12.Content = "12";
            button13.Content = "13";
            button14.Content = "14";
            button15.Content = "15";
            button16.Content = "16";
            button17.Content = "17";
            button18.Content = "18";
            button19.Content = "19";
            button20.Content = "20";
            button21.Content = "21";

            //Label contents...
            label1.Content = "100";
            label2.Content = "200";
            label3.Content = "300";
            label4.Content = "400";
            label5.Content = "500";
            label6.Content = "800";
            label7.Content = "1000";
            label8.Content = "5000";
            label9.Content = "8000";
            label10.Content = "10000";
            label11.Content = "15000";
            label12.Content = "20000";
            label13.Content = "30000";
            label14.Content = "50000";
            label15.Content = "60000";
            label16.Content = "80000";
            label17.Content = "100000";
            label18.Content = "130000";
            label19.Content = "160000";
            label20.Content = "180000";
            label21.Content = "200000";



        }
         
    }
}