//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); }
//mortgage/sell properties when AI has enough potential funds but doesn't have enough in hand private void Mortgage() { foreach (Property property in GameManager.CurrentPlayer.PropertiesOwned) { if (property.CanMortagage()) { property.Mortgage(); return; } } //if can't mortgage AI can still sell houses foreach (Property property in GameManager.CurrentPlayer.PropertiesOwned) { Street street = property.GetComponent <Street>(); if (street != null && street.CanSellHouse()) { street.SellHouse(); return; } } }
public override void EnterUI() { base.EnterUI(); MenuManager.UpdateCardInfo(property); if (!MenuManager.TradingMode) { Street street = property.GetComponent <Street>(); if (MenuManager.BuildHouseMode) { if (street == null) { toolTip.text = "Cannot build house on this type of property"; } else if (!street.CanBuildHouse()) { toolTip.text = "House requirements not met"; } else { toolTip.text = "Build house for $" + street.HousePrice; } } else if (property.CanMortagage()) { toolTip.text = "Click to mortgage"; } else if (street != null && street.CanSellHouse()) { toolTip.text = "Click to sell house for $" + street.SellHousePrice; } else if (property.Mortgaged && MenuManager.PaymentOptions.enabled == false) { toolTip.text = "Click to unmortgage"; } else if (MenuManager.PaymentOptions.enabled == true) { toolTip.text = "Cannot unmortgage as a payment is due"; } else { toolTip.text = "House selling requirements not met"; } //change camera to property CameraFollow.target = property.transform; return; } //set tool tip based on whether property offered/who is offering Player owner = property.Owner; if (owner == GameManager.CurrentPlayer) { if (!TradingSystem.CurrentPlayerOffer.Contains(property)) { toolTip.text = !TradingSystem.CounterOfferInProgress ? "Add to offer" : "Add to demand"; return; } toolTip.text = !TradingSystem.CounterOfferInProgress ? "Remove from offer" : "Remove from demand"; return; } if (!TradingSystem.TradeeOffer.Contains(property)) { toolTip.text = !TradingSystem.CounterOfferInProgress ? "Add to demand" : "Add to offer"; return; } toolTip.text = !TradingSystem.CounterOfferInProgress ? "Remove from demand" : "Remove from offer"; }
public static void CreatePropertyCard(Transform parent, Property property, Vector2 localPosition, Vector2 sizeDelta) { Street street = property.GetComponent <Street>(); GameObject cardObj = new GameObject("InventoryCard"); Image card = cardObj.AddComponent <Image>(); card.tag = "InventoryCard"; card.transform.SetParent(parent); card.rectTransform.sizeDelta = sizeDelta; card.rectTransform.localPosition = localPosition; cardObj.AddComponent <InventoryPropertyMouseInputUI>().property = property; Text title = new GameObject().AddComponent <Text>(); title.text = property.Title; title.fontSize = 6; title.color = Color.black; title.font = Resources.GetBuiltinResource <Font>("Arial.ttf"); title.alignment = TextAnchor.UpperCenter; title.transform.SetParent(card.transform); title.rectTransform.sizeDelta = new Vector2(card.rectTransform.sizeDelta.x * 4 / 5, card.rectTransform.sizeDelta.y / 6); title.rectTransform.localPosition = new Vector2(0f, 35f); if (!property.Mortgaged) { Text price = new GameObject().AddComponent <Text>(); price.text = "$" + property.Price; price.fontSize = 6; price.color = Color.black; price.font = Resources.GetBuiltinResource <Font>("Arial.ttf"); price.alignment = TextAnchor.UpperCenter; price.transform.SetParent(card.transform); price.rectTransform.sizeDelta = new Vector2(card.rectTransform.sizeDelta.x * 4 / 5, card.rectTransform.sizeDelta.y / 6); price.rectTransform.localPosition = new Vector2(0f, -40f); if (street != null) { Image streetColour = new GameObject("StreetColour").AddComponent <Image>(); streetColour.transform.SetParent(card.transform); streetColour.rectTransform.sizeDelta = new Vector2(card.rectTransform.sizeDelta.x, card.rectTransform.sizeDelta.y / 6); streetColour.rectTransform.localPosition = new Vector2(0f, card.rectTransform.sizeDelta.y / 2 - streetColour.rectTransform.sizeDelta.y / 2); streetColour.color = new Color(street.Colour.r, street.Colour.g, street.Colour.b, 1); title.rectTransform.localPosition = new Vector2(0f, 20f); //grays out street if not able to build house in house mode if (BuildHouseMode && !street.CanBuildHouse()) { DisableCard(cardObj); } } else if (property.GetComponent <Utility>() != null || property.GetComponent <RailwayStation>() != null) { Image icon = new GameObject("Icon").AddComponent <Image>(); icon.sprite = property.GetComponent <Tile>().Icon; icon.rectTransform.SetParent(card.transform); icon.rectTransform.localPosition = Vector2.zero; icon.rectTransform.sizeDelta = new Vector2(card.rectTransform.sizeDelta.x * 0.7f, card.rectTransform.sizeDelta.x * 0.7f); } } else { title.text = "MORTGAGED"; title.rectTransform.localPosition = Vector3.zero; } //grays out non-street properties if in house mode or if cant sell house, or if in payment menu and property mortgaged, or can't pay unmortgage cost if ((!TradingMode && ((BuildHouseMode && (street == null || street.Mortgaged)) || (!BuildHouseMode && street != null && !street.CanMortagage() && !street.Mortgaged && !street.CanSellHouse()) || (PaymentOptions.enabled == true && property.Mortgaged) || (property.Mortgaged && property.Owner.GetBalance() < property.UnMortgageCost))) || (TradingMode && street != null && street.Houses > 0)) { DisableCard(cardObj); } }