예제 #1
0
    void Update()
    {
        Vector3 clickPosition;

        clickPosition = cam.ScreenToWorldPoint(Input.mousePosition) + Vector3.forward * 10.0f;

        // Detect input for selecting tool bar items
        DetectToolbarSelection();
        // Only display placement overlay if selected item is a placeable tile
        if (Toolbar.GetItemByIndex(Toolbar.currentIndex).itemType == InventoryItem.Type.Tile &&
            GridUtils.AABBFloat2D(0, StaticMaps.worldMap.size.x, 0, StaticMaps.worldMap.size.y, new Vector2(clickPosition.x, clickPosition.y)))
        {
            // Display placement preview
            StaticMaps.ToggleMapRenderer(StaticMaps.MapType.Placement, true);
            StaticMaps.placementMap.SetTile(Vector3Int.zero, Toolbar.GetItemByIndex(Toolbar.currentIndex).itemTile);
            DisplayTileToPlace();
        }
        else
        {
            StaticMaps.ToggleMapRenderer(StaticMaps.MapType.Placement, false);
            canPlace = false;
        }
        DetectClick();
    }