public void UpdateTileDescription(GameObject gameObject) { //floor moet altijd als laatste want een tile is altijd een floor if (gameObject.GetComponent <FloorStorage>()) { BuildingStorage storage = gameObject.GetComponentInParent <BuildingStorage>(); tileDescriptionCanvas.gameObject.SetActive(true); tileTitle.text = "Storage"; tileDescription.text = "This building stores all your resources"; tileSpecial.text = "Storage " + storage.storageCurrent + "/100"; } else if (gameObject.GetComponent <FloorSpawner>()) { tileDescriptionCanvas.gameObject.SetActive(true); tileTitle.text = "Fertile lands"; tileDescription.text = "This land is fertile and will spawn 1 gold everysecond"; tileSpecial.text = "Spawned: " + gameObject.GetComponent <FloorSpawner>().spawned.ToString() + "/" + gameObject.GetComponent <FloorSpawner>().amountToSpawn.ToString(); } else if (gameObject.GetComponent <Floor>()) { tileDescriptionCanvas.gameObject.SetActive(true); tileTitle.text = "Empty"; tileDescription.text = "Nothing is Here"; tileSpecial.text = "You can build here"; } }
// Update is called once per frame void Update() { if (buildFloorMode) { BuildFloorModeExecution(); if (Input.GetMouseButtonDown(0)) //check if the L-Mouse is clicked { Floor FloorToSpawn = GameState.Instance.TileManager.GetTileToSpawn(); Floor floor = Instantiate(FloorToSpawn, ghostBlockFloor.transform.position, new Quaternion(0, 0, 0, 0)); GameState.Instance.Player.FloorsList.Add(floor); buildFloorMode = false; GameState.Instance.MissionManager.ReceiveMissionEvent(MissionEvent.Explore); } } else if (buildWallMode) { BuildWallModeExecution(); if (Input.GetMouseButtonDown(0)) //check if the Q is clicked { Wall wall = Instantiate(SquarePlatformWallClass, ghostBlockWall.transform.position, new Quaternion(0, 0, 0, 0)); if (southRotation) { wall.transform.rotation = southRotationQuaternion; wall.southRotation = true; } else if (westRotation) { wall.transform.rotation = westRotationQuaternion; wall.westRotation = true; } GameState.Instance.Player.WallsList.Add(wall); buildWallMode = false; } } else if (buildBuildingMode) { BuildBuildingExecution(); if (Input.GetMouseButtonDown(0)) //check if the l-Mouse is clicked { GameState.Instance.Player.FloorsList.Remove(floorUnderConstruction); Destroy(floorUnderConstruction.gameObject); BuildingStorage buildingStorage = Instantiate(BuildingStorageClass, ghostStorageBuilding.transform.position, new Quaternion(0, 0, 0, 0)); Vector3 floorposition = buildingStorage.GetComponentInChildren <Floor>().gameObject.transform.position; expellUnitsElevator = Instantiate(ExpellUnitsBlockClass, floorposition + new Vector3(0, 0.5f, 0), new Quaternion(0, 0, 0, 0)); buildBuildingMode = false; } } else if (buildBulldozeMode) { //maak apart als dit allemaan weg gaat hier if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = playerCamera.GetComponent <Camera>().ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) //check if the ray hit something { //wall hit if (hit.collider.gameObject.GetComponent <Wall>() != null) { wallToDestroy = hit.collider.gameObject.GetComponent <Wall>(); //verander de wal van kleur Debug.Log("Verander wall van kleur exception"); } } } if (Input.GetKeyDown(KeyCode.Q)) //check if the Q is clicked { Destroy(wallToDestroy.gameObject); } } else { //takes care of all ghosts; if (ghostBlockFloor != null) { Destroy(ghostBlockFloor.gameObject); } if (ghostBlockWall != null) { Destroy(ghostBlockWall.gameObject); } if (ghostStorageBuilding != null) { Destroy(ghostStorageBuilding.gameObject); } } }