Esempio n. 1
0
    public bool CanPlaceItemOnMap(InteractiveObject item)
    {
        ObjectDir  dir = item.GetItemDirection();
        Vector2Int pos = GeItemMapPosition(item);

        if (IsBlocked(pos))
        {
            return(false);
        }

        return(true);
    }
Esempio n. 2
0
    public Vector2Int GeItemMapPosition(InteractiveObject item)
    {
        if (item == null)
        {
            return(new Vector2Int(int.MinValue, int.MinValue));
        }

        ObjectDir  itemDirection = item.GetItemDirection();
        Vector2Int index         = MapManager.Instance.WorldPosToMapIndex(item.transform.position);

        index -= new Vector2Int(1 / 2, 1 / 2);

        return(index);
    }
Esempio n. 3
0
    public void ShowBuildingPlacementIndicator()
    {
        if (carryingItem != null)
        {
            Vector2Int index = MapManager.Instance.WorldPosToMapIndex(carryingItem.transform.position);

            if (carryingItem.GetItemDirection() == ObjectDir.Horizontal)
            {
                index -= new Vector2Int(carryingItem.size.x / 2, carryingItem.size.y / 2);
                MapManager.Instance.RenderGrid(index, carryingItem.size);
            }
            else
            {
                index -= new Vector2Int(carryingItem.size.y / 2, carryingItem.size.x / 2);
                MapManager.Instance.RenderGrid(index, new Vector2Int(carryingItem.size.y, carryingItem.size.x));
            }
        }
    }