예제 #1
0
    private void Update()
    {
        if (GameController.Location != null || map == null || GameController.WorldCamera.dragged)
        {
            return;
        }

        RaycastHit hit;

        if (Physics.Raycast(camera.ScreenPointToRay(Input.mousePosition), out hit))
        {
            int x = Mathf.FloorToInt(hit.point.x);
            int y = GameController.Map.size - Mathf.CeilToInt(hit.point.z) - 1;

            Tile newTile = map.GetTile(x, y);

            if (newTile == null)
            {
                return;
            }

            if (newTile != tile)
            {
                tile = newTile;
                string text = $"x: {x} y: {y}" +
                              $"\nHeight: {worldGenUtility.WorldHeightToMeters(tile.height)}m ({tile.height:F2})" +
                              $"\nTemp: {worldGenUtility.TemperatureToCelsius(tile.temp)}°C ({tile.temp:F2})" +
                              $"\nRegion: {tile.region}";
                if (tile.location != null)
                {
                    text += $"\n{tile.location}";
                }
                Town town = tile.location as Town;
                if (town != null)
                {
                    text += $"\nPopulation: {town.population}";
                }

                tileInfo.text = text;
            }

            if (Input.GetMouseButtonDown(0) && tile.location != null)
            {
                StartCoroutine(GameController.LoadLocation(tile.location));
            }

            if (Input.GetMouseButtonDown(1))
            {
                Vector3 point = hit.point;
                point.y = GameController.WorldCamera.targetPos.y;
                GameController.WorldCamera.targetPos = point;
            }
        }
    }