예제 #1
0
    public override void OnPointerClick(PointerEventData eventData)
    {
        if (eventData.button != PointerEventData.InputButton.Right)
        {
            return;
        }

        var @base = currentItem as BuildableBase;

        if (@base != null && inventory != null)
        {
            inventory.BuildingController.ActivateBuildMode(@base);
        }
        else if (CurrentItem is Armor)
        {
            equipmentManager.EquipArmor(CurrentItem as Armor, index);
            Tooltip.Instance.Hide();
        }
        else
        {
            var item = currentItem as Consumable;
            if (item == null || !item.IsConsumable || item.OnConsumedEffects == null || item.OnConsumedEffects.Count <= 0)
            {
                return;
            }

            PlayerNetwork.LocalPlayer.GetComponent <StatusEffectComponent>().AddStatusEffect(item.OnConsumedEffects);

            if (item.StackSize > 1)
            {
                item.StackSize--;
                if (inventory != null)
                {
                    inventory.OnItemChangedCallback?.Invoke();
                }
            }
            else if (inventory != null)
            {
                inventory.RemoveItemAtIndex(index);
            }

            Tooltip.Instance.Hide();
        }
    }