Example #1
0
    void SummonItem(string itemName)
    {
        Vector3 p_position = Camera.main.ScreenToWorldPoint(transform.position);

        if (HasSomethingAt(p_position))
        {
            return;
        }

        switch (itemName)
        {
        case "Bloco Especial":
            SpecialBlockTilemap.GetSpecialBlockTilemap().GetTilemap().SetTile(new Vector3Int(Mathf.FloorToInt(p_position.x), Mathf.FloorToInt(p_position.y), 0), ItemFactory.GetFactory().ProduceSpecialBlock());
            SpecialBlockTilemap.GetSpecialBlockTilemap().GetTilemap().RefreshAllTiles();
            break;

        default:
            Instantiate(ItemFactory.GetFactory().ProduceItem(itemName), p_position + new Vector3(0, 0, 2), Quaternion.identity);
            break;
        }

        isBeingHeld = false;

        FirebaseMethods.firebaseMethods.IncrementQttItems(itemName);
        Debug.Log(itemName);
        item_quantity.text = Player.getInstance().GetPlayerInventory().DecreseQuantityFromItem(itemName).ToString();
        quantity--;
        if (Mathf.Sign(quantity) == -1)
        {
            quantity           = 0;
            item_quantity.text = 0.ToString();
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     instance = this;
     tilemap  = GetComponentInParent <Tilemap>();
 }