示例#1
0
    public void DropItemInHand()
    {
        Vector3 newDirr = (transform.position - Player.transform.position);
        Vector3 dir     = new Vector3(newDirr.x, newDirr.y, 0).normalized;
        //Debug.Log(HandContainer);
        GameObject newDrop = Instantiate(DropCatalog.GetGObyID(HandContainer), Player.transform.position + dir, Quaternion.identity);

        newDrop.GetComponent <Drop_scr>().count = HandContainerCount;
        CursorContainerActivation();
        //Vector3 newDirr = transform.position - Player.transform.position;
        newDrop.GetComponent <Rigidbody2D>().AddForce(dir / 5f);
        Cursor.SetCursor(CursorDefault, Vector2.zero, CursorMode.Auto);
    }
示例#2
0
    public void AddItem(GameObject item)
    {
        Drop_scr drop  = item.GetComponent <Drop_scr>();
        int      count = drop.count;
        int      id    = drop.id;

        for (int i = 0; i < InvItemsLength; i++)
        {
            GameObject iItem = InvItems[i];
            if (iItem != null && iItem.GetComponent <Drop_scr>().id.Equals(id))
            {
                int istack = iItem.GetComponent <Drop_scr>().InStack;
                if (ItemsCount[i] + count <= istack)
                {
                    ItemsCount[i] += count;
                    drop.IsEmpty();
                    InvSlots[i].SetCount(ItemsCount[i]);
                    return;
                }
                else
                {
                    drop.count    = ItemsCount[i] + count - istack;
                    ItemsCount[i] = istack;
                }
            }
        }
        if (!isFull)
        {
            InvItems[firstemptycell]   = DropCatalog.GetGObyID(id);
            ItemsCount[firstemptycell] = count;
            InvSlots[firstemptycell].SetCount(ItemsCount[firstemptycell], InvItems[firstemptycell]);
            drop.IsEmpty();
            UpdateInventory();
        }
        ChangeInHandItem();
    }
示例#3
0
    public void IteractWithSlot()
    {
        Debug.Log("Click");
        if (CursorComponent.HandContainerFull) // если в руках есть some
        {
            int        id       = CursorComponent.HandContainer;
            GameObject FreeHand = DropCatalog.GetGObyID(id);
            Drop_scr   drop     = FreeHand.GetComponent <Drop_scr>();
            Debug.Log(drop.type.Equals(SlotType));
            if (drop.type.Equals(SlotType))
            {
                if (busy) //клетка занята
                {
                    SlotBenifits(-1);
                    CursorComponent.CursorContainerActivation(inSlot, 1);
                    SetSlot(FreeHand);
                    SlotBenifits(1);
                    //
                }
                else //положить в пустую
                {
                    SetSlot(FreeHand);
                    SlotBenifits(1);
                    CursorComponent.CursorContainerActivation();
                }
            }
            else
            {
                Debug.Log("Этот предмет не подходит в этот слот");
            }

            // InventoryComponent.PutItem(SlotNumber);
        }
        else if (busy) // руки пустые, но в клетке предмет
        {
            CursorComponent.CursorContainerActivation(inSlot, 1);
            SlotBenifits(-1);
            SetSlot();
        }
    }