public void SetTokenPossition(int index) { Board_Sequence b = (Board_Sequence)(index); Control[] obj = (this.Controls.Find(b.ToString(), true)); MoveToken((PictureBox)obj[0]); }
public void CurrentBrandDecision() { Board_Sequence b = (Board_Sequence)(currentPlayer.Current_Pos); Type type_Space = Type.GetType("Empire_Monopoly.Spaces." + b.ToString().Replace("picBx", "")); object o = Activator.CreateInstance(type_Space); FieldInfo f = type_Space.GetField("img"); Image img = null; if (f != null) { img = f.GetValue(null) as Image; } FieldInfo F_Size = type_Space.GetField("size"); int billBoardSize = 0; if (F_Size != null) { billBoardSize = (int)F_Size.GetValue(o); } FieldInfo F_Price = type_Space.GetField("price"); int price = 0; if (F_Price != null) { price = (int)F_Price.GetValue(o); } //if (b.ToString() == "pixBxGo") //{ //} if (b.ToString() == "picBxJustVisiting") { NextTurn(); } else if (b.ToString() == "picBxEmpireBottom" || b.ToString() == "picBxEmpireTop") { card.DecideEmpireCard(this); DisplayEmpirecards(); NextTurn(); //if (isMoveToAnySpaceOnTheBoardCardUse == false) //{ // NextTurn(); //} } else if (b.ToString() == "picBxChanceBottom" || b.ToString() == "picBxChanceLeft" || b.ToString() == "picBxChanceRight" || b.ToString() == "picBxChanceTop") { card.DecideChanceCard(this); DisplayChanceCard(); if (isCasinoNightCardUse == false) { NextTurn(); } } //else if (b.ToString() == "picBxElectricCompany") //{ // NextTurn(); //} //else if (b.ToString() == "picBxWaterWorks") //{ // NextTurn(); //} else if (b.ToString() == "picBxFreeParking") { TakeTrip(); NextTurn(); } else if (b.ToString() == "picBxTowerTax") { currentPlayer.PayTax(ref pnlBoard); NextTurn(); } else if (b.ToString() == "picBxRivalTowerTax") { comp1.PayTax(ref pnlBoard); NextTurn(); } else if (b.ToString() == "picBxGoToJail") { GoToJail(); NextTurn(); } else { if (comp1.brandNames.Contains("," + b.ToString().Replace("picBx", "") + ",")) { Board_Sequence b_ownedBrand = (Board_Sequence)(comp1.Current_Pos); currentPlayer.PayRent(comp1, b_ownedBrand.ToString()); NextTurn(); return; } if (currentPlayer.amount < price) { MessageBox.Show("You don't have sufficient balance to purchase this brand...!!!"); NextTurn(); return; } if (MessageBox.Show("Would you like to buy this brand for $" + price.ToString() + "??", "Buy Brand??", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { currentPlayer.BuyBrand(billBoardSize, price, img, b.ToString().Replace("picBx", ""), ref pnlBoard, false); } NextTurn(); } }
private void RunComp1() { Random r = new Random(); int decide = 0; if (currentPlayer.isInJail) { decide = r.Next(1, 3); switch (decide) { case 1: currentPlayer.amount -= 100; currentPlayer.isInJail = false; MessageBox.Show("User Pais $100 to bank to get out of jail..."); NextTurn(); return; case 2: lblMsg.Text = "Roll Double (user has three chance to roll the dice)"; lblMsg.Visible = true; int i = 0; while (i <= 3) { List <int> lDiceValue = dice.RollDice(); if (lDiceValue[0] == lDiceValue[1]) { currentPlayer.isInJail = false; lblMsg.Visible = false; } i++; } if (currentPlayer.isInJail == true) { currentPlayer.amount -= 50; currentPlayer.isInJail = false; } NextTurn(); return; } } UseDice(); GetBrandSpace(); Board_Sequence b = (Board_Sequence)(currentPlayer.Current_Pos); Type type_Space = Type.GetType("Empire_Monopoly.Spaces." + b.ToString().Replace("picBx", "")); object o = Activator.CreateInstance(type_Space); FieldInfo f = type_Space.GetField("img"); Image img = null; if (f != null) { img = f.GetValue(null) as Image; } FieldInfo F_Size = type_Space.GetField("size"); int billBoardSize = 0; if (F_Size != null) { billBoardSize = (int)F_Size.GetValue(o); } FieldInfo F_Price = type_Space.GetField("price"); int price = 0; if (F_Price != null) { price = (int)F_Price.GetValue(o); } //if (b.ToString() == "pixBxGo") //{ // NextTurn(); //} if (b.ToString() == "picBxJustVisiting") { NextTurn(); } else if (b.ToString() == "picBxEmpireBottom" || b.ToString() == "picBxEmpireTop") { card.DecideEmpireCard(this); DisplayEmpirecards(); NextTurn(); } else if (b.ToString() == "picBxChanceBottom" || b.ToString() == "picBxChanceLeft" || b.ToString() == "picBxChanceRight" || b.ToString() == "picBxChanceTop") { card.DecideChanceCard(this); DisplayChanceCard(); if (isCasinoNightCardUse == false) { NextTurn(); } } //else if (b.ToString() == "picBxElectricCompany") //{ // NextTurn(); //} //else if (b.ToString() == "picBxWaterWorks") //{ // NextTurn(); //} else if (b.ToString() == "picBxFreeParking") { if (r.Next(1, 3) == 1) { int pos = r.Next(0, 36); Control[] p = this.Controls.Find(((Board_Sequence)(pos)).ToString(), true); MoveToken(p[0] as PictureBox); currentPlayer.Current_Pos = pos; currentPlayer.amount -= 100; RunComp1(); } NextTurn(); } else if (b.ToString() == "picBxTowerTax") { currentPlayer.PayTax(ref pnlBoard); NextTurn(); } else if (b.ToString() == "picBxRivalTowerTax") { human.PayTax(ref pnlBoard); NextTurn(); } else if (b.ToString() == "picBxGoToJail") { GoToJail(); NextTurn(); } else { if (human.brandNames.Contains("," + b.ToString().Replace("picBx", "") + ",")) { Board_Sequence b_ownedBrand = (Board_Sequence)(human.Current_Pos); currentPlayer.PayRent(human, b_ownedBrand.ToString()); NextTurn(); } if (currentPlayer.amount < price) { MessageBox.Show("User doesn't have sufficient balance to purchase this brand...!!!"); NextTurn(); return; } decide = r.Next(1, 3); switch (decide) { case 1: MessageBox.Show("user has decided to buy the brand..."); currentPlayer.BuyBrand(billBoardSize, price, img, b.ToString().Replace("picBx", ""), ref pnlBoard, false); NextTurn(); break; case 2: MessageBox.Show("user doesn't want to buy the brand..."); NextTurn(); return; } } }