stackableSettings() 공개 메소드

public stackableSettings ( ) : void
리턴 void
예제 #1
0
 void stackableItemsSettings()
 {
     EditorGUILayout.PropertyField(inventoryStackable, new GUIContent("Splitting/Stacking"));
     if (inventoryStackable.boolValue)
     {
         EditorGUI.indentLevel++;
         showStackableItems = EditorGUILayout.Foldout(showStackableItems, "StackNumberPosition");
         if (showStackableItems)
         {
             inventoryStackable.boolValue = true;
             EditorGUI.BeginChangeCheck();
             EditorGUI.indentLevel++;
             positionNumberX.intValue = EditorGUILayout.IntSlider("Position X:", positionNumberX.intValue, -(inventorySlotSize.intValue / 2), inventorySlotSize.intValue / 2);
             positionNumberY.intValue = EditorGUILayout.IntSlider("Position Y:", positionNumberY.intValue, -(inventorySlotSize.intValue / 2), inventorySlotSize.intValue / 2);
             EditorGUI.indentLevel--;
             if (EditorGUI.EndChangeCheck())
             {
                 inv.stackableSettings();
             }
         }
         else
         {
             inv.stackableSettings();
         }
         EditorGUI.indentLevel--;
     }
     else
     {
         inv.stackableSettings();
     }
 }
예제 #2
0
 // Update is called once per frame
 void Update()
 {
     if (_inventory != null && UserControl.PickupItem)
     {
         float distance = Vector2.Distance(new Vector2(this.gameObject.transform.position.x, this.gameObject.transform.position.y), new Vector2(_player.transform.position.x, _player.transform.position.y));
         print("distance: " + distance);
         if (distance <= 1.3)
         {
             sceneManager.GetComponent <MySceneManager>().removeFromGearList(this.gameObject);
             bool check = _inventory.checkIfItemAllreadyExist(item.itemID, item.itemValue);
             if (check)
             {
                 Destroy(this.gameObject);
             }
             else if (_inventory.ItemsInInventory.Count < (_inventory.width * _inventory.height))
             {
                 _inventory.addItemToInventory(item.itemID, item.itemValue);
                 _inventory.updateItemList();
                 _inventory.stackableSettings();
                 Destroy(this.gameObject);
             }
         }
     }
     if (_inventory != null && UserControl.GetGearsBack)
     {
         addItemToInv(item.itemID, item.itemValue);
     }
 }
예제 #3
0
 public void dropItem_re(Int32 itemIndex)
 {
     if (itemInventory == null)
     {
         itemInventory = this.transform.GetComponent <PlayerInventory>().inventory.GetComponent <Inventory>();
     }
     if (itemInventory != null)
     {
         itemInventory.deleteItemByIndex(itemIndex);
         itemInventory.updateItemList();
         itemInventory.stackableSettings();
         tooltip.deactivateTooltip();
     }
 }
예제 #4
0
    private bool pressingButtonToSplit; //bool for pressing a item to split it

    #endregion Fields

    #region Methods

    //splitting the item now
    public void OnPointerDown(PointerEventData data)
    {
        inv = transform.parent.parent.parent.GetComponent<Inventory>();
        if (transform.parent.parent.parent.GetComponent<Hotbar>() == null && data.button == PointerEventData.InputButton.Left && pressingButtonToSplit && inv.stackable && (inv.ItemsInInventory.Count < (inv.height * inv.width))) //if you press leftclick and and keycode
        {
            ItemOnObject itemOnObject = GetComponent<ItemOnObject>();                                                   //we take the ItemOnObject script of the item in the slot

            if (itemOnObject.item.itemValue > 1)                                                                         //we split the item only when we have more than 1 in the stack
            {
                int splitPart = itemOnObject.item.itemValue;                                                           //we take the value and store it in there
                itemOnObject.item.itemValue = (int)itemOnObject.item.itemValue / 2;                                     //calculate the new value for the splitted item
                splitPart = splitPart - itemOnObject.item.itemValue;                                                   //take the different

                inv.addItemToInventory(itemOnObject.item.itemID, splitPart);                                            //and add a new item to the inventory
                inv.stackableSettings();

                if (GetComponent<ConsumeItem>().duplication != null)
                {
                    GameObject dup = GetComponent<ConsumeItem>().duplication;
                    dup.GetComponent<ItemOnObject>().item.itemValue = itemOnObject.item.itemValue;
                    dup.GetComponent<SplitItem>().inv.stackableSettings();
                }
                inv.updateItemList();

            }
        }
    }
예제 #5
0
    // Update is called once per frame
    void Update()
    {
        Vector3 newPos = this.gameObject.transform.position;
        // characPos = center of the player;
        Vector3 characPos = _player.transform.position;

        characPos.y += _player.transform.localScale.y / 2;
        float distance = Vector3.Distance(this.gameObject.transform.position, characPos);

        speedMultiplier = distance * 0.05f;

        if (distance <= 1)
        {
            pi.brokenItemID = this.gameObject.GetComponent <PickUpItem>().item.itemID;
            if (!pi.FullInventory())
            {
                // moving the item to the player
                if (newPos.x - characPos.x < 0)
                {
                    newPos.x += speedMultiplier;
                }
                else if (newPos.x - characPos.x > 0)
                {
                    newPos.x -= speedMultiplier;
                }

                if (newPos.y - characPos.y < 0)
                {
                    newPos.y += speedMultiplier;
                }
                else if (newPos.y - characPos.y > 0)
                {
                    newPos.y -= speedMultiplier;
                }
                this.gameObject.transform.position = newPos;

                // picking up the item
                if (_inventory != null && Mathf.Abs(this.gameObject.transform.position.x - characPos.x) <= 0.3f &&
                    Mathf.Abs(this.gameObject.transform.position.y - characPos.y) <= 0.3f * (_player.GetComponent <CapsuleCollider2D>().offset.y / _player.GetComponent <CapsuleCollider2D>().offset.x))
                {
                    bool check = _inventory.checkIfItemAllreadyExist(item.itemID, item.itemValue);
                    if (check)
                    {
                        Destroy(this.gameObject);
                    }
                    else if (_inventory.ItemsInInventory.Count < (_inventory.width * _inventory.height))
                    {
                        _inventory.addItemToInventory(item.itemID, item.itemValue);
                        _inventory.updateItemList();
                        _inventory.stackableSettings();
                        Destroy(this.gameObject);
                    }
                    if (!pi.currentLevel.Equals(pi.maxLevel))
                    {
                        pi.GainExp(item.expToGain);
                    }
                }
            }
        }
    }
예제 #6
0
 // Update is called once per frame
 void Update()
 {
     if (_inventory != null && Input.GetKeyDown(KeyCode.E))
     {
         RaycastHit hit;
         if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, 3f))
         {
             if (!hit.transform.gameObject.GetComponent <PickUpItem>())
             {
                 return;
             }
             bool check = _inventory.checkIfItemAllreadyExist(item.itemID, item.itemValue);
             if (check)
             {
                 Destroy(this.gameObject);
             }
             else if (_inventory.ItemsInInventory.Count < (_inventory.width * _inventory.height))
             {
                 _inventory.addItemToInventory(item.itemID, item.itemValue);
                 _inventory.updateItemList();
                 _inventory.stackableSettings();
                 Destroy(this.gameObject);
             }
         }
     }
 }
예제 #7
0
    public void OnPointerDown(PointerEventData data)
    {
        inv = transform.parent.parent.parent.GetComponent<Inventory>();
        if (transform.parent.parent.parent.GetComponent<Hotbar>() == null && data.button == PointerEventData.InputButton.Left && pressingButtonToSplit && inv.stackable && (inv.ItemsInInventory.Count < (inv.height * inv.width)))
        {
            ItemOnObject itemOnObject = GetComponent<ItemOnObject>();

            if (itemOnObject.item.itemValue > 1)
            {
                int splitPart = itemOnObject.item.itemValue;
                itemOnObject.item.itemValue = (int)itemOnObject.item.itemValue / 2;
                splitPart = splitPart - itemOnObject.item.itemValue;

                inv.addItemToInventory(itemOnObject.item.itemID, splitPart);
                inv.stackableSettings();

                if (GetComponent<ConsumeItem>().duplication != null)
                {
                    GameObject dup = GetComponent<ConsumeItem>().duplication;
                    dup.GetComponent<ItemOnObject>().item.itemValue = itemOnObject.item.itemValue;
                    dup.GetComponent<SplitItem>().inv.stackableSettings();
                }
                inv.updateItemList();

            }
        }
    }
예제 #8
0
    public void equipItemRequest_re(Dictionary <string, object> itemInfo, Dictionary <string, object> equipItemInfo)
    {
        Int32  itemIndex      = (Int32)itemInfo["itemIndex"];
        Int32  equipItemIndex = (Int32)equipItemInfo["itemIndex"];
        UInt64 itemUUid       = (UInt64)itemInfo["UUID"];
        UInt64 equipItemUUid  = (UInt64)equipItemInfo["UUID"];

        if (itemUUid > 0)
        {
            itemInventory.addItemToInventory((Int32)itemInfo["itemId"], (UInt64)itemInfo["UUID"], 1, (Int32)itemInfo["itemIndex"]);
        }
        else
        {
            itemInventory.deleteItemByIndex(itemIndex);
        }

        if (equipItemUUid > 0)
        {
            equipInventory.addItemToInventory((Int32)equipItemInfo["itemId"], (UInt64)equipItemInfo["UUID"], 1, (Int32)equipItemInfo["itemIndex"]);
        }
        else
        {
            equipInventory.deleteItemByIndex(equipItemIndex);
        }

        itemInventory.updateItemList();
        itemInventory.stackableSettings();
        equipInventory.updateItemList();
        equipInventory.stackableSettings();
    }
예제 #9
0
    public void OnPointerDown(PointerEventData data)                    //splitting the item now
    {
        inv = transform.parent.parent.parent.GetComponent <Inventory>();
        if (transform.parent.parent.parent.GetComponent <Hotbar>() == null && data.button == PointerEventData.InputButton.Left && pressingButtonToSplit && inv.stackable && (inv.ItemsInInventory.Count < (inv.height * inv.width))) //if you press leftclick and and keycode
        {
            ItemOnObject itemOnObject = GetComponent <ItemOnObject>();                                                                                                                                                               //we take the ItemOnObject script of the item in the slot

            if (itemOnObject.item.itemValue > 1)                                                                                                                                                                                     //we split the item only when we have more than 1 in the stack
            {
                int splitPart = itemOnObject.item.itemValue;                                                                                                                                                                         //we take the value and store it in there
                itemOnObject.item.itemValue = (int)itemOnObject.item.itemValue / 2;                                                                                                                                                  //calculate the new value for the splitted item
                splitPart = splitPart - itemOnObject.item.itemValue;                                                                                                                                                                 //take the different

                inv.addItemToInventory(itemOnObject.item.itemID, splitPart);                                                                                                                                                         //and add a new item to the inventory
                inv.stackableSettings();

                if (GetComponent <ConsumeItem>().duplication != null)
                {
                    GameObject dup = GetComponent <ConsumeItem>().duplication;
                    dup.GetComponent <ItemOnObject>().item.itemValue = itemOnObject.item.itemValue;
                    dup.GetComponent <SplitItem>().inv.stackableSettings();
                }
                inv.updateItemList();
            }
        }
    }
예제 #10
0
    public void equipItemRequest_re(ITEM_INFO itemInfo, ITEM_INFO equipItemInfo)
    {
        Int32  itemIndex      = itemInfo.itemIndex;
        Int32  equipItemIndex = equipItemInfo.itemIndex;
        UInt64 itemUUid       = itemInfo.UUID;
        UInt64 equipItemUUid  = equipItemInfo.UUID;

        if (itemUUid > 0)
        {
            itemInventory.addItemToInventory(itemInfo.itemId, itemInfo.UUID, 1, itemInfo.itemIndex);
        }
        else
        {
            itemInventory.deleteItemByIndex(itemIndex);
        }

        if (equipItemUUid > 0)
        {
            equipInventory.addItemToInventory(equipItemInfo.itemId, equipItemInfo.UUID, 1, equipItemInfo.itemIndex);
        }
        else
        {
            equipInventory.deleteItemByIndex(equipItemIndex);
        }

        itemInventory.updateItemList();
        itemInventory.stackableSettings();
        equipInventory.updateItemList();
        equipInventory.stackableSettings();
    }
예제 #11
0
    // Update is called once per frame
    void Update()
    {
        if (_inventory != null && Input.GetKeyDown(KeyCode.E))
        {
            float distance = Vector3.Distance(this.gameObject.transform.position, _player.transform.position);

            if (distance <= 3)
            {
                if (playerIO.isNetwork)
                {
                    menuManager.Debuglog("Собранно " + item.itemName + " колличество " + item.itemValue);
                    //MenuManager.instance.Debuglog();
                    GameObject.Find("NetworkManager").GetComponent <NetworkLayerClient>().HarwestWood(item.itemID, item.itemValue);
                    Destroy(this.gameObject);
                }
                else
                {
                    Debug.Log("Собранно " + item.itemName + " колличество " + item.itemValue);
                    bool check = _inventory.checkIfItemAllreadyExist(item.itemID, item.itemValue);
                    if (check)
                    {
                        Destroy(this.gameObject);
                    }
                    else if (_inventory.ItemsInInventory.Count < (_inventory.width * _inventory.height))
                    {
                        _inventory.addItemToInventory(item.itemID, item.itemValue);
                        _inventory.updateItemList();
                        _inventory.stackableSettings();
                        Destroy(this.gameObject);
                    }
                }
            }
        }
    }
예제 #12
0
    void addItemsToInventory()
    {
        Inventory iV = inventory.GetComponent <Inventory>();

        for (int i = 0; i < storageItems.Count; i++)
        {
            iV.addItemToInventory(storageItems[i].itemID, storageItems[i].itemValue);
        }
        iV.stackableSettings();
    }
예제 #13
0
    public override void Interact()
    {
        base.Interact();
        bool check = _inventory.checkIfItemAllreadyExist(item.itemID, item.itemValue);

        if (check)
        {
            Destroy(this.gameObject);
        }
        else if (_inventory.ItemsInInventory.Count < (_inventory.width * _inventory.height))
        {
            _inventory.addItemToInventory(item.itemID, item.itemValue);
            _inventory.updateIconSize();
            _inventory.updateItemList();
            _inventory.stackableSettings();
            Destroy(this.gameObject);
            GameManager.NotifyPickedUpItem(item);
        }
    }
예제 #14
0
    public void onReqItemList(Dictionary <UInt64, ITEM_INFO> itemList, Dictionary <UInt64, ITEM_INFO> equipItemDict)
    {
        UnityEngine.GameObject _player = UnityEngine.GameObject.FindGameObjectWithTag("Player");
        Inventory _inventory           = null;
        Inventory _equipInventory      = null;

        if (_player != null)
        {
            _inventory      = _player.GetComponent <PlayerInventory>().inventory.GetComponent <Inventory>();
            _equipInventory = _player.GetComponent <PlayerInventory>().characterSystem.GetComponent <Inventory>();
        }
        if (_inventory != null)
        {
            foreach (UInt64 dbid in itemList.Keys)
            {
                ITEM_INFO info  = itemList[dbid];
                Int32     id    = info.itemId;
                UInt64    uid   = info.UUID;
                Int32     index = info.itemIndex;
                UInt32    count = info.itemCount;
                _inventory.addItemToInventory(id, uid, (int)count, index);
                _inventory.updateItemList();
                _inventory.stackableSettings();
            }
        }
        if (_equipInventory != null)
        {
            foreach (UInt64 dbid in equipItemDict.Keys)
            {
                ITEM_INFO info  = equipItemDict[dbid];
                Int32     id    = info.itemId;
                UInt64    uid   = info.UUID;
                Int32     index = info.itemIndex;
                _equipInventory.addItemToInventory(id, uid, 1, index);
                _equipInventory.updateItemList();
                _equipInventory.stackableSettings();
            }
        }
    }
예제 #15
0
    // Update is called once per frame
    void Update()
    {
        if (_inventory != null && Input.GetKeyDown(KeyCode.E))
        {
            float distance = Vector3.Distance(this.gameObject.transform.position, _player.transform.position);

            if (distance <= 3)
            {
                bool check = _inventory.checkIfItemAllreadyExist(item.itemID, item.itemValue);
                if (check)
                {
                    Destroy(this.gameObject);
                }
                else if (_inventory.ItemsInInventory.Count < (_inventory.width * _inventory.height))
                {
                    _inventory.addItemToInventory(item.itemID, item.itemValue);
                    _inventory.updateItemList();
                    _inventory.stackableSettings();
                    Destroy(this.gameObject);
                }
            }
        }
    }
예제 #16
0
 public void addItemToInventory(int id)
 {
     mainInventory.addItemToInventory(id);
     mainInventory.updateItemList();
     mainInventory.stackableSettings();
 }