예제 #1
0
        void RasdachaCard(bool AmIFirst, int EnemyHealth, string EnemyName, int MyHealth, int MyMana, List <CardHeroes> StartKoloda, string name, List <CardHeroes> FirstInHand)
        {
            int mana = MyMana;

            foreach (PictureBox a in pMana.Controls)
            {
                while (mana != 0)
                {
                    a.Invoke((MethodInvoker)(() =>
                                             a.Visible = true));
                    mana--;
                }
            }
            CardHand = FirstInHand;
            if (this.InvokeRequired)
            {
                lNamePlayer1.Invoke((MethodInvoker)(() => lNamePlayer1.Text = name));
                lNamePlayer2.Invoke((MethodInvoker)(() => lNamePlayer2.Text = EnemyName));
                lHealthPlayer2.Invoke((MethodInvoker)(() => lHealthPlayer2.Text = MyHealth.ToString()));
                lHealthPlayer1.Invoke((MethodInvoker)(() => lHealthPlayer1.Text = EnemyHealth.ToString()));

                for (int i = 0; i < 7; i++)
                {
                    foreach (CardsForm a in pMyHand.Controls)
                    {
                        bool flag = false;
                        a.Invoke((MethodInvoker)(() => flag = (bool)Equals(a.Image, null)));
                        if (flag)
                        {
                            CardHand[i].Index = a.Index;
                            a.Invoke((MethodInvoker)(() => a.Index = pMyHand.Controls.IndexOf(a)));
                            a.Invoke((MethodInvoker)(() => a.Image = (Image)Resource1.ResourceManager.GetObject(FirstInHand[i].Name)));
                            a.Invoke((MethodInvoker)(() => a.NameCards = FirstInHand[i].Name));
                            a.Invoke((MethodInvoker)(() => a.Power = FirstInHand[i].Power));
                            a.Invoke((MethodInvoker)(() => a.Health = FirstInHand[i].Health));
                            a.Invoke((MethodInvoker)(() => a.Price = FirstInHand[i].Price));
                            break;
                        }
                    }
                }
                if (AmIFirst == false)
                {
                    this.Invoke((MethodInvoker)(() => this.Enabled = false));
                    ENSt.Invoke((MethodInvoker)(() => ENSt.Visible = true));
                }
                else
                {
                    this.Enabled = true;
                    ENSt.Visible = false;
                }
            }
            else
            {
            }
        }
예제 #2
0
        private void cardsForm1_Click(object sender, EventArgs e)
        {
            CardsForm card = (CardsForm)sender;

            if (pEnemy.Contains((CardsForm)sender))
            {
                // lNamePlayer2.Enabled = true;
                if (card.ISPRESSED == false)
                {
                    choosenEnemyCard           = (CardsForm)sender;
                    choosenEnemyCard.ISPRESSED = true;
                    choosenEnemyCard.Index     = card.Index;
                    card.BackgroundImage       = Resource1.ВЫБРАННАЯКАРТА;
                    if (choosenEnemyCard != null && choosenEnemyCard != null)
                    {
                        Step.Visible = true;
                    }
                }
                else
                {
                    choosenEnemyCard.ISPRESSED = false;
                    choosenEnemyCard           = null;

                    card.BackgroundImage = Resource1.ФОН_ЛИСТА;
                    Step.Visible         = false;
                }
            }
            else
            if (pMyArena.Contains((CardsForm)sender))
            {
                lNamePlayer2.Enabled = true;
                if (card.ISPRESSED == false)
                {
                    choosenCard           = (CardsForm)sender;
                    choosenCard.ISPRESSED = true;
                    choosenCard.Index     = card.Index;
                    card.BackgroundImage  = Resource1.ВЫБРАННАЯКАРТА;
                    if (choosenCard != null && choosenEnemyCard != null)
                    {
                        Step.Visible = true;
                    }
                    foreach (CardsForm a in pEnemy.Controls)
                    {
                        if (this.InvokeRequired)
                        {
                            a.Invoke((MethodInvoker)(() => a.Enabled = true));
                        }
                        else
                        {
                            a.Enabled = true;
                        }
                    }
                    ENSt.Invoke((MethodInvoker)(() => ENSt.Enabled = true));
                }
                else
                {
                    choosenCard.ISPRESSED = false;
                    choosenCard           = null;

                    card.BackgroundImage = Resource1.ФОН_ЛИСТА;
                    Step.Visible         = false;
                    foreach (CardsForm a in pEnemy.Controls)
                    {
                        a.Invoke((MethodInvoker)(() => a.Enabled = false));
                    }
                    ENSt.Invoke((MethodInvoker)(() => ENSt.Enabled = false));
                }
            }
            else
            {
                if (choosenCard != sender && choosenCard != null)
                {
                    chooseFace = false;
                    choosenCard.BackgroundImage = Resource1.ФОН_ЛИСТА;
                    choosenCard.ISPRESSED       = false;
                    choosenCard = (CardsForm)sender;
                    if (!pMyArena.Contains((CardsForm)sender))
                    {
                        bArena.Visible = true;
                    }
                }
                if (card.ISPRESSED == false)
                {
                    card.BackgroundImage = Resource1.ВЫБРАННАЯКАРТА;
                    card.ISPRESSED       = true;
                    choosenCard          = card;
                    choosenCard.Index    = card.Index;
                    if (!pMyArena.Contains((CardsForm)sender))
                    {
                        bArena.Visible = true;
                    }
                }
                else
                {
                    card.BackgroundImage = Resource1.ФОН_ЛИСТА;
                    card.ISPRESSED       = false;
                    choosenCard          = null;

                    bArena.Visible = false;
                }
            }
        }
예제 #3
0
        List <CardHeroes> CardHand   = new List <CardHeroes>(); //как достать с сервера?
        private void ChangeAfterStep(bool AmIFirst, int EnemyHealth, string enemyName, int MyHealth,
                                     int MyMana, List <CardHeroes> Arena1, List <CardHeroes> Arena2, List <CardHeroes> EnemyArena1, List <CardHeroes> EnemyArena2)
        {
            int mana = MyMana;

            while (mana > 0)
            {
                if (pMana.InvokeRequired)
                {
                    pMana.Invoke((MethodInvoker)(() => pMana.Controls[mana - 1].Visible = true));
                }
                else
                {
                    pMana.Controls[mana - 1].Visible = true;
                }
                mana--;
            }

            if (this.InvokeRequired)
            {
                lHealthPlayer2.Invoke((MethodInvoker)(() => lHealthPlayer2.Text = MyHealth.ToString()));
                lHealthPlayer1.Invoke((MethodInvoker)(() => lHealthPlayer1.Text = EnemyHealth.ToString()));
                int count1 = 0; int count2 = 0;
                for (int i = 0; i < Arena1.Count; i++)
                {
                    foreach (CardsForm a in pMe.Controls)
                    {
                        if (a.Image != null)
                        {
                            if (Arena1[i].Name != null)
                            {
                                if (a.Index == Arena1[i].Index)
                                {
                                    a.Invoke((MethodInvoker)(() => a.Index = pMyHand.Controls.IndexOf(a)));
                                    a.Invoke((MethodInvoker)(() => a.Image = (Image)Resource1.ResourceManager.GetObject(Arena1[i].Name)));
                                    a.Invoke((MethodInvoker)(() => a.NameCards = Arena1[i].Name));
                                    a.Invoke((MethodInvoker)(() => a.Power = Arena1[i].Power));
                                    a.Invoke((MethodInvoker)(() => a.Health = Arena1[i].Health));
                                    a.Invoke((MethodInvoker)(() => a.Price = Arena1[i].Price));
                                    a.Invoke((MethodInvoker)(() => a.Enabled = false));

                                    break;
                                }
                            }
                        }
                    }

                    for (int j = 0; j < Arena2.Count; j++)
                    {
                        foreach (CardsForm a in pMe.Controls)
                        {
                            if (a.Image != null)
                            {
                                if (a.Index == Arena2[j].Index)
                                {
                                    if (Arena2[j].Name != null)
                                    {
                                        a.Invoke((MethodInvoker)(() => a.Index = pMyHand.Controls.IndexOf(a)));
                                        a.Invoke((MethodInvoker)(() => a.Image = (Image)Resource1.ResourceManager.GetObject(Arena2[j].Name)));
                                        a.Invoke((MethodInvoker)(() => a.NameCards = Arena2[j].Name));
                                        a.Invoke((MethodInvoker)(() => a.Power = Arena2[j].Power));
                                        a.Invoke((MethodInvoker)(() => a.Health = Arena2[j].Health));
                                        a.Invoke((MethodInvoker)(() => a.Price = Arena2[j].Price));
                                        a.Invoke((MethodInvoker)(() => a.Enabled = true));
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }


                if (AmIFirst == false)
                {
                    this.Invoke((MethodInvoker)(() => this.Enabled = false));
                    ENSt.Invoke((MethodInvoker)(() => ENSt.Visible = true));
                }
                else
                {
                    this.Invoke((MethodInvoker)(() => this.Enabled = true));
                    ENSt.Invoke((MethodInvoker)(() => ENSt.Visible = false));
                }



                foreach (CardsForm a in pEnemy.Controls)
                {
                    if (a.Image != null)
                    {
                        for (int i = 0; i < EnemyArena1.Count; i++)
                        {
                            if (EnemyArena1[i].Name != null)
                            {
                                if (a.Index == EnemyArena1[i].Index)
                                {
                                    a.Invoke((MethodInvoker)(() => a.Index = pEnemy.Controls.IndexOf(a)));
                                    a.Invoke((MethodInvoker)(() => a.Image = (Image)Resource1.ResourceManager.GetObject(EnemyArena1[i].Name)));
                                    a.Invoke((MethodInvoker)(() => a.NameCards = EnemyArena1[i].Name));
                                    a.Invoke((MethodInvoker)(() => a.Power = EnemyArena1[i].Power));
                                    a.Invoke((MethodInvoker)(() => a.Health = EnemyArena1[i].Health));
                                    a.Invoke((MethodInvoker)(() => a.Price = EnemyArena1[i].Price));
                                    a.Invoke((MethodInvoker)(() => a.Enabled = false));

                                    break;
                                }
                            }
                        }
                    }
                }
                for (int i = 0; i < EnemyArena2.Count; i++)
                {
                    foreach (CardsForm a in pEnemy.Controls)
                    {
                        if (a.Image != null)
                        {
                            if (EnemyArena2[i].Name != null)
                            {
                                if (a.Index == EnemyArena2[i].Index)
                                {
                                    a.Invoke((MethodInvoker)(() => a.Index = pEnemy.Controls.IndexOf(a)));
                                    a.Invoke((MethodInvoker)(() => a.Image = (Image)Resource1.ResourceManager.GetObject(EnemyArena2[i].Name)));
                                    a.Invoke((MethodInvoker)(() => a.NameCards = EnemyArena2[i].Name));
                                    a.Invoke((MethodInvoker)(() => a.Power = EnemyArena2[i].Power));
                                    a.Invoke((MethodInvoker)(() => a.Health = EnemyArena2[i].Health));
                                    a.Invoke((MethodInvoker)(() => a.Price = EnemyArena2[i].Price));

                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }