コード例 #1
0
 private void AsocijacijeForm_Load(object sender, EventArgs e)
 {
     PlaceScores();
     timerBox = new TimerBox(626, 63, 27, 214, this);
     Controls.Add(timerBox);
     for (int i = 0; i < 4; i++)
     {
         kolone[i] = new TextBoxRounded[5];
     }
     kolone[4] = new TextBoxRounded[1] {
         new TextBoxRounded(411f, 335f, 458f, 50f, "???", this)
     };
     for (int i = 0; i < 5; i++)
     {
         kolone[0][i]              = new TextBoxRounded(409.0 - 52.2 * (i + 1), 334.8 - 54.2 * (i + 1), 279f, 50f, "А" + (5 - i), this);
         kolone[1][i]              = new TextBoxRounded(590.7 + 52.5 * (i + 1), 334.8 - 54.2 * (i + 1), 279f, 50f, "Б" + (5 - i), this);
         kolone[2][i]              = new TextBoxRounded(409.9 - 52.5 * (i + 1), 54.5 * (i + 1) + 334.7, 279f, 50f, "В" + (5 - i), this);
         kolone[3][i]              = new TextBoxRounded(52.5 * (i + 1) + 590.7, 54.5 * (i + 1) + 334.7, 279f, 50f, "Г" + (5 - i), this);
         kolone[i][0].ResultEvent += OnResult;
     }
     for (int i = 0; i < 4; i++)
     {
         for (int j = 0; j < 5; j++)
         {
             kolone[i][j].Click += new EventHandler(TextBoxClick);
             Controls.Add(kolone[i][j]);
         }
     }
     naReduBox           = new TextBoxRounded(440f, -8f, 400f, 50f, (naRedu ? "ВИ СТЕ" : "ПРОТИВНИК ЈЕ") + " НА ПОТЕЗУ", this);
     dalje               = new TextBoxRounded(565f, 658f, 150f, 50f, "ДАЉЕ", this);
     kolone[4][0].Click += new EventHandler(TextBoxClick);
     dalje.MouseDown    += new MouseEventHandler(DaljeDown);
     naReduBox.Click    += new EventHandler(TextBoxClick);
     dalje.Click        += new EventHandler(TextBoxClick);
     Controls.Add(kolone[4][0]);
     Controls.Add(naReduBox);
     timer.Enabled = true;
     Controls.Add(dalje);
     Tick(sender, e);
     UpdateNaRedu();
     loaded = true;
     if (!naRedu)
     {
         _ = ReceiveMessageAsync();
     }
 }
コード例 #2
0
        async void TextBoxClick(object sender, EventArgs e)
        {
            if (naRedu)
            {
                TextBoxRounded textBox = (TextBoxRounded)sender;
                if (!finished && otvaranje && textBox.B < 4 && !textBox.Opened)
                {
                    RestoreTitles();
                    await chat.SendMessageAsync("open:" + textBox.K + ":" + textBox.B);

                    otvaranje      = false;
                    textBox.Text   = asocijacije[textBox.K][textBox.B][0];
                    textBox.Opened = true;
                }
                else if (!finished && (!otvaranje || (probajKonacno && textBox.K == 4) || SveOtvoreno()) && textBox.B == 4 && (probano || DifferentTextBox(textBox)) && !textBox.Opened && (OtvorenaKolona(textBox.K) || textBox.K == 4))
                {
                    RestoreTitles();
                    probano         = false;
                    backClick       = false;
                    textBox.Enabled = true;
                    textBox.ResetText();
                }
                else if (!finished && (!otvaranje || probajKonacno || SveOtvoreno()) && textBox.B == 5)
                {
                    RestoreTitles();
                    await chat.SendMessageAsync("next");

                    otvaranje = true;
                    naRedu    = false;
                    Task.Delay(500).Wait();
                    dalje.Color = TextBoxRounded.Neutralna;
                    UpdateNaRedu();
                    await ReceiveMessageAsync();
                }
                else if (!finished && DifferentTextBox(textBox))
                {
                    RestoreTitles();
                }
                textBoxOld = textBox;
            }
        }
コード例 #3
0
 bool DifferentTextBox(TextBoxRounded textBox)
 {
     return(textBoxOld == null || textBox.K != textBoxOld.K || textBox.B != textBoxOld.B || backClick);
 }
コード例 #4
0
 async void OnResult(TextBoxRounded textBox, bool addScore = true)
 {
     if (naRedu && !finished)
     {
         await chat.SendMessageAsync("result:" + textBox.K + ":" + textBox.Text);
     }
     else
     {
         otvaranje = true;
     }
     if (!finished)
     {
         await Task.Delay(750);
     }
     probano = true;
     foreach (string resenje in asocijacije[textBox.K][textBox.K == 4 ? 0 : 4])
     {
         if (IspraviCir(textBox.Text) == resenje)
         {
             int score = 0;
             for (int i = textBox.K == 4 ? 0 : textBox.K; i < (textBox.K == 4 ? 4 : textBox.K + 1); i++)
             {
                 probajKonacno = true;
                 if (!kolone[i][0].Opened)
                 {
                     score += 3;
                 }
                 for (int j = 0; j < 5; j++)
                 {
                     if (j < 4 && !kolone[i][4 - j].Opened)
                     {
                         score++;
                     }
                     if (!kolone[i][0].Opened)
                     {
                         kolone[i][4 - j].Open(asocijacije[i][j][0], finished ? TextBoxRounded.Neutralna : prvi == naRedu ? TextBoxRounded.Plava : TextBoxRounded.Crvena);
                     }
                 }
             }
             if (textBox.K == 4)
             {
                 kolone[4][0].Open(asocijacije[4][0][0], finished ? TextBoxRounded.Neutralna : prvi == naRedu ? TextBoxRounded.Plava : TextBoxRounded.Crvena);
                 timer.Enabled = false;
                 chat.Disconnect();
                 finished = true;
                 score   += 7;
             }
             if (addScore)
             {
                 AddScore(prvi == naRedu ? scoreL : scoreD, score);
             }
             if (textBox.K == 4 && Convert.ToInt32(scoreL.Text) >= Convert.ToInt32(scoreD.Text))
             {
                 naReduBox.Open((prvi ? me.ToUpper() : kolega.ToUpper()) + " ЈЕ ПОБЕДИО", TextBoxRounded.Plava);
             }
             else if (textBox.K == 4)
             {
                 naReduBox.Open((prvi ? kolega.ToUpper() : me.ToUpper()) + " ЈЕ ПОБЕДИО", TextBoxRounded.Crvena);
             }
             textBox.Opened = true;
             if (!naRedu && !finished)
             {
                 _ = ReceiveMessageAsync();
             }
             return;
         }
     }
     RestoreTitles();
     if (naRedu)
     {
         _ = ReceiveMessageAsync();
     }
     naRedu = !naRedu;
     UpdateNaRedu();
 }