Esempio n. 1
0
        public MemoryForm()
        {
            buttons        = new Button[(int)ButtonsCount.Max];
            visibleButtons = new List <Button>();
            copyVB         = new List <Button>();

            card = new Card();

            rnd    = new Random();
            rndNum = 0;

            sizeField = 0;

            timerGame          = new System.Windows.Forms.Timer();
            timerGame.Interval = 1000;
            timerGame.Tick    += Timer_Tick;

            time = new TimeSpan(0, 0, 0);

            sleep = new Timer();

            InitializeComponent();
            InitializeButtons();

            game = SaveBest.Open();

            labelBT.Text = game.Time;
            labelBS.Text = game.Scores.ToString();

            labelScore.Text = "0";
            label3.Text     = "0";
            labelTime.Text  = "00:00:00";

            buttonStop.Enabled = false;

            indecies1 = new List <int>();
            indecies2 = new List <int>();

            scores = 0;
            moves  = 0;

            countOpndCrds = 0;

            isEnd = false;
        }
Esempio n. 2
0
        private void StopCards_Tick(object sender, EventArgs e)
        {
            if (stopCards.Enabled)
            {
                stopCards.Stop();
                CheckForAMatch();

                if (countOpndCrds == sizeField)
                {
                    isEnd = true;
                    timerGame.Stop();
                    label4.Visible = true;

                    Game game = new Game {
                        Scores = int.Parse(labelScore.Text), Time = labelTime.Text
                    };
                    SaveBest.Save(game, labelBT, labelBS);
                }
            }
        }