private void restOfActivate() { bool?response = ModalPopup.response; // If they did want to buy if (response == true) { GameObject player = gm.GetComponent <GameManagerScript>().GetCurrentPlayer(); int playerCash = player.GetComponent <PlayerScript>().GetCash(); if (playerCash < buyCost) { InfoScript.instance().Displayer("You don't have enough money"); return; } // Update player's cash and add to their ownership player.GetComponent <PlayerScript>().RemvCash(buyCost); player.GetComponent <PlayerScript>().GetOwnedTiles().Add(gameObject); player.GetComponent <PlayerScript>().IncNumProp(); this.owner = player; InfoScript.instance().Displayer(gm.GetCurrentPlayer().GetComponent <PlayerScript>().GetName() + " has bought " + tileName + "!"); } else { InfoScript.instance().Displayer(gm.GetCurrentPlayer().GetComponent <PlayerScript>().GetName() + "didn't buy" + tileName); } }
private void restOfActivate() { bool?response = ModalPopup.response; if (response == true) { RemvCash(50); timeInJail = 0; state = State.Active; InfoScript.instance().Displayer("You're free, roll to advance."); return; } // Atempt to roll doubles lastRolled = die.RollDie(); if (die.isDouble()) { InfoScript.instance().Displayer("Rolled doubles and broke out of jail!"); timeInJail = 0; // Update location to trigger Update() locationIndex += lastRolled; //impossible to hit go from this location state = State.Moving; } else { timeInJail++; InfoScript.instance().Displayer("Did not roll doubles, stay in jail!"); gm.NextTurn(); } }
// Upgrade the property public void Upgrade(int index) { // If it can be upgraded if (rentIndex >= rent.Length - 1) { InfoScript.instance().Displayer("You cannot upgrade further."); return; } else if (isMortgaged == true) { InfoScript.instance().Displayer("Cannot upgrade mortgaged property."); return; } // If player has enough money if (owner.GetComponent <PlayerScript>().GetCash() < upgradeCost) { InfoScript.instance().Displayer("Player doesn't have enough money to upgrade."); return; } owner.GetComponent <PlayerScript>().RemvCash(upgradeCost); rentIndex++; gm.GetTileButton(index).GetComponentInChildren <Text>().text = rentIndex.ToString(); }
// Handling pay me logic public void PayMe() { if (hasBeenPaid == true) { InfoScript.instance().Displayer("Player has already been charged."); return; } // If last player to go has landed on an owned property int lastPlayerLoc = playerList[lastPlayerIndex].GetComponent <PlayerScript>().GetLocIndex(); // If tile doesn't implement IBuyTile, avoid error bool isOwned = false; try { isOwned = tilesList[lastPlayerLoc].GetComponent <IBuyTile>().IsOwned(); } catch (Exception e) { InfoScript.instance().Displayer("This tile cannot be owned!"); } // Pay money! if (isOwned) { tilesList[lastPlayerLoc].GetComponent <IBuyTile>().PayPlayer(playerList[lastPlayerIndex]); hasBeenPaid = true; } }
public override void Activate() { InfoScript.instance().Displayer(cardName + "\n" + text); gm.GetCurrentPlayer().GetComponent <PlayerScript>().SetLocIndex(0); gm.GetCurrentPlayer().GetComponent <PlayerScript>().transform.position = gm.GetTile(0).transform.position; gm.GetCurrentPlayer().GetComponent <PlayerScript>().AddCash(200); //make this a reference to go tile }
public override void Activate() { InfoScript.instance().Displayer(cardName + "\n" + text); int x = 0; //take 50 from every player and give to current player gm.GetCurrentPlayer().GetComponent <PlayerScript>().AddCash(x); }
// This property is now mortgaged. public void ToMortgaged() { if (rentIndex != 0) { InfoScript.instance().Displayer("You need to have no upgrades to mortgage."); } owner.GetComponent <PlayerScript>().AddCash(mortgageValue); isMortgaged = true; }
/* TILESCRIPT INHERITANCE */ // Buying process public override void Activate() { InfoScript.instance().Displayer(gm.GetCurrentPlayer().GetComponent <PlayerScript>().GetName() + " has landed on " + tileName); // If the tile doesn't have an owner, ask to buy if (owner == null) { StartCoroutine(ModalPopup.instance().Dialog("Buy this property?")); Invoke("restOfActivate", 4); } }
// When trying to sell public void SellTile() { if (isMortgaged == false) { InfoScript.instance().Displayer("You're trying to mortgage " + tileName); } else { InfoScript.instance().Displayer(tileName + " is already mortgaged!"); } }
/* TILESCRIPT INHERITANCE */ // Buying process public override void Activate() { InfoScript.instance().Displayer(gm.GetCurrentPlayer().GetComponent <PlayerScript>().GetName() + " has landed on " + tileName); // If the tile doesn't have an owner, ask to buy if (owner == null) { //bool response = EditorUtility.DisplayDialog(tileName, ("Would you like to buy this tile for " + buyCost + "?"), "Yes", "No"); StartCoroutine(ModalPopup.instance().Dialog("Buy this property?")); Invoke("restOfActivate", 4); } }
// REMOVE a value from cash public void RemvCash(int cash) { if (this.cash - cash < 0) { InfoScript.instance().Displayer("This player doesn't have enough money to pay"); } else { this.cash -= cash; } }
// Ends player turn private void EndTurn() { if (cash <= 0 && numProperties <= 0) { InfoScript.instance().Displayer(playerName + " has lost the game!"); } SetWaiting(); //button.SetActive(false); // Client side gm.NextTurn(); }
// Rolls two dice, upadtes previous die roll and possibly calls incDouble in gamemanager public int RollDie(int numSides) { die1 = Random.Range(1, numSides + 1); die2 = Random.Range(1, numSides + 1); if (isDouble()) { gm.IncDouble(); } InfoScript.instance().Displayer("Rolled: " + (die1 + die2) + (isDouble() ? " DOUBLE" : "")); return(die1 + die2); }
/* TILESCRIPT INHERITANCE */ // Tax either 200 or 10%. public override void Activate() { if (gm.GetCurrentPlayer().GetComponent <PlayerScript>().GetCash() >= 200) { gm.GetCurrentPlayer().GetComponent <PlayerScript>().RemvCash(200); InfoScript.instance().Displayer("You've been taxed 200!"); } else { int cash = gm.GetCurrentPlayer().GetComponent <PlayerScript>().GetCash(); gm.GetCurrentPlayer().GetComponent <PlayerScript>().RemvCash(cash / 10); InfoScript.instance().Displayer("You've been taxed 10%!"); } }
public void PressMortgageButton() { if (verifyOwner() == false) { return; } try { InfoScript.instance().Displayer("Mortgaged " + gm.GetComponent <GameManagerScript>().GetTile(lastTileIndex).GetComponent <TileScript>().GetName()); gm.GetComponent <GameManagerScript>().GetTile(lastTileIndex).GetComponent <IBuyTile>().Mortgage(); } catch (Exception e) { InfoScript.instance().Displayer("This tile cannot be mortgaged!"); } }
// Method the sell button calls public void PressSellButton() { if (verifyOwner() == false) { return; } try { InfoScript.instance().Displayer("Sold upgrade on " + gm.GetComponent <GameManagerScript>().GetTile(lastTileIndex).GetComponent <TileScript>().GetName()); gm.GetComponent <GameManagerScript>().GetTile(lastTileIndex).GetComponent <PropertyScript>().SellUpgrade(lastTileIndex); } catch (Exception e) { InfoScript.instance().Displayer("You cannot sell upgrades on this tile."); } }
// Upgrade prop public void PressUpgradeButton() { if (verifyOwner() == false) { return; } try { InfoScript.instance().Displayer("Bought upgrade on " + gm.GetComponent <GameManagerScript>().GetTile(lastTileIndex).GetComponent <TileScript>().GetName()); gm.GetComponent <GameManagerScript>().GetTile(lastTileIndex).GetComponent <PropertyScript>().Upgrade(lastTileIndex); } catch (Exception e) { InfoScript.instance().Displayer("This tile cannot be upgraded!"); } }
public void SellUpgrade(int index) { if (rentIndex <= 0) { InfoScript.instance().Displayer("There are no upgrades to sell."); return; } else if (isMortgaged == true) { InfoScript.instance().Displayer("Cannot sell upgrade on mortgaged property."); return; } // Give player cash owner.GetComponent <PlayerScript>().AddCash(upgradeCost / 2); rentIndex--; gm.GetTileButton(index).GetComponentInChildren <Text>().text = rentIndex.ToString(); }
// if current player owns property public bool verifyOwner() { try { List <GameObject> tiles = gm.GetCurrentPlayer().GetComponent <PlayerScript>().GetOwnedTiles(); GameObject selectedTile = gm.GetTile(lastTileIndex); if (tiles.Contains(selectedTile) == false) { InfoScript.instance().Displayer("You do not own this tile!"); return(false); } return(true); } catch (Exception e) { return(false); } }
// Decides how to handle mortgaging public void Mortgage() { // Already mortgaged if (isMortgaged == true) { if (owner.GetComponent <PlayerScript>().GetCash() > mortgageValue + (mortgageValue / 10)) { InfoScript.instance().Displayer("Bought back property from mortgage."); FromMortgaged(); return; } else { InfoScript.instance().Displayer("You don't have enough money to buy from mortgage."); return; } } ToMortgaged(); }
/* TILESCRIPT INHERITANCE */ // Buy tile option public override void Activate() { InfoScript.instance().Displayer("Free spot!"); }
//Pay the player when pay me button has been pressed public void PayPlayer(GameObject payer) { payer.GetComponent <PlayerScript>().RemvCash(GetRent()); owner.GetComponent <PlayerScript>().AddCash(GetRent()); InfoScript.instance().Displayer(payer.GetComponent <PlayerScript>().GetName() + " paid " + owner.GetComponent <PlayerScript>().GetName() + " " + GetRent()); }
public override void Activate() { InfoScript.instance().Displayer(cardName + "\n" + text); gm.GetCurrentPlayer().GetComponent <PlayerScript>().AddCash(50); }
/* TILESCRIPT INHERITANCE */ // standard activation method public override void Activate() { InfoScript.instance().Displayer("Just visiting jail"); }
/* TILESCRIPT INHERITANCE */ public override void Activate() { InfoScript.instance().Displayer("You're on GO!"); }