Example #1
0
 // When the storage is clicked
 public void OnPointerDown(PointerEventData eventData)
 {
     // If there is any of the ingredient left in the storage
     if (quantity >= 1)
     {
         // If the storage is part of the players inventory *OR* the player can afford to purchase the ingredient from the shop
         if (transform.parent.CompareTag("Inventory") || manager.GetPlayer().CanAfford(heldIngredient.cost))
         {
             FindObjectOfType <AudioManager>().Play("IngredientPickup", 1f);
             // Spawn the draggable element
             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.SetIngredient(/*Instantiate(heldIngredient)*/ heldIngredient); dragger.manager = manager;
             // Decrement the remaining quantity of ingredients
             quantity--;
         }
     }
 }
Example #2
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();
        }
    }