public static void CallTradingButtonListener(Button button) { if (button == Back) { //destroy previous cards if (TradingOptions.enabled == true) { foreach (GameObject cardObj in GameObject.FindGameObjectsWithTag("InventoryCard")) { GameObject.Destroy(cardObj); } MenuManager.SwitchToMenu(TradingSetup); MenuManager.ShowMenu(BackFromTradingOptions); } else if (Jail.InJail()) { MenuManager.SwitchToMenuWithInventory(MenuManager.InJailTurnOptions); } else { MenuManager.SwitchToMenuWithInventory(MenuManager.TurnOptions); } _tradee = null; //prevent memory leaks Resources.UnloadUnusedAssets(); } else if (button == Offer && !(MenuManager.ButtonClicked && ((Tradee.gameObject.GetComponent <AI>() != null && CounterOfferInProgress) || (GameManager.CurrentPlayer.gameObject.GetComponent <AI>() != null && !CounterOfferInProgress)))) { Text text = Offer.GetComponentInChildren <Text>(); text.text = text.text == "Offer" ? "CounterOffer" : "Offer"; _counterOffer = !_counterOffer; Accept.interactable = true; Back.interactable = !Back.interactable; UpdateCardsInTrade(); Offer.interactable = false; } else if (button == Accept && !(MenuManager.ButtonClicked && ((Tradee.gameObject.GetComponent <AI>() != null && CounterOfferInProgress) || (GameManager.CurrentPlayer.gameObject.GetComponent <AI>() != null && !CounterOfferInProgress)))) { foreach (Property property in _playerOffer) { GameManager.CurrentPlayer.RemoveProperty(property); Tradee.AddProperty(property); } foreach (Property property in _tradeeOffer) { Tradee.RemoveProperty(property); GameManager.CurrentPlayer.AddProperty(property); } _tradee = null; if (Jail.InJail()) { MenuManager.SwitchToMenuWithInventory(MenuManager.InJailTurnOptions); } else { MenuManager.SwitchToMenuWithInventory(MenuManager.TurnOptions); } } else if (Array.IndexOf(TradingPartnerOptions, button) != -1) { //set tradee to selected player foreach (Player player in GameManager.Players) { if (player.gameObject.name == button.GetComponentInChildren <Text>().text) { _tradee = player; break; } } //reset offer lists _tradeeOffer = new List <Property>(); _playerOffer = new List <Property>(); MenuManager.SwitchToMenu(TradingOptions); MenuManager.ShowMenu(BackFromTradingOptions); _counterOffer = false; Accept.interactable = false; Offer.GetComponentInChildren <Text>().text = "Offer"; UpdateCardsInTrade(); Offer.interactable = false; } }