From 33834069d371e2fa3d1a7e87efeb1a6a6dc41723 Mon Sep 17 00:00:00 2001 From: smyalygames Date: Thu, 5 Mar 2020 15:24:13 +0000 Subject: [PATCH] Fixed up the classes with voids --- Assets/board.cs | 2 + Assets/player.cs | 8 +-- Assets/properties.cs | 158 ++++++++++++++++++++++--------------------- 3 files changed, 86 insertions(+), 82 deletions(-) diff --git a/Assets/board.cs b/Assets/board.cs index 2fc363f..2c46bd4 100644 --- a/Assets/board.cs +++ b/Assets/board.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using properties; public class board : MonoBehaviour { @@ -9,6 +10,7 @@ public class board : MonoBehaviour { public int houses; //Initialising houses public int hotels; //Initialising hotels + List cards = new List; public Board() { diff --git a/Assets/player.cs b/Assets/player.cs index 98af6df..2940083 100644 --- a/Assets/player.cs +++ b/Assets/player.cs @@ -13,10 +13,10 @@ public class player : MonoBehaviour public Player() { - + money = 1500; } - public Move(int length) //This moves the player a certain length (what they got from rolling the dice). + public void Move(int length) //This moves the player a certain length (what they got from rolling the dice). { if (position + length < 40) //Checks if the player will not pass go. { @@ -30,12 +30,12 @@ public class player : MonoBehaviour } } - public goToJail() //If the player needs to go to jail. + public void goToJail() //If the player needs to go to jail. { position = 40; //Special position for jail. } - public getOutOfJail(int length) //If the player is going out of jail. + public void getOutOfJail(int length) //If the player is going out of jail. { position = 10; //Moves the player out of jail. Move(length); //Then moves the player. diff --git a/Assets/properties.cs b/Assets/properties.cs index 9091ce2..057881b 100644 --- a/Assets/properties.cs +++ b/Assets/properties.cs @@ -2,87 +2,89 @@ using System.Collections.Generic; using UnityEngine; +public class Property +{ + public string title; //The name of the property. + public string group; //The colour, station or utility. + public int value; //How much it costs to buy. + public int houseCost; //How much it costs to buy a house on that property. + public int houses = 0; //How many houses it has. (Can have up to 4) + public bool hotel = false; //Whether it has a hotel or not. (Can only have 1) + public bool mortgage = false; //Whether the property has been mortgaged. + + public Property(string name, string importGroup, int importValue, int house) //For houses. + { + //Initialising all the variables. + title = name; + group = importGroup; + value = importValue; + houseCost = house; + } + + public Property(string name, string importGroup, int importValue) //For stations or utility. + { + //Initialising all the variables. + title = name; + group = importGroup; + value = importValue; + } + + public void addHouse() //Used to add a house. + { + if (!mortgage && (houses < 4) && !hotel) //Checks if there is not a mortgage and there are less than 4 houses and that there isn't a hotel. + { + houses += 1; //Adds a house to the property. + } + } + + public void removeHouse() //Used to remove a house. + { + if (houses > 0) //Checks if there is at least 1 house on the property. + { + houses -= 1; //Removes the house from the property. + } + } + + public void addHotel() //Used to add a hotel. + { + if (houses == 4) //Checks if the user has enough houses. + { + houses = 0; //Removes all the houses. + hotel = true; //Creates the hotel. + } + } + + public void removeHotel() //Removes the hotel. + { + if (hotel) //Checks if they have a hotel already. + { + houses = 4; //Gives the user back their 4 houses. + hotel = false; //Removes the hotel. + + } + } + + public void mortgageProperty() //Mortgages the property. + { + if (!hotel && (houses == 0)) //Checks if there is not a hotel and if there are no houses. + { + mortgage = true; //Mortgages the property. + } + } + + public void unmortgageProperty() //Removes the mortgage on the property. + { + if (mortgage) //Checks if the property has been mortgaged. + { + mortgage = false; //Removes the mortgage. + } + } +} + + public class properties : MonoBehaviour { - public class Property - { - public string title; //The name of the property. - public string group; //The colour, station or utility. - public int value; //How much it costs to buy. - public int houseCost; //How much it costs to buy a house on that property. - public int houses = 0; //How many houses it has. (Can have up to 4) - public bool hotel = false; //Whether it has a hotel or not. (Can only have 1) - public bool mortgage = false; //Whether the property has been mortgaged. - - public Property(string name, string importGroup, int importValue, int house) //For houses. - { - //Initialising all the variables. - title = name; - group = importGroup; - value = importValue; - houseCost = house; - } - - public Property(string name, string importGroup, int importValue) //For stations or utility. - { - //Initialising all the variables. - title = name; - group = importGroup; - value = importValue; - } - - public addHouse() //Used to add a house. - { - if (!mortgage && (houses < 4) && !hotel) //Checks if there is not a mortgage and there are less than 4 houses and that there isn't a hotel. - { - houses += 1; //Adds a house to the property. - } - } - - public removeHouse() //Used to remove a house. - { - if (houses > 0) //Checks if there is at least 1 house on the property. - { - houses -= 1; //Removes the house from the property. - } - } - - public addHotel() //Used to add a hotel. - { - if (houses == 4) //Checks if the user has enough houses. - { - houses = 0; //Removes all the houses. - hotel = true; //Creates the hotel. - } - } - - public removeHotel() //Removes the hotel. - { - if (hotel) //Checks if they have a hotel already. - { - houses = 4; //Gives the user back their 4 houses. - hotel = false; //Removes the hotel. - - } - } - - public mortgageProperty() //Mortgages the property. - { - if (!hotel && (houses = 0)) //Checks if there is not a hotel and if there are no houses. - { - mortgage = true; //Mortgages the property. - } - } - - public unmortgageProperty() //Removes the mortgage on the property. - { - if (mortgage) - { - mortgage = false; - } - } - } // Start is called before the first frame update void Start()