Example #1
0
    public void TakeItem()
    {
        PlayerData pdata = PlayerData.Get();

        if (CanTakeItem())
        {
            int slot = pdata.AddItem(data.id, quantity); //Add to inventory

            if (was_dropped)
            {
                pdata.RemoveDroppedItem(unique_id.unique_id); //Removed from dropped items
            }
            else
            {
                pdata.RemoveObject(GetUID()); //Taken from map
            }
            Destroy(gameObject);

            //Take fx
            ItemTakeFX.DoTakeFX(transform.position, data, slot);

            TheAudio.Get().PlaySFX("item", take_audio);
            if (take_fx != null)
            {
                Instantiate(take_fx, transform.position, Quaternion.identity);
            }
        }
    }
Example #2
0
    public override void DoAction(PlayerCharacter character, ItemSlot slot, Selectable select)
    {
        if (PlayerData.Get().CanTakeItem(cooked_item.id, 1))
        {
            PlayerData.Get().RemoveItemAt(slot.slot_index, 1);
            int islot = PlayerData.Get().AddItem(cooked_item.id, 1);

            //Take fx
            ItemTakeFX.DoTakeFX(select.transform.position, cooked_item, islot);
        }
    }
Example #3
0
    public override void DoAction(PlayerCharacter character, ItemSlot slot1, ItemSlot slot2)
    {
        if (PlayerData.Get().CanTakeItem(cut_item.id, 1))
        {
            PlayerData.Get().RemoveItemAt(slot1.slot_index, 1);
            int islot = PlayerData.Get().AddItem(cut_item.id, 1);

            //Take fx
            ItemTakeFX.DoTakeFX(character.transform.position, cut_item, islot);
        }
    }
Example #4
0
 //Gain an new item directly to inventory
 public void GainItem(GameObject source, ItemData item, int quantity, bool animate = true)
 {
     if (item != null && PlayerData.Get().CanTakeItem(item.id, quantity))
     {
         if (animate)
         {
             StartCoroutine(GainItemRoutine(source, item, quantity));
         }
         else
         {
             int islot = PlayerData.Get().AddItem(item.id, quantity);
             ItemTakeFX.DoTakeFX(source.transform.position, item, islot);
         }
     }
 }
Example #5
0
    private IEnumerator GainItemRoutine(GameObject source, ItemData item, int quantity)
    {
        is_action = true;

        if (source != null)
        {
            FaceTorward(source.transform.position);
        }

        if (onGainItem != null)
        {
            onGainItem.Invoke(item);
        }

        yield return(new WaitForSeconds(0.4f));

        int islot = PlayerData.Get().AddItem(item.id, quantity);

        ItemTakeFX.DoTakeFX(source.transform.position, item, islot);

        is_action = false;
    }