Ejemplo n.º 1
0
    public override void OnDrop(GameObject Slot)
    {
        if (Visible == Visiblility.Hidden)
        {
            return;
        }

        UI_InventorySlot InventoryComponent = Slot.GetComponent <UI_InventorySlot> ();

        if (Inventory && InventoryComponent)
        {
            UI_Item    Item        = (Remove == RemoveType.RemoveOnDrag) ? TempDrag : this.Item;
            Vector2Int NewPosition = ParentInventory.AddItem(Item, InventoryComponent.Position);
            if (NewPosition != UI_Inventory.InvalidIndex)
            {
                if (Remove == RemoveType.RemoveOnDrop && RemoveEvent)
                {
                    ParentInventory.RemoveItem(Position);
                }
            }
            else
            {
                if (Remove == RemoveType.RemoveOnDrag)
                {
                    ParentInventory.AddItem(Item, Position);
                }
            }
        }

        UI_EquipSlot EquipComponent = Slot.GetComponent <UI_EquipSlot>();

        if (EquipComponent && EquipComponent.Inventory)
        {
            UI_Item    Item  = (Remove == RemoveType.RemoveOnDrag) ? TempDrag : this.Item;
            Vector2Int NewId = EquipComponent.Inventory.AddItem(Item, Slot);
            if (NewId != UI_Inventory.InvalidIndex)
            {
                if (Remove == RemoveType.RemoveOnDrop && RemoveEvent)
                {
                    ParentInventory.RemoveItem(Position);
                }
            }
            else
            {
                if (Remove == RemoveType.RemoveOnDrag)
                {
                    ParentInventory.AddItem(Item, Position);
                }
            }

            print("Cast To Equip slot");
        }
    }
Ejemplo n.º 2
0
    public bool RemoveItem(GameObject Slot)
    {
        bool Success = false;

        UI_EquipSlot SlotComponent = Slot.GetComponent <UI_EquipSlot>();

        if (SlotComponent)
        {
            SlotComponent.SetVisibility(Visiblility.Visible);
            SlotComponent.SetScale(new Vector2Int(1, 1));
            SlotComponent.SetIcon(null);
            SlotComponent.Item = new UI_Item();
            Success            = true;
            DebugLog("Item Removed Successfully: " + SlotComponent.Id);
        }

        return(Success);
    }
Ejemplo n.º 3
0
    public void Carry()
    {
        int amount = card.equipCost;

        int n = UI_CardPanel.slotNum - 1;

        card = UI_CardLoader.slots [n].GetComponentInChildren <Card> ();

        GameObject[] equipSlots = GameObject.FindGameObjectsWithTag("EquipSlot");


        for (int i = equipSlots.Length; i > 0; i--)
        {
            UI_EquipSlot slot = equipSlots [equipSlots.Length - i].GetComponent <UI_EquipSlot> ();

            if (slot.SlotAvailable())
            {
                if (GameManager.composure - amount > 0)
                {
                    hud.RemoveSegment(amount);

                    loader.AddtoCarry(card.gameObject);

                    card.gameObject.transform.SetParent(equipSlots [equipSlots.Length - i].transform, false);

                    card.mySlotState = Card.SlotState.EQUIP_SLOT;
                }
                else
                {
                    print("Not enough composure");
                }

                panel.DisablePanel();
                break;
            }
        }

        if (card.myCardType == Card.CardType.POSSESSION_CARD)
        {
            card.AccessAbility();
        }
    }
Ejemplo n.º 4
0
    public Vector2Int AddItem(UI_Item NewItem, GameObject Slot)
    {
        if (!ValidateItemFormat(NewItem))
        {
            return(InvalidIndex);
        }

        Vector2Int   Index         = InvalidIndex;
        UI_EquipSlot SlotComponent = Slot.GetComponent <UI_EquipSlot>();

        if (SlotComponent)
        {
            DebugLog("Item added to Equipament Slot: [" + SlotComponent.Id + "]");
            SlotComponent.SetVisibility(Visiblility.Visible);
            SlotComponent.SetIcon(NewItem.Icon);
            SlotComponent.SetScale(NewItem.Size);
            SlotComponent.Item = NewItem;
            Index = new Vector2Int(SlotComponent.Id, SlotComponent.Id);
        }

        return(Index);
    }
Ejemplo n.º 5
0
    public override void OnDrop(GameObject Slot)
    {
        if (Visible == Visiblility.Hidden)
        {
            return;
        }

        UI_EquipSlot EquipComponent = Slot.GetComponent <UI_EquipSlot>();

        if (EquipComponent && Inventory)
        {
            print("Drop Cast Equip");
        }

        UI_InventorySlot InventoryComponent = Slot.GetComponent <UI_InventorySlot>();

        if (InventoryComponent && Inventory)
        {
            UI_Item    Item  = (Remove == UI_InventorySlot.RemoveType.RemoveOnDrag) ? TempDrag : this.Item;
            Vector2Int Index = Inventory.AddItem(Item, InventoryComponent.Position);
            if (Index != UI_Inventory.InvalidIndex)
            {
                if (Remove == UI_InventorySlot.RemoveType.RemoveOnDrop)
                {
                    Inventory.RemoveItem(gameObject);
                }
            }
            else
            {
                if (Remove == UI_InventorySlot.RemoveType.RemoveOnDrag)
                {
                    Inventory.AddItem(Item, gameObject);
                }
            }
        }
    }