Exemple #1
0
    public void OnEndDrag(PointerEventData eventData)
    {
        // hide the tooltip
        showTooltip = false;
        // set the object's scale back to default
        transform.localScale = new Vector3 (1, 1, 1);
        itemBeingDragged = null;
        GetComponent<CanvasGroup> ().blocksRaycasts = true;
        if (transform.parent == startParent) {
            transform.position = startPosition;
        }
        // if object is dropped into the cauldron
        if (transform.parent.name == "CauldronSlot") {
            database = GameObject.FindGameObjectWithTag("Item Database").GetComponent<ItemDatabase> ();
            inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent<Inventory>();
            cauldron = GameObject.FindGameObjectWithTag("Cauldron").GetComponent<Cauldron>();
            item = database.items[itemID];
            cauldron.potionIngredients.Add(item);
            DestroyObject (gameObject);
            inventory.RemoveItem(itemID); // remove dropped ingredient from inventory
            startParent.GetComponent<Slot>().FillSlot ();

            cauldron.UpdateCountLabels();

            soundEffect = Instantiate (ingredientDroppedSound).gameObject;
            Destroy (soundEffect, 3);
        }
    }