Example #1
0
    public override void Interact()
    {
        EContainerType  container;
        EContainerType2 container2;

        if (Level.GetPlayer().PeekContainer(out container, out container2)) // player holding something?
        {
            if (container == containerType)                                 // player holding same as this container?
            {
                Debug.Log("Interact: dropped " + containerType.ToString());
                Level.GetPlayer().DropContainer(); // drop it
            }
        }
        else // player NOT holding anything?
        {
            Debug.Log("Interact: picked up " + containerType.ToString());
            // give this
            prefabRaw.transform.position =
                Level.player.holdPosition.transform.localPosition;
            if (containerType2 == EContainerType2.Bag)
            {
                Level.GetPlayer().CarryBag(new List <BagItem>(), prefabRaw, this);
            }
            else
            {
                Level.GetPlayer().CarryContainer(containerType, containerType2, prefabRaw, this);
            }
        }
    }
Example #2
0
    public override void Interact()
    {
        EContainerType container;
		EContainerType2 container2;
		if (Level.GetPlayer().PeekContainer(out container, out container2)) // player holding something?
        {
            if (container == containerType) // player holding same as this container?
            {
                Debug.Log("Interact: dropped " + containerType.ToString());
                Level.GetPlayer().DropContainer(); // drop it
            }
        }
        else // player NOT holding anything?
        {
            Debug.Log("Interact: picked up " + containerType.ToString());
            Level.GetPlayer().CarryContainer(containerType, containerType2, prefabRaw); // give this
        }
    }
Example #3
0
    public override void Interact()
    {
        EContainerType  t1;
        EContainerType2 t2;
        bool            carryingItem = Level.player.PeekContainer(out t1, out t2);

        if (canPlaceDown && !hasItem)
        {
            Debug.Log("Interact: placed down " + t1.ToString());
            hasItem        = true;
            placeItemType  = t1;
            placeItemType2 = t2;
            hasBag         = (t1 == EContainerType.Bag && t2 == EContainerType2.Bag);
            container      = Level.player.container;
            if (hasBag)
            {
                Level.player.PeekBag(out bagItems);
            }

            bool ready = (t2 == EContainerType2.Fruit_Ready ||
                          t2 == EContainerType2.Meat_Ready);
            bool       destroyed = (t2 == EContainerType2.Fruit_Overwashed);
            GameObject go;
            if (!ready && !destroyed)
            {
                go = Level.player.container.prefabRaw;
            }
            else
            {
                go = ready
                    ? Level.player.container.prefabReady
                    : Level.player.container.prefabDestroyed;
            }

            placeItem = Instantiate(go, placePosition.transform.position,
                                    placePosition.transform.rotation);
            Level.player.DropContainer();
        }
        else if ((canPlaceDown && hasItem && hasBag))
        {
            if ((t2 == EContainerType2.Fruit_Ready ||
                 t2 == EContainerType2.Meat_Ready))
            {
                if (bagItems.Count >= 5)
                {
                    Debug.Log("Bag full");
                }
                else
                {
                    Debug.Log("Interact: placed " + t1.ToString() + " into Bag");
                    BagItem bag = new BagItem
                    {
                        t1 = t1,
                        t2 = t2
                    };
                    bagItems.Add(bag);
                    Level.player.DropContainer();
                }
            }
            else
            {
                Debug.Log(
                    "Interact: wash the fruit before placing into Bag.");
            }
        }

        if (canPickUp)
        {
            Debug.Log("Interact: picked up " + placeItemType.ToString());
            placeItem.transform.position =
                Level.player.holdPosition.transform.localPosition;
            //placeItem.transform.position = new Vector3(Level.player.holdPosition.transform.position.x, Level.player.holdPosition.transform.position.y, Level.player.holdPosition.transform.position.z);
            if (hasBag)
            {
                Level.player.CarryBag(bagItems, placeItem, container);
            }
            else
            {
                Level.player.CarryContainer(placeItemType, placeItemType2,
                                            placeItem, container);
            }

            hasItem = false;
            bagItems.Clear();
            Destroy(placeItem);
        }

        RenderBagItems();
    }