Example #1
0
    public void useItemInHand()
    {
        //if Food:
        //if(currentHolded.getItemName() == PickedUpItemName.FRUIT)
        //{
        //    //ChangeHealth();
        if (currentHolded == null)
        {
            return;
        }

        currentHolded.m_State = PickedUpItems.ItemState.IN_BAG;

        // TODO

        GameResources.PickedUpItemName name = currentHolded.getItemName();
        myBackpack.PopItem(currentHolded);
        RpcDestroyHoldedItem();

        //photonView.RPC("RpcDestroyHoldedItem", RpcTarget.AllBuffered);


        myBackpack.LetItemInHandByName(name);

        //if (!myBackpack.DoIHave(name)) {
        //    photonView.RPC("RpcChangeHoldItemSprite", RpcTarget.AllBuffered, "", m_ID);
        //}
    }
Example #2
0
    //this function run on client and for all players
    public bool PickedUp(PickedUpItems item)
    {
        GameResources.PickedUpItemName name = item.getItemName();
        Debug.Log("Pick up " + name.ToString());
        Debug.Log("Bag full: " + bagFull);
        //if (currentHolded != null && bagFull)
        //{
        //    Debug.Log("Oops, your bug is full! Can not pick up " + name.ToString());
        //    return false;
        //}

        //for self
        if (photonView.IsMine)
        {
            //play sound
            AudioManager.instance.PlaySound("pickUp");
            //put in bag
            if (myBackpack.AddNewItem(item))
            {
                bagFull = myBackpack.ItemSpaceLeft() <= 0;
                Debug.Log("Sucessfully put " + item.getItemName().ToString() + " in bag: now space left " + myBackpack.ItemSpaceLeft());
                item.gameObject.SetActive(false);
            }
            else
            {
                Debug.Log("Oops, your bug is full! Can not pick up " + name.ToString());
                return(false);
            }
            if (currentHolded == null)
            {
                HoldItemInHand(item);
            }
        }
        else
        {
            //not local player, only check hold in hand
            if (currentHolded == null)
            {
                HoldItemInHand(item);
            }
        }
        item.m_State = PickedUpItems.ItemState.IN_BAG;
        //item.gameObject.SetActive(false);
        return(true);
    }