public void CreatePropertySpace() { Utility waters = new Utility("Edison Waters", 5); PropertySpace boardSpace = new PropertySpace(waters); // correct property stored Assert.AreEqual(waters, boardSpace.GetProperty()); // implements IBoardSpace interface Assert.IsTrue(boardSpace is IBoardSpace); }
// 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; } }
//Form method that activates when a key is press. Used to perfrom key relate actions in the game, such //as rolling the dice, moving the camera, etc. private void GameForm_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { this.Close(); } if (e.KeyCode == Keys.Up) { camera.move(0, -Camera.CAMERA_SPEED); } if (e.KeyCode == Keys.Down) { camera.move(0, Camera.CAMERA_SPEED); } if (e.KeyCode == Keys.Left) { camera.move(-Camera.CAMERA_SPEED, 0); } if (e.KeyCode == Keys.Right) { camera.move(Camera.CAMERA_SPEED, 0); } if (e.KeyCode == Keys.R) { if (!players[currentPlayer].IsPlayerBankrupt()) { MoveCurrentPlayer(); } clickedObject = null; this.Refresh(); if (CheckIfPlayerWon()) { MessageBox.Show("Player " + currentPlayer + " has won"); Close(); } } //Debug command if (e.KeyCode == Keys.U) { foreach (GameObject g in gameObjects) { if (g is PropertySpace p) { if (p.GetOwner() != null) { p.GetProperty().IncreaseNumOfHouses(); } } } } //Debug command if (e.KeyCode == Keys.L) { players[currentPlayer].RemoveMoney(100); } //Used to sell properties if (e.KeyCode == Keys.B && players[currentPlayer].GetSpaceOccupied() is PropertySpace) { Player player = players[currentPlayer]; PropertySpace property = (PropertySpace)player.GetSpaceOccupied(); if (property.GetProperty().GetOwner() == player) { using (SellProperty sellProperty = new SellProperty(property.GetProperty(), players, player)) { sellProperty.ShowDialog(); } } this.Refresh(); } this.Refresh(); }