private void Carde_DragDrop(object sender, DragEventArgs e) { if (lBCrads1.SelectedIndex > 0) { string a = e.Data.GetData(DataFormats.Text).ToString(); if (a[a.Length - 1] == 'T') { Carde c = (Carde)sender; int i; string messege; if (c.EnIndex == -1) { i = c.Index; messege = lBCrads1.SelectedIndex.ToString() + ";" + i.ToString() + ";you"; } else { i = c.EnIndex; messege = lBCrads1.SelectedIndex.ToString() + ";" + i.ToString() + ";enemy"; } Thread clientThread = new Thread(new ParameterizedThreadStart(controller.SendMSG)); clientThread.Start(messege); } } }
/// <summary> /// Выбор атакуемой карты /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void MouseEnemyClickNew(object sender, EventArgs e) { if (bSelectedCard) { if (sStep == true) { Invoke(new MethodInvoker(delegate() { Carde carde = (Carde)sender; foreach (Control c in YourPanel.Controls) { if (c is Carde) { c.BackColor = Color.Gray; c.BackgroundImage = Picture.Card; } } bSelectedCard = false; sAttac += carde.EnIndex.ToString(); lBCrads1.Enabled = true; })); Thread clientThread = new Thread(new ParameterizedThreadStart(controller.SendMSG)); clientThread.Start(sAttac); sAttac = ""; } } }
/// <summary> /// Выбор атакующей карты /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void MouseClickNew(object sender, EventArgs e) { if (sStep == true) { Invoke(new MethodInvoker(delegate() { Carde carde = (Carde)sender; if (carde.BackColor == Color.Gray) { foreach (Control c in YourPanel.Controls) { if (c is Carde) { c.BackColor = Color.Gray; c.BackgroundImage = Picture.Card; } } carde.BackColor = Color.Green; carde.BackgroundImage = Picture.SelectedCard; sAttac = carde.Index.ToString() + ";"; bSelectedCard = true; lBCrads1.Enabled = false; } else { foreach (Control c in YourPanel.Controls) { if (c is Carde) { c.BackColor = Color.Gray; c.BackgroundImage = Picture.Card; } } bSelectedCard = false; lBCrads1.Enabled = true; } })); } }
/// <summary> /// Метод добавления карт на стол /// </summary> /// <param name="cards">Список карт, которые необходимо добавить на стол</param> /// <param name="bordNotEmpty">Переменная определяющая, присутсявуют ли карты на столе</param> /// <param name="player">Строка, обозначающая карты кокого играка подается в метод</param> public void AddCardsOnBord(List <Card> cards, bool bordNotEmpty, string player) { if (player == "You") { if (bordNotEmpty) { cardX = 11; for (int j = 0; j < cards.Count; j++) { Minion m = (Minion)cards[j]; Carde c = new Carde { Location = new Point(cardX, 330), Namee = m.Name, Damage = m.Damage, Health = m.Health, image = (Image)Picture.ResourceManager.GetObject(m.Name), Index = j, EnIndex = -1, AllowDrop = true }; if (m.IsCharge && m.IsTaunt) { c.Vid = "Ch and Ta"; } else { if (m.IsTaunt) { c.Vid = "Taunt"; } if (m.IsCharge) { c.Vid = "Charge"; } } c.DragEnter += new DragEventHandler(Carde_DragEnter); c.DragDrop += new DragEventHandler(Carde_DragDrop); YourPanel.Controls.Add(c); c.Click += new System.EventHandler(this.MouseClickNew); cardX += 125; } } else { cardX = 11; } } else { if (bordNotEmpty) { cardX2 = 11; for (int j = 0; j < cards.Count; j++) { Minion m = (Minion)cards[j]; Carde c = new Carde { Location = new Point(cardX2, 117), Namee = m.Name, Damage = m.Damage, Health = m.Health, image = (Image)Picture.ResourceManager.GetObject(m.Name), Index = -1, EnIndex = j, Tag = "Enemy", AllowDrop = true }; if (m.IsCharge && m.IsTaunt) { c.Vid = "Ch and Ta"; } else { if (m.IsTaunt) { c.Vid = "Taunt"; } if (m.IsCharge) { c.Vid = "Charge"; } } c.DragEnter += new DragEventHandler(Carde_DragEnter); c.DragDrop += new DragEventHandler(Carde_DragDrop); YourPanel.Controls.Add(c); c.Click += new System.EventHandler(this.MouseEnemyClickNew); cardX2 += 125; } } else { cardX2 = 11; } } }
/// <summary> /// Метод добавления карты на стол /// </summary> /// <param name="card">Карта, которую необходимо добавить</param> /// <param name="index">Индекс карты</param> /// <param name="energy">Текущая енергия игрока</param> /// <param name="player">Строка, обозначающая карта кокого играка подается в метод</param> public void AddCardOnBord(Card card, int index, int energy, string player) { Minion m = (Minion)card; if (player == "You") { Carde c = new Carde { Location = new Point(cardX, 330), Size = new Size(114, 163), Namee = m.Name, Damage = m.Damage, Health = m.Health, image = (Image)Picture.ResourceManager.GetObject(m.Name), Index = index, EnIndex = -1, AllowDrop = true }; if (m.IsCharge && m.IsTaunt) { c.Vid = "Ch and Ta"; } else { if (m.IsTaunt) { c.Vid = "Taunt"; } if (m.IsCharge) { c.Vid = "Charge"; } } c.DragEnter += new DragEventHandler(Carde_DragEnter); c.DragDrop += new DragEventHandler(Carde_DragDrop); YourPanel.Controls.Add(c); c.Click += new System.EventHandler(this.MouseClickNew); cardX += 125; userPlayer1.Energy = energy; } else { Carde c = new Carde { Location = new Point(cardX2, 117), Namee = m.Name, Damage = m.Damage, Health = m.Health, image = (Image)Picture.ResourceManager.GetObject(m.Name), Index = -1, EnIndex = index, Tag = "Enemy", AllowDrop = true }; if (m.IsCharge && m.IsTaunt) { c.Vid = "Ch and Ta"; } else { if (m.IsTaunt) { c.Vid = "Taunt"; } if (m.IsCharge) { c.Vid = "Charge"; } } c.DragEnter += new DragEventHandler(Carde_DragEnter); c.DragDrop += new DragEventHandler(Carde_DragDrop); cardX2 += 125; YourPanel.Controls.Add(c); c.Click += new System.EventHandler(this.MouseEnemyClickNew); userPlayer2.Energy = energy; } }