Example #1
0
    // When the player clicks on the cauldron
    public void OnPointerDown(PointerEventData eventData)
    {
        // If there is a potion currently in the cauldron
        if (contents.Count >= 1)
        {
            // Make a new potion object, and set its data to the cauldron's
            Potion newPotion = ScriptableObject.CreateInstance <Potion>();
            newPotion.effects_dict  = effects_dict;
            newPotion.effect_string = effect_string;
            newPotion.sprite        = newPotion.BuildSprite(fillObj.GetComponent <Image>().color, Resources.Load <Sprite>("Sprites/Potion_Graphic"));

            // Create a draggable ui element to hold that potion
            GameObject       draggedIcon = Instantiate(icon_prefab, Input.mousePosition, Quaternion.identity, GameObject.Find("Icons").transform);
            UIElementDragger dragger     = draggedIcon.GetComponent <UIElementDragger>();
            dragger.dragging = true; dragger.spawn = transform.gameObject; dragger.SetPotion(newPotion); dragger.manager = manager;

            // Dump the cauldron and play bottling sound
            FindObjectOfType <AudioManager>().Play("PotionPickup", 1f);
            EmptyCauldron();
        }
    }