// pickup public void CarryContainer(EContainerType containerType, EContainerType2 containerType2, GameObject containerGameObject) { currentContainer = Instantiate(containerGameObject, transform); currentContainerType = containerType; currentContainerType2 = containerType2; isCarryingContainer = true; }
// pickup bag public void CarryBag(List <BagItem> _bagItems, GameObject containerGameObject, Container c) { container = c; bagItems = new List <BagItem>(_bagItems); currentContainer = Instantiate(containerGameObject, transform); currentContainerType = EContainerType.Bag; currentContainerType2 = EContainerType2.Bag; isCarryingContainer = true; hasBag = true; }
public override void Interact() { if (!hasItem) { EContainerType t1; EContainerType2 t2; bool carryingItem = Level.player.PeekContainer(out t1, out t2); Debug.Log("Interact: put " + t1.ToString() + " in the sink"); if (!carryingItem) { Debug.Log("ERROR: PLAYER NOT CARRYING ITEM. Sink.Interact()"); } container = Level.player.container; itemType1 = t1; itemType2 = t2; Level.player.DropContainer(); washing = true; hasItem = true; timer.SetActive(true); timer.transform.forward = Camera.main.transform.forward; alert.transform.forward = Camera.main.transform.forward; timerDone = false; timerMask.transform.DOLocalMoveX(timerMask.transform.localPosition.x - 5f, washTime) .From() .SetEase(Ease.Linear) .OnComplete(OnTimerDone); } else { hasItem = false; washing = false; Vector3 rot = Level.player.interact_item.GetLookAt(); rot.y = transform.position.y; Quaternion temp_rot = Level.player.transform.rotation; Level.player.transform.LookAt(rot); Debug.Log("Interact: " + itemType1 + " is " + (alertDone?"overwashed" : "ready")); itemType2 = alertDone ? EContainerType2.Fruit_Overwashed : EContainerType2.Fruit_Ready; Level.player.CarryContainer(itemType1, itemType2, alertDone ? container.prefabDestroyed : container.prefabReady, container); Level.player.transform.rotation = temp_rot; Level.player.transform.DOLookAt(rot, 0.1f); alertDone = true; alert.SetActive(false); } }
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(); }
// what is the player holding? public bool PeekContainer(out EContainerType containerType, out EContainerType2 containerType2) { containerType = currentContainerType; containerType2 = currentContainerType2; return(isCarryingContainer); }