private void StationConstructionToCursor() { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, 1000f, 1 << (int)ObjectLayers.Map)) { possibleStation.gameObject.transform.position = hit.point; if (Input.GetMouseButtonUp(0))//Left click { Destroy(possibleStation.gameObject); GameObject station = possibleStation.stationConstructor.BuildStation(possibleStation.stationConstruction.stationType, hit.point); possibleStation.stationConstructor.GetComponent <ShipController>().BuildStation(station, !Input.GetKey(KeyCode.LeftShift), false); possibleStation = null; ObjectSelector.Instance.lockSelection = false; } else if (Input.GetMouseButtonUp(1))//right click { Destroy(possibleStation.gameObject); possibleStation = null; ObjectSelector.Instance.lockSelection = false; } } }
private void SetStationConstructionButtonClickCallback(StationConstructor stationConstructor, GameObject button, StationConstruction stationConstruction) { button.GetComponent <Button>().onClick.AddListener(() => { Vector3 spawnPosition = stationConstructor.gameObject.transform.position; GameObject stationPrefab = Spawner.Instance.dummyStationDictionary[stationConstruction.stationType]; GameObject station = Instantiate(stationPrefab, spawnPosition, Quaternion.identity); if (possibleStation != null) { Destroy(possibleStation.gameObject); } station.SetActive(true); FogOfWarUtility.SetRendering(true, station); possibleStation = new PossibleStationConstruction(station, stationConstruction, stationConstructor); ObjectSelector.Instance.lockSelection = true; }); }