//mortgage public override void ClickUI() { base.ClickUI(); if (!MenuManager.TradingMode) { Street street = property.GetComponent <Street>(); if (!MenuManager.BuildHouseMode) { if (property.CanMortagage()) { property.Mortgage(); } else if (street != null && street.CanSellHouse()) { street.SellHouse(); } //can only unmortgage if player does not need to pay anything else if (property.Mortgaged && MenuManager.PaymentOptions.enabled == false) { property.UnMortgage(); } } else if (MenuManager.BuildHouseMode) { if (street != null) { street.BuildHouse(); } } return; } //check if AI is currently trading, and disable clicking if it is if ((TradingSystem.CounterOfferInProgress && TradingSystem.Tradee.gameObject.GetComponent <AI>() != null) || (!TradingSystem.CounterOfferInProgress && GameManager.CurrentPlayer.gameObject.GetComponent <AI>() != null)) { return; } TradingSystem.ToggleCardInOffer(property); }
//Add AI pays when a collect from everyone card is picked up void Update() { if (timer == 0) { Player playerComp = gameObject.GetComponent <Player>(); if (GameManager.CurrentPlayer == playerComp || CardCollect.currentPayee == playerComp || TradingSystem.Tradee == playerComp) { if (MenuManager.TurnOptions.enabled == true) { if (!MenuManager.BuildHouseMode) { //check if a player has anything to trade bool tradingPartnerExists = false; foreach (Player player in GameManager.Players) { if (player != playerComp && player.PropertiesOwned.Count > 0) { tradingPartnerExists = true; break; } } //has % chance to intitate trading if amount of offers this turn have not been exceded if (tradingPartnerExists && offers < MAX_OFFERS_PER_TURN && UnityEngine.Random.Range(0f, 1f) < CHANCE_OF_TRADING_BEFORE_ROLL) { Click(MenuManager.Trade); } else { //Build house if possible - update this for different AI modes bool canBuildHouse = false; foreach (Property property in GameManager.CurrentPlayer.PropertiesOwned) { if (property.GetComponent <Street>() != null && property.GetComponent <Street>().CanBuildHouse()) { canBuildHouse = true; break; } } if (canBuildHouse) { Click(MenuManager.BuildHouse); } else { Click(MenuManager.Roll); } } } else { //Build house on heighest value streets - update this for different AI modes bool houseBuilt = false; for (byte i = (byte)(GameManager.CurrentPlayer.PropertiesOwned.Count - 1); i >= 0; i--) { foreach (Property property in GameManager.CurrentPlayer.PropertiesOwned) { Street street = property.GetComponent <Street>(); if (street != null && street.CanBuildHouse()) { street.BuildHouse(); houseBuilt = true; break; } } if (houseBuilt) { Click(MenuManager.BuildHouse); break; } } } } else if (MenuManager.EndOfTurnOptions.enabled == true) { if (!Click(MenuManager.Buy)) { if (!Click(MenuManager.Auction)) { //reset number of trade offers AI has attempted offers = 0; Click(MenuManager.NextTurn); } } } else if (MenuManager.PaymentOptions.enabled == true) { if (!(GameManager.ActiveCard is CardCollect) || CardCollect.currentPayee == GameManager.CurrentPlayer) { if (!Click(MenuManager.Pay)) { Mortgage(); } } } else if (MenuManager.PaymentTileOptions.enabled == true) { int potentialFunds = GameManager.CurrentPlayer.GetTotalPotentialBalance() + GameManager.CurrentPlayer.GetBalance() / 10; if (potentialFunds > 200) //may need to change the 200 for super tax tile { Click(MenuManager.PayFixed); } else { Click(MenuManager.PayPercentage); } } else if (MenuManager.CardOptions.enabled == true) { Click(MenuManager.AcknowledgeCard); } else if (MenuManager.LoseOptions.enabled == true) { Click(MenuManager.Bankrupt); } else if (TradingSystem.TradingSetup.enabled == true) { //goes back if AI has made enough offers this turn if (offers >= MAX_OFFERS_PER_TURN) { Click(TradingSystem.Back); } else { uint highestVal = 0; Button playerButton = null; //finds player who can trade the most total value //change this for different personalitites foreach (Button button in TradingSystem.TradingPartnerOptions) { if (button.interactable == true) { uint val = 0; foreach (Player player in GameManager.Players) { if (player.gameObject.name == button.GetComponentInChildren <Text>().text) { val = TradingSystem.GetTradingValue(player.PropertiesOwned); break; } } if (val >= highestVal) { highestVal = val; playerButton = button; } } } Click(playerButton); } } else if (TradingSystem.TradingOptions.enabled == true) { //if AI is the tradee if (TradingSystem.Tradee == playerComp && TradingSystem.CounterOfferInProgress) //set it up so AI does not repeat offers { TradingDecision(false); } //if AI is the trader else if (GameManager.CurrentPlayer == playerComp && !TradingSystem.CounterOfferInProgress) { TradingDecision(true); } } } } timer = timer == 0 ? TIME_BETWEEN_CLICKS + 1 : timer; timer--; }