Exemple #1
0
    public void addToInvo(GameObject obj)
    {
        if (inventory.checkIfWeCanAdd(obj.GetComponent <ItemPickup>().item))
        {
            objPoolManager.ObjectPoolAddition(obj);
            ItemPickup ip = obj.GetComponent <ItemPickup>();
            tempItem      = ip.item;
            tempItemCount = ip.count;
            inventory.Add(tempItem, tempItemCount);
        }
        else
        {
            objPoolManager.DropTable(obj, transform.position);
        }

        /*  tempItemGameobject = obj;
         *
         * Debug.Log(tempItemGameobject.name);
         * if (tempItemCount <= 0)
         * {
         *    Debug.LogError(tempItemGameobject.name + " item pickup count is 0 or less then");
         * }
         *
         *
         *    objPoolManager.ReturnFromPool(obj);*/
    }
Exemple #2
0
    //pick up items

    //incomplete - need to add to inventory etc/ also need pickup item button and current node check function at the end of control function to see if there is something we can pick up

    public void pickUp()
    {
        if (currentNode.stack.Count > 0)
        {
            tempItemGameobject = currentNode.stack.Peek().gameObject;

            if (tempItemGameobject == null)
            {
                Debug.LogError("Player is picking up an empty gameobject somehow");
            }

            if (!inventory.checkIfWeCanAdd(tempItemGameobject.GetComponent <ItemPickup>().item))
            {
                return;
            }

            //check if we have enough inventory space
            //if true do this

            //check to see if we either consume it(dew), or add it to vial in inventory if health full? or add to invo

            //remove it from stack
            currentNode.stack.Pop();

            ////decrement nodes index for sprite rendering order
            //currentNode.index--;

            //check if there are still any items left on my node

            displayPickUpButton();

            //Add to inventoy Here
            objPoolManager.ObjectPoolAddition(tempItemGameobject);

            if (tempItemGameobject.GetComponent <ItemPickup>() == null)
            {
                Debug.Log(tempItemGameobject.name + "Error, Item Pickup Is not implimented onto this object");
            }
            if (tempItemGameobject.GetComponent <ItemPickup>().item == null)
            {
                Debug.Log(tempItemGameobject.name + "Error, The Item in Item Pickup component is null on this prefab object");
            }

            tempItem      = tempItemGameobject.GetComponent <ItemPickup>().item;
            tempItemCount = tempItemGameobject.GetComponent <ItemPickup>().count;
            if (tempItemCount <= 0)
            {
                Debug.LogError(tempItemGameobject.name + " item pickup count is 0 or less then");
            }

            inventory.Add(tempItem, tempItemCount);

            //pass control to other entities if we picked something up?
            Control();
        }
    }