Beispiel #1
0
 public void validateGuess()
 {
     Square s1 = new Square();
     Square s2 = new Square();
     bool tmp = true;
     foreach (Square s in squares)
     {
         if (s.isSelected)
         {
             if (tmp)
             { s1 = s; tmp = false; }
             else { s2 = s; }
         }
     }
     if (s1.image.Tag == s2.image.Tag)
     {
         SoundPlayer sound = new SoundPlayer(Properties.Resources.beep_04);
         sound.Play();
         s1.isGuessed = true;
         s2.isGuessed = true;
         s1.isSelected = false;
         s2.isSelected = false;
         hits++;
         can = true;
     }
     else
     {
         first = s1;
         second = s2;
         Timer t1 = new Timer();
         t1.Interval = 1000;
         t1.Tick += new EventHandler(t1_Tick);
         t1.Start();
     }
 }
Beispiel #2
0
 public void swap(Square x, Square y)
 {
     Square z = null;
     z = x;
     x = y;
     y = z;
 }
 public Square(Square p, Button b)
 {
     isSelected = false;
     pair = p;
     button = b;
     vedrana.Add(p);
 }
Beispiel #4
0
        public Square[] shuffle(Square[] allArray)
        {
            for (int i = allArray.Length - 1; i >= 1; i--)
            {
                int j = random.Next(0, i);
                swap(allArray[j], allArray[i]);
            }

            return allArray;
        }
Beispiel #5
0
        private void newGame()
        {
            foreach (Square s in squares)
            {
                s.isSelected = false;
                s.isGuessed = false;
                s.button.Visible = true;
            }

            Random r = new Random();
            for (int i = 0; i < 200; i++)
            {
                int index = r.Next(16);
                Square temp = new Square();
                temp.button = squares[i % 16].button;
                squares[i % 16].button = squares[index].button;
                squares[index].button = temp.button;
            }

            can = true;
            hits = 0;
            opened = 0;
            timeElapsed = 0;
            timer1.Start();
            updateTime();
            Invalidate();
        }