// Use this for initialization void Start() { controller = GameObject.Find("GameController"); controllerScript = controller.GetComponent <ControllerScript>(); PropertyTycoon game = controllerScript.game; PropertySpace space = (PropertySpace)game.GetBoardSpace(spaceID); IProperty property = space.GetProperty(); this.GetComponent <UnityEngine.UI.Text>().text = property.GetPropertyName(); }
int spaceID = 1; //change this and the script name I suppose... // Use this for initialization void Start() { controller = GameObject.Find("GameController"); controllerScript = controller.GetComponent <ControllerScript>(); // don't check what space the current player is on because they don't need to be on the space to view the property info // instead we will hard code the board space number to each script and copy and paste... PropertyTycoon game = controllerScript.game; PropertySpace space = ((PropertySpace)game.GetBoardSpace(spaceID)); IProperty property = space.GetProperty(); if (property.IsDevelopable()) { DevelopableLand devLand = (DevelopableLand)property; if (devLand.GetColourGroup() == Colour.Blue) { this.GetComponent <UnityEngine.UI.Image>().color = Color.cyan; } else if (devLand.GetColourGroup() == Colour.Brown) { this.GetComponent <UnityEngine.UI.Image>().color = new Color(165, 42, 42); } else if (devLand.GetColourGroup() == Colour.DeepBlue) { this.GetComponent <UnityEngine.UI.Image>().color = Color.blue; } else if (devLand.GetColourGroup() == Colour.Green) { this.GetComponent <UnityEngine.UI.Image>().color = Color.green; } else if (devLand.GetColourGroup() == Colour.Orange) { this.GetComponent <UnityEngine.UI.Image>().color = new Color(255, 165, 0); } else if (devLand.GetColourGroup() == Colour.Purple) { this.GetComponent <UnityEngine.UI.Image>().color = new Color(160, 32, 240); } else if (devLand.GetColourGroup() == Colour.Red) { this.GetComponent <UnityEngine.UI.Image>().color = Color.red; } else if (devLand.GetColourGroup() == Colour.Yellow) { this.GetComponent <UnityEngine.UI.Image>().color = Color.yellow; } } }
// Use this for initialization void Start() { GameObject controller = GameObject.Find("GameController"); ControllerScript controllerScript = controller.GetComponent <ControllerScript>(); PropertyTycoon game = controllerScript.game; space = game.GetBoardSpace(spaceID); Debug.Log(space.GetType()); // dynamic text based on type of board space // assumes you're using Text Mesh Pro UGUI component if (space.GetType() == typeof(GoSpace)) { GetComponent <TextMeshProUGUI>().text = spaceID + "\n\nGo!"; Debug.Log("Found a go space"); } else if (space.GetType() == typeof(JailSpace)) { GetComponent <TextMeshProUGUI>().text = "Just Visiting / Jail Space"; } else if (space.GetType() == typeof(FreeParkingSpace)) { GetComponent <TextMeshProUGUI>().text = "Free Parking"; } else if (space.GetType() == typeof(PropertySpace)) { // cast and get property object and display name PropertySpace propertySpace = (PropertySpace)space; IProperty property = propertySpace.GetProperty(); GetComponent <TextMeshProUGUI>().text = spaceID + "\n\n\n" + property.GetPropertyName(); } else if (space.GetType() == typeof(InstructionSpace)) { // cast and get instruction object and display description InstructionSpace instructionSpace = (InstructionSpace)space; string description = instructionSpace.GetDescription(); GetComponent <TextMeshProUGUI>().text = spaceID + "\n\n" + description; } }