Пример #1
0
        private async void pictureBox_click(object sender, EventArgs e)
        {
            socarddangmo++;
            if (socarddangmo >= 3)
            {
                socarddangmo = 0;
                return;
            }

            PictureBox P = (PictureBox)(sender);

            int cardnum = Int32.Parse((P.Name.Substring(4)));

            if (LISTCARD.getCard(cardnum).getcardstatus() == 0 && PrePic == null || PrePic != null && PrePic.Name != P.Name)
            {
                object o = Properties.Resources.ResourceManager.GetObject(LISTCARD.getCard(cardnum).getcardimagename() + typeCard);
                P.Image = (Image)o;
                LISTCARD.getCard(cardnum).setcardstatus(1);



                if (cardmo1 != 0 && cardmo2 == 0)
                {
                    cardmo2 = cardnum;
                }
                else if (cardmo1 == 0)
                {
                    cardmo1 = cardnum;
                }
                //check 2 cai neu giong nhau thi...
                if (cardmo1 != 0 && cardmo2 != 0 && LISTCARD.getCard(cardmo1).getcardimagename() == LISTCARD.getCard(cardmo2).getcardimagename())
                {
                    await Task.Delay(300);

                    //SoundPlayer sp = new SoundPlayer(@"C:\Users\abc\Desktop\item lol\Ys.wav");
                    //sp.Play();

                    P.Hide();
                    PrePic.Hide();

                    socarddangmo = 0;

                    cardmo1     = 0;
                    cardmo2     = 0;
                    PrePic      = null;
                    socardxong += 2;
                    if (socardxong == _NUMCOLUMN_ * _NUMROW_)
                    {
                        ((SoloMultiplay)this.MdiParent).Win();
                    }
                }
                if (cardmo1 != 0 && cardmo2 != 0 && LISTCARD.getCard(cardmo1).getcardimagename() != LISTCARD.getCard(cardmo2).getcardimagename())
                {
                    await Task.Delay(200);

                    covercard(P);
                    covercard(PrePic);
                    socarddangmo = 0;

                    LISTCARD.getCard(cardmo1).setcardstatus(0);
                    LISTCARD.getCard(cardmo2).setcardstatus(0);
                    cardmo1 = 0;
                    cardmo2 = 0;
                    PrePic  = null;
                }
                if ((cardmo1 == 0 || cardmo2 == 0) && cardmo1 != cardmo2)
                {
                    PrePic = (PictureBox)(sender);
                }
            }
        }
Пример #2
0
        private async void pictureBox_click(object sender, EventArgs e)
        {
            socarddangmo++;
            if (socarddangmo >= 3)
            {
                socarddangmo = 0;
                return;
            }

            PictureBox P = (PictureBox)(sender);

            int cardnum = Int32.Parse((P.Name.Substring(4)));

            if (LISTCARD.getCard(cardnum).getcardstatus() == 0 && PrePic == null || PrePic != null && PrePic.Name != P.Name)
            {
                object o = Properties.Resources.ResourceManager.GetObject(LISTCARD.getCard(cardnum).getcardimagename() + typeCard);
                P.Image = (Image)o;
                LISTCARD.getCard(cardnum).setcardstatus(1);



                if (cardmo1 != 0 && cardmo2 == 0)
                {
                    cardmo2 = cardnum;
                }
                else if (cardmo1 == 0)
                {
                    cardmo1 = cardnum;
                }
                //check 2 cai neu giong nhau thi...
                if (cardmo1 != 0 && cardmo2 != 0 && LISTCARD.getCard(cardmo1).getcardimagename() == LISTCARD.getCard(cardmo2).getcardimagename())
                {
                    if (isSoundOn)
                    {
                        SPcorrect.Play();
                    }
                    await Task.Delay(300);


                    P.Hide();
                    PrePic.Hide();
                    if (LISTCARD.getCard(cardmo1).isBonusScoreCard || LISTCARD.getCard(cardmo2).isBonusScoreCard)
                    {
                        ((SinglePlay)this.MdiParent).updateScore(10);
                    }
                    else
                    {
                        ((SinglePlay)this.MdiParent).updateScore(2);
                    }
                    if (LISTCARD.getCard(cardmo1).isBonusTimeCard || LISTCARD.getCard(cardmo2).isBonusTimeCard)
                    {
                        quick += 200;
                    }
                    if (LISTCARD.getCard(cardmo1).isDangerousCard || LISTCARD.getCard(cardmo2).isDangerousCard)
                    {
                        socarddangmo = 0;
                    }

                    cardmo1     = 0;
                    cardmo2     = 0;
                    PrePic      = null;
                    socardxong += 2;

                    if (socardxong == _NUMCOLUMN_ * _NUMROW_)
                    {
                        timer1.Stop();

                        ((SinglePlay)this.MdiParent).levelPass(quick / 10);

                        this.Close();
                    }
                }
                if (cardmo1 != 0 && cardmo2 != 0 && LISTCARD.getCard(cardmo1).getcardimagename() != LISTCARD.getCard(cardmo2).getcardimagename())
                {
                    if (isSoundOn)
                    {
                        SPcorrect.Play();
                    }
                    await Task.Delay(200);

                    covercard(P);
                    covercard(PrePic);
                    socarddangmo = 0;

                    LISTCARD.getCard(cardmo1).setcardstatus(0);
                    LISTCARD.getCard(cardmo2).setcardstatus(0);
                    cardmo1 = 0;
                    cardmo2 = 0;
                    PrePic  = null;
                }
                if ((cardmo1 == 0 || cardmo2 == 0) && cardmo1 != cardmo2)
                {
                    PrePic = (PictureBox)(sender);
                }
            }
        }