public void buyTile(bool buy) { setPlayerInfo info = GetComponent <setPlayerInfo> (); realEstate realestate = _propBuys.GetComponent <realEstate> (); if (buy == true) { //can player afford it if (_playerBuys.player.money >= realestate.tile.price) { realestate.setOwner(_playerBuys); realestate.tile.owner = _playerBuys.gameObject; _playerBuys.player.money -= realestate.tile.price; _playerBuys.player.addProperty(_propBuys); buyButton.SetActive(false); } else { buyButton.SetActive(false); } } else { buyButton.SetActive(false); } // turnButton.SetActive (true); info.setInfo(_playerBuys); }
public void setInfo(movePlayer currentPlayer) { GameTileColors = GetComponent <organizeGameSpaces>().colorList; string ownings = ""; //create a dictionary of the categories of properties the player owns Dictionary <Color, int> playerCategories = new Dictionary <Color, int>(); foreach (GameObject prop in currentPlayer.player.owned) { // ownings += prop.name + "\n"; realEstate real = prop.GetComponent <realEstate> (); int posY = 0; //this is for determining whether user can buy hotels if (playerCategories.ContainsKey(real.tile.category)) { playerCategories [real.tile.category]++; // Debug.Log (currentPlayer); if (playerCategories [real.tile.category] == GameTileColors[real.tile.category]) { // Debug.Log ("buy a hotel"); propUp.upgrade(real.tile.category); } } else { playerCategories.Add(real.tile.category, 1); } ownings += prop.name + "\n"; } info.text = "Player: " + currentPlayer.gameObject.name + "\nMoney: " + currentPlayer.player.money + "\n" + ownings; }
public void rentInfo(GameObject tile, movePlayer player) { // Debug.Log ("RENTING"); realEstate prop = tile.GetComponent <realEstate> (); Text txt = rentInfoText.GetComponent <Text> (); txt.text = "Would you like to pay rent to " + prop.tile.owner + "\nAt: " + prop.tile.name + "\nFor: " + prop.tile.rent; }
//this determines whether the player lands on a property or game mech tile. //It plays after the dice is rolled, and triggers the end turn button private void turnAction(GameObject thisTile, movePlayer thisPlayer) { setPlayerInfo info = GetComponent <setPlayerInfo> (); info.setInfo(thisPlayer); //is it a property tile or a game mechanic tile? if (thisTile.GetComponent <realEstate>() != null) { realEstate property = thisTile.GetComponent <realEstate> (); Debug.Log("real estate tile"); //is it owned by a player? if (property.tile.owner != null) { Debug.Log("Someone Owns it"); //is it owned by the player? if (thisPlayer.gameObject == property.tile.owner) { Debug.Log("You Owns it"); } else { //the player chooses to pay rent or no Debug.Log(thisPlayer.gameObject.name + " Owns it"); rentButton.SetActive(true); _playerBuys = thisPlayer; _propBuys = thisTile; info.rentInfo(thisTile, thisPlayer); } info.setInfo(thisPlayer); // turnButton.SetActive (true); } else { //the player can buy the tile //set info for this specific tile buyButtonInfo.GetComponent <Text>().text = "Would you like to buy " + thisTile.name + "?\nPrice: " + property.tile.price + "\nRent: " + property.tile.rent; buyButton.SetActive(true); _playerBuys = thisPlayer; _propBuys = thisTile; } } else if (thisTile.GetComponent <goTile>() != null) { Debug.Log("game mechanic tile"); info.setInfo(thisPlayer); } endTurnButton.SetActive(true); }
public int rentCalc(realEstate property) { int houses = property.tile.houses; int hotels = property.tile.hotels; int rent = property.tile.rent; int price = property.tile.price; if (houses == 0 && hotels == 0) { return(rent); } else { if (hotels == 1) { //how much is property with hotels rent = ((price / 2) - 20) * 5 + 600; return(rent); } else if (houses == 4) { //how much is property with 4 hosues rent = ((price / 2) - 20) * 7 + 270; return(rent); } else if (houses == 3) { rent = ((price / 2) - 20) * 6 + 140; return(rent); } else if (houses == 2) { rent = ((price / 2) - 20) * 3; return(rent); } else if (houses == 1) { rent = (price / 2) - 20; return(rent); } else { return(rent); } } }
public void upgradePanel() { Debug.Log(ownedColors.Count); organizeGameSpaces tiles = GetComponent <organizeGameSpaces> (); // Dictionary<Color,int> colorDict = tiles.colorList; List <GameObject> tileList = tiles.spaces; buyUpgradePanel.SetActive(true); // Dropdown field = buyUpgradePanel.transform.FindChild("selectProperty").GetComponent<Dropdown>(); List <string> options = new List <string>(); List <GameObject> propertySpaces = new List <GameObject> (); int i = 0; field.ClearOptions(); foreach (GameObject property in tileList) { realEstate real = property.GetComponent <realEstate> (); if (real != null) { if (ownedColors.Contains(real.tile.category)) { //now we need to fill a list with the properties available to buy houses for if (real.tile.houses > i) { propertySpaces.Clear(); propertySpaces.Add(property); } else if (real.tile.houses == i) { propertySpaces.Add(property); } // options.Add(property.name); // propertySpaces.Add (property); Debug.Log("name: " + property.name); //TO DO: figure out the effin drop down add values??? Maybe switch it for series of button, gawd } } } field.AddOptions(options); buyHouses(propertySpaces[Random.Range(0, propertySpaces.Count)]); // field.AddOptions (new List<Dropdown.OptionData>()); // field.RefreshShownValue (); destroyButtons(); }
public void payRent(bool rent) { setPlayerInfo info = GetComponent <setPlayerInfo> (); realEstate realestate = _propBuys.GetComponent <realEstate> (); movePlayer owner = realestate.tile.owner.GetComponent <movePlayer> (); if (rent == true) { int rentNumber = GetComponent <determineRent>().rentCalc(realestate); _playerBuys.player.money -= realestate.tile.rent; owner.player.money += realestate.tile.rent; rentButton.SetActive(false); info.setInfo(_playerBuys); } else { rentButton.SetActive(false); } }
void groupColors(List <GameObject> tileSet) { foreach (GameObject tile in tileSet) { if (tile.GetComponent <realEstate> () != null) { realEstate prop = tile.GetComponent <realEstate> (); // Debug.Log (prop.tile.category); //add colors to a list of how many properties for each color category if (colorList.ContainsKey(prop.tile.category)) { colorList [prop.tile.category] = colorList [prop.tile.category] + 1; } else { colorList.Add(prop.tile.category, 1); } // Debug.Log (prop.tile.category + ": " + colorList [prop.tile.category]); } } }
public void buyHouses(GameObject property) { realEstate realestate = property.GetComponent <realEstate> (); movePlayer player = realestate.tile.owner.GetComponent <movePlayer> (); //find out if there's any houses on the property if (realestate.tile.houses == 4) { Debug.Log("hotel"); //delete all children houses of that tile foreach (Transform child in property.transform) { Debug.Log(child.gameObject.name); if (child.gameObject.tag == "house") { Destroy(child.gameObject); } } GameObject thisHotel = (GameObject)Instantiate(hotel, property.transform.position + new Vector3((Random.Range(0.1f, 3) / 10f) - 0.3f, 1, (Random.Range(0, 10) / 10f)), Quaternion.identity, property.transform); realestate.tile.hotels++; realestate.tile.houses = 0; player.player.money -= realestate.tile.housePrice; GetComponent <setPlayerInfo> ().setInfo(player); } else if (realestate.tile.hotels == 1) { //the property is full of houses, etc Debug.Log("no more hotels, houses"); } else { GameObject thisHouse = (GameObject)Instantiate(house, property.transform.position + new Vector3((Random.Range(0.1f, 3) / 10f) - 0.3f, 1, (Random.Range(0, 10) / 10f)), Quaternion.identity, property.transform); realestate.tile.houses++; player.player.money -= realestate.tile.housePrice; Debug.Log("house"); } realestate.updateRent(GetComponent <determineRent>()); }