public static CCheckBox CreateButtonCheckBoxCard(Card c, double perc, int playerid, int index, bool user) { int width = (int)(200 * perc); int height = (int)(279 * perc); Image myimage = GetImageFromCard(c); CCheckBox b = new CCheckBox() { //Text = c.ToString(), Card = c, InHand = user, PlayerId = playerid, Percentage = perc, Index = index, CardImage = myimage, BackgroundImage = myimage, Width = width, Height = height, Appearance = Appearance.Button }; b.CheckedChanged += new System.EventHandler(b.SetTransparency); b.BackgroundImage = new Bitmap(b.BackgroundImage, b.Width, b.Height); return(b); }
public string GetMoveGivenSelectedCards(List <CCheckBox> selected) { if (selected == null || selected.Count == 0) { return(null); } Card first = selected[0].Card; selected.Remove(selected[0]); switch (first.Face) { case Card.CardFace.EvolvedMedicine: case Card.CardFace.EvolvedVirus: case Card.CardFace.Medicine: case Card.CardFace.OrganThief: case Card.CardFace.Quarantine: case Card.CardFace.Virus: CCheckBox dest = selected[0]; return(Scheduler.GenerateMove(dest.PlayerId, dest.Index)); // Two cards interaction case Card.CardFace.Transplant: //if (source == null || dest == null) // // { // // return null; // // } // // return Scheduler.GetManyMoveItem(new string[] // // { // // Scheduler.GenerateMove(source.PlayerId, source.Index), // // Scheduler.GenerateMove(dest.PlayerId, dest.Index) // // }); return(null); // N cards interaction case Card.CardFace.Spreading: return(null); //case Card.CardFace.MedicalError: //case Card.CardFace.SecondOpinion: //case Card.CardFace.LatexGlove: break; //case Card.CardFace.Organ: break; //case Card.CardFace.Overtime: break; //case Card.CardFace.ProtectiveSuit: break; } return(null); }
public void SetTransparency(object sender, EventArgs e) { CCheckBox cb = (CCheckBox)sender; if (cb.Checked) { cb.BackColor = Color.Transparent; cb.BackgroundImage = FormUtilities.SetImageOpacity(CardImage, Percentage, 0.5F); } else { cb.BackgroundImage = FormUtilities.SetImageOpacity(CardImage, Percentage, 1F); } }
private void UpdatePlayerPanel(int id) { Player p = Game.Players[id]; Panel pItem; int i = 0; for (i = 0; i < p.Body.Items.Count; i++) { pItem = GetBodyItemPanel(id, i); pItem.Controls.Clear(); BodyItem item = p.Body.Items[i]; CCheckBox cb = FormUtilities.CreateButtonCheckBoxCard(item.Organ, 0.4, id, i, false); //cb.Click += CardClicked; cb.Click += CardClicked2; pItem.Controls.Add(cb); for (int j = 0; j < item.Modifiers.Count; j++) { cb = FormUtilities.CreateButtonCheckBoxCard(item.Modifiers[j], 0.25, id, i, false); //cb.Click += CardClicked; cb.Click += CardClicked2; pItem.Controls.Add(cb); } } while (i < Game.Settings.NumberToWin) { pItem = GetBodyItemPanel(id, i); pItem.Controls.Clear(); i++; } }
public void CardClicked2(object sender, EventArgs e) { CCheckBox cb = (CCheckBox)sender; switch (action) { case Action.Discarding: { // Check or uncheck card to discard or not. if (cb.Checked) { SelectedCards.Add(cb); //if (SelectedCards.Count == Game.Settings.NumberCardInHand) //{ // // Automatic click to discard all hand. // bDiscard_Click(BDiscards, e); //} } else { SelectedCards.Remove(cb); } } break; case Action.None: { if (cb.InHand) { foreach (var s in SelectedCards) { s.Checked = false; } SelectedCards.Clear(); SelectedCards.Add(cb); if (CurrentMoves == null) { CurrentMoves = Game.Referee.GetListMovements(Me, cb.Card, false); } switch (CurrentMoves.Count) { case 0: cb.Checked = false; SelectedCards.Clear(); CurrentMoves = null; break; case 1: Game.PlayGameCardByUser(Me, cb.Index, CurrentMoves, cb.Card); Game.DrawCardsToFill(Me); Game.Turn++; SelectedCards.Clear(); UpdateGUI(); CurrentMoves = null; break; default: switch (cb.Card.Face) { // Cards that only need one more card to interact with case Card.CardFace.EvolvedMedicine: case Card.CardFace.EvolvedVirus: case Card.CardFace.Medicine: case Card.CardFace.OrganThief: case Card.CardFace.Quarantine: case Card.CardFace.Virus: action = Action.OneInteraction; break; // Two cards interaction case Card.CardFace.Transplant: action = Action.TwoInteraction; break; // N cards interaction case Card.CardFace.Spreading: action = Action.ManyInteraction; break; // Cards that need a inputbox dialog case Card.CardFace.MedicalError: case Card.CardFace.SecondOpinion: { string[] options = new string[Game.Players.Count - 1]; int i = 0; foreach (Player p in Game.Players) { if (p.ID != Me.ID) { options[i] = p.Nickname; i++; } } #region DIALOG //Set buttons language Czech/English/German/Slovakian/Spanish (default English) InputBox.SetLanguage(InputBox.Language.English); //Save the DialogResult as res DialogResult res = InputBox.ShowDialog("To which player do you want to use this card?", "Play this card", //Text message (mandatory), Title (optional) InputBox.Icon.Question, //Set icon type (default info) //InputBox.Icon.Information, //Set icon type (default info) InputBox.Buttons.OkCancel, //Set buttons (default ok) InputBox.Type.ComboBox, //Set type (default nothing) options, //String field as ComboBox items (default null) true //Set visible in taskbar (default false) ); #endregion //Check InputBox result if (res == System.Windows.Forms.DialogResult.OK || res == System.Windows.Forms.DialogResult.Yes) { string user = InputBox.ResultValue; string move; foreach (Player p in Game.Players) { if (p.Nickname == user) { move = Scheduler.GenerateMove(p.ID, 0); Game.PlayUserCardByMove(Me, cb.Card, move, CurrentMoves); } } } SelectedCards.Clear(); CurrentMoves = null; } break; // Cards that doesn't need any other interaction case Card.CardFace.LatexGlove: break; case Card.CardFace.Organ: break; case Card.CardFace.Overtime: break; case Card.CardFace.ProtectiveSuit: break; } break; } } else { cb.Checked = false; CurrentMoves = null; } } break; case Action.OneInteraction: if (!cb.InHand) { SelectedCards.Add(cb); bool movedone = false; if (SelectedCards.Count > 0 && CurrentMoves != null && cb.Card.Face == Card.CardFace.Organ) { Card selected = SelectedCards[0].Card; string move = Game.GetMoveGivenSelectedCards(SelectedCards); if (move != null) { movedone = Game.PlayUserCardByMove(Me, selected, move, CurrentMoves); } } if (movedone) { Game.DrawCardsToFill(Me); Game.Turn++; UpdateGUI(); CurrentMoves = null; } else { cb.Checked = false; foreach (var c in SelectedCards) { c.Checked = false; } SelectedCards.Clear(); CurrentMoves = null; } } else { ClearAllCheckedCardHand(); SelectedCards.Clear(); CurrentMoves = null; cb.Checked = false; action = Action.None; } break; } SetSelected(); }