private void Awake() { camera = Camera.main; mapDisplay = GetComponent <MapDisplay>(); worldGenUtility = GetComponent <WorldGenUtility>(); mapDrawModesCount = Enum.GetValues(typeof(MapDrawMode)).Length; }
protected override void UpdateDisplay() { if (!Target.Active) { MapDisplay.SafeDestroy(gameObject); } transform.position = WorldGenUtility.WorldToMeshPoint(Target.tile.position); }
private void Update() { RaycastHit hit; if (Physics.Raycast(GameController.WorldCamera.camera.ScreenPointToRay(Input.mousePosition), out hit)) { Vector2Int pos = WorldGenUtility.MeshToWorldPoint(hit.point); Tile tile = World.GetTile(pos); if (tile == null) { return; } float height = GameController.WorldGenUtility.WorldHeightToMeters(tile.height); float temp = GameController.WorldGenUtility.TemperatureToCelsius(tile.temp); string text = $"Position: {tile.position}\nHeight: {height}m ({tile.height:F3})\nTemp: {temp}°C ({tile.temp:F3})\nRegion: {tile.region}"; if (tile.location != null) { text += $"\n{tile.location}"; } Town town = tile.Town; if (town != null) { text += $"\nPopulation: {town.population}"; } tileInfo.text = text; if (Input.GetMouseButtonDown(1)) { GameController.WorldCamera.target = hit.point; } } }
private static Vector3 RoadPosition(Vector2Int position) => WorldGenUtility.WorldToMeshPoint(position) + Vector3.up * 0.2f;
private static T InstantiateOnMap <T>(T t, Vector2Int position, Transform parent) where T : Object { T instance = Instantiate(t, WorldGenUtility.WorldToMeshPoint(position), Quaternion.identity, parent); return(instance); }