Beispiel #1
0
    public void DropResource(ResourceInfo resourceInfo)
    {
        int resourceIndex = resourceInfo.ToIndex();

        if (inventory [resourceIndex] < 1f)
        {
            return;
        }

        Vector2 posV2 = TerrainManager.PosToV2(playerTransform.position);

        if (tm.PadAtPosition(posV2) != null || tm.GetBuildingAtPosition(posV2) != null)
        {
            return;
        }

        if (tm.SpawnResource(playerTransform.position, resourceInfo, body.location) == null)
        {
            return;
        }

        inventory[resourceIndex] -= 1f;
        GameManager.instance.SaveThisTurn();
        UpdateInventoryUI();
    }