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); }
//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 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); } }
//The Turn function is first triggered after the players are create in addPlayers.cs, and subsequently is //activated by the endTurn function. public void Turn() { setPlayerInfo info = GetComponent <setPlayerInfo> (); if (playerNumber == 0) { playerNumber = playerList.Count; } //determine the current player GameObject currentPlayer = playerList[currentTurn]; camera.GetComponent <moveCamera> ().move(currentPlayer); _playerBuys = currentPlayer.GetComponent <movePlayer> (); if (currentTurn == playerNumber - 1) { currentTurn = 0; } else { currentTurn++; } turnButton.SetActive(true); info.setInfo(_playerBuys); }