public override string UseObjectOnVerb_Inv() { //ObjectInteraction ObjIntInHand=CurrentObjectInHand; if (CurrentObjectInHand != null) { switch (CurrentObjectInHand.GetItemType()) { case ObjectInteraction.RUNE: return("place rune in bag"); } } return(base.UseObjectOnVerb_Inv()); }
public override string UseObjectOnVerb_World() { //ObjectInteraction ObjIntInHand = UWCharacter.Instance.playerInventory.GetObjIntInHand(); if (CurrentObjectInHand != null) { switch (CurrentObjectInHand.GetItemType()) { case ObjectInteraction.POLE: return("trigger with pole"); } } return(base.UseObjectOnVerb_Inv()); }
public override string UseObjectOnVerb_World() { //ObjectInteraction ObjIntInHand=CurrentObjectInHand; if (CurrentObjectInHand != null) { switch (CurrentObjectInHand.GetItemType()) { case ObjectInteraction.KEY: return("turn key in lock"); case ObjectInteraction.SPIKE: return("spike door"); case ObjectInteraction.LOCKPICK: return("attempt lockpicking"); } } return(base.UseObjectOnVerb_Inv()); }
public void OnClick() { if (Dragging == true) { return; } if ((UWCharacter.Instance.isRoaming == true) || (Quest.instance.InDreamWorld)) {//No inventory use while using wizard eye. return; } if (UWCharacter.Instance.playerInventory.currentContainer == UWCharacter.Instance.playerInventory.playerContainer) // UWCharacter.Instance.name) { //Don't do anything on the top level UWCharacter.Instance.playerInventory.ContainerOffset = 0; BackpackBg.SetActive(false); return; } if (CurrentObjectInHand == null) {//Player has no object in their hand. We close up the container. ScrollButtonInventory.ScrollValue = 0; UWCharacter.Instance.playerInventory.ContainerOffset = 0; Container currentContainerObj = UWCharacter.Instance.playerInventory.currentContainer; UWCharacter.Instance.playerInventory.currentContainer = currentContainerObj.ContainerParent; currentContainerObj.isOpenOnPanel = false; //Close child containers as well CloseChildContainer(currentContainerObj); Container DestinationContainer = UWCharacter.Instance.playerInventory.currentContainer; if (UWCharacter.Instance.playerInventory.currentContainer == UWCharacter.Instance.playerInventory.playerContainer) { GetComponent <RawImage>().texture = UWCharacter.Instance.playerInventory.Blank; BackpackBg.SetActive(false); if ((DestinationContainer.CountItems() >= 8) && (DestinationContainer != UWCharacter.Instance.playerInventory.playerContainer)) { InvUp.SetActive(true); InvDown.SetActive(true); } else { InvUp.SetActive(false); InvDown.SetActive(false); } } else { GetComponent <RawImage>().texture = DestinationContainer.transform.GetComponent <ObjectInteraction>().GetEquipDisplay().texture; BackpackBg.SetActive(true); if ((DestinationContainer.CountItems() >= 8) && (DestinationContainer != UWCharacter.Instance.playerInventory.playerContainer)) { InvUp.SetActive(true); InvDown.SetActive(true); } else { InvUp.SetActive(false); InvDown.SetActive(false); } } for (short i = 0; i < 8; i++) { UWCharacter.Instance.playerInventory.SetObjectAtSlot((short)(i + 11), DestinationContainer.GetItemAt(i)); } } else { if (UWCharacter.InteractionMode != UWCharacter.InteractionModePickup) {//Only allow this to happen when in pickup mode. return; } //Move the contents out of the container into the parent. //Container CurrentContainer = UWCharacter.Instance.playerInventory.currentContainer; //GameObject.Find(UWCharacter.Instance.playerInventory.currentContainer).GetComponent<Container>(); Container DestinationContainer = UWCharacter.Instance.playerInventory.currentContainer.ContainerParent; //GameObject.Find(CurrentContainer.ContainerParent).GetComponent<Container>(); if (Container.TestContainerRules(DestinationContainer, 11, false)) { if (!CurrentObjectInHand.IsStackable()) { if (DestinationContainer.AddItemToContainer(CurrentObjectInHand)) {//Object has moved CurrentObjectInHand = null; } } else { if (DestinationContainer.AddItemMergedItemToContainer(CurrentObjectInHand)) {//Object has moved CurrentObjectInHand = null; } } } } }
public void PlayerSlotLeftClick() { if (TradeSlot.Locked) { return; } ObjectInteraction objIntAtSlot = GetGameObjectInteraction(); if (CurrentObjectInHand != null) { //put the object in hand in this slot. if (objectInSlot == null) { //Empty slot //GameObject objToMove = UWCharacter.Instance.playerInventory.GetGameObjectInHand(); if (CurrentObjectInHand != null) { if (CurrentObjectInHand.transform.parent != GameWorldController.instance.DynamicObjectMarker()) { //Object needs to be moved to world //objToMove.transform.parent= GameWorldController.instance.DynamicObjectMarker(); GameWorldController.MoveToWorld(CurrentObjectInHand); ConversationVM.BuildObjectList(); } objectInSlot = CurrentObjectInHand; CurrentObjectInHand = null; SlotImage.texture = UWHUD.instance.CursorIcon; //UWHUD.instance.CursorIcon=UWHUD.instance.CursorIconDefault; Selected = true; } } else { //Swap the objects //GameObject objInSlot = GetGameObjectInteraction().gameObject; //GameObject objInHand = UWCharacter.Instance.playerInventory.GetGameObjectInHand(); if (objIntAtSlot != null) { objIntAtSlot.transform.parent = GameWorldController.instance.InventoryMarker.transform; GameWorldController.MoveToInventory(objIntAtSlot); //This will call rebuild list } if (CurrentObjectInHand != null) { if (CurrentObjectInHand.transform.parent != GameWorldController.instance.DynamicObjectMarker()) { //Object needs to be moved to world //objInHand.transform.parent= GameWorldController.instance.DynamicObjectMarker(); GameWorldController.MoveToWorld(CurrentObjectInHand); } } objectInSlot = CurrentObjectInHand; SlotImage.texture = CurrentObjectInHand.GetInventoryDisplay().texture; //UWHUD.instance.CursorIcon = objInSlot.GetComponent<ObjectInteraction>().GetInventoryDisplay().texture; CurrentObjectInHand = objIntAtSlot; ConversationVM.BuildObjectList(); Selected = true; } } else { if (objectInSlot != null) { //Pickup the object in the slot //UWCharacter.Instance.playerInventory.SetObjectInHand(objectInSlot); CurrentObjectInHand = objIntAtSlot; //UWHUD.instance.CursorIcon= UWCharacter.Instance.playerInventory.GetGameObject(objectInSlot).GetComponent<ObjectInteraction>().GetInventoryDisplay().texture; objectInSlot = null; SlotImage.texture = Blank; Selected = false; //GameObject objToMove = UWCharacter.Instance.playerInventory.GetGameObjectInHand(); if (CurrentObjectInHand != null) { CurrentObjectInHand.transform.parent = GameWorldController.instance.InventoryMarker.transform; GameWorldController.MoveToInventory(CurrentObjectInHand); //This will call rebuild list CurrentObjectInHand.GetComponent <object_base>().PickupEvent(); } } } if (objectInSlot == null) { Quantity.text = ""; } else { int qty = GetGameObjectInteraction().GetQty(); if (qty <= 1) { Quantity.text = ""; } else { Quantity.text = qty.ToString(); } } }
public bool use() { //GameObject ObjectInHand=UWCharacter.Instance.playerInventory.GetGameObjectInHand(); //TODO:add object to container or open container. //Container cn = this.gameObject.GetComponent<Container>(); if (CurrentObjectInHand == null) {//Open the container OpenContainer(); return(true); } else {//Put the item in the container. bool Valid = true; if (CurrentObjectInHand.GetComponent <Container>() != null) { if (this.gameObject.name == CurrentObjectInHand.name) { Valid = false; Debug.Log("Attempt to add a container to itself"); } } if (Container.TestContainerRules(this, 11, false) == false) { Valid = false; return(true); } if (Valid) { if ((CurrentObjectInHand.isQuant == false) || (CurrentObjectInHand.isEnchanted)) { AddItemToContainer(CurrentObjectInHand); } else { AddItemMergedItemToContainer(CurrentObjectInHand); } //If the item is already in the current player container then remove it's reference //if(UWCharacter.Instance.playerInventory.GetCurrentContainer()) // {} if (isOpenOnPanel == true) {//Container is open for display force a refresh. OpenContainer(); } else { //Remove to prevent item duplication removeFromContainer(UWCharacter.Instance.playerInventory.GetCurrentContainer(), CurrentObjectInHand); } CurrentObjectInHand = null; //UWHUD.instance.CursorIcon= UWHUD.instance.CursorIconDefault; return(true); } else { return(false); } } }
void RightClickPickup() { ObjectInteraction ObjectUsedOn = UWCharacter.Instance.playerInventory.GetObjectIntAtSlot(slotIndex);//The object at the clicked slot bool DoNotPickup = false; if (CurrentObjectInHand != null) { if ((SlotCategory != CurrentObjectInHand.GetItemType()) && (SlotCategory != -1)) {//Slot is not a general use on and This item type does not go in this slot. DoNotPickup = true; } //Eating food dropped in helm slot if (SlotCategory == HELM) { if (CurrentObjectInHand.GetItemType() == ObjectInteraction.FOOD) { CurrentObjectInHand.Use(); DoNotPickup = true; return; } } if (CurrentObjectInHand.IsStackable()) { if (ObjectUsedOn != null) { if (ObjectInteraction.CanMerge(ObjectUsedOn, CurrentObjectInHand)) { //merge the items ObjectInteraction.Merge(ObjectUsedOn, CurrentObjectInHand); CurrentObjectInHand = null; UWCharacter.Instance.playerInventory.Refresh(); return; } } } } //Code for when I right click in pickup mode. if (UWCharacter.Instance.playerInventory.GetObjectAtSlot(slotIndex) != null) {//Special case for opening containers in pickup mode. if ((CurrentObjectInHand == null)) { if (ObjectUsedOn.GetComponent <Container>() != null) { if (ObjectUsedOn.GetComponent <Container>().isOpenOnPanel == true) { return; } CurrentObjectInHand = ObjectUsedOn.GetComponent <ObjectInteraction>(); if (this.slotIndex >= 11) { UWCharacter.Instance.playerInventory.currentContainer.RemoveItemFromContainer(UWCharacter.Instance.playerInventory.ContainerOffset + this.slotIndex - 11); } UWCharacter.Instance.playerInventory.ClearSlot(this.slotIndex); return; } } } if (UWCharacter.Instance.playerInventory.GetObjectAtSlot(slotIndex) == null)//No object in slot { if (DoNotPickup == false) { if (Container.TestContainerRules(UWCharacter.Instance.playerInventory.currentContainer, slotIndex, false)) { UWCharacter.Instance.playerInventory.SetObjectAtSlot(slotIndex, CurrentObjectInHand); CurrentObjectInHand = null; } } } else { bool ObjectActivated = false; //Get the object at the slot and test it's activation. //When right clicking only try to activate when an object in in the hand if (CurrentObjectInHand != null) { ObjectActivated = ObjectUsedOn.GetComponent <ObjectInteraction>().Use(); } if (ObjectActivated == false) {//if nothing happened when I clicked on the object at the slot with something in hand. if (CurrentObjectInHand != null) { if (DoNotPickup == false) { //TODO: Make sure this works with Equipment slots //No effect occurred. Swap the two objects. if (Container.TestContainerRules(UWCharacter.Instance.playerInventory.currentContainer, slotIndex, true)) { UWCharacter.Instance.playerInventory.SwapObjects(ObjectUsedOn, slotIndex, CurrentObjectInHand); UWCharacter.Instance.playerInventory.Refresh(); } } } else {//Pick up the item at that slot. //TODO: Make this work with Equipment slots if (DoNotPickup == false) { ObjectInteraction objIntUsedOn = ObjectUsedOn.GetComponent <ObjectInteraction>(); if ((!objIntUsedOn.IsStackable()) || ((objIntUsedOn.IsStackable()) && (objIntUsedOn.GetQty() <= 1))) {//Is either not a quant or is a quantity of 1 CurrentObjectInHand = ObjectUsedOn; if (this.slotIndex >= 11) { UWCharacter.Instance.playerInventory.currentContainer.RemoveItemFromContainer(UWCharacter.Instance.playerInventory.ContainerOffset + this.slotIndex - 11); } UWCharacter.Instance.playerInventory.ClearSlot(this.slotIndex); } else { if (ConversationVM.InConversation == true) { //InventorySlot.TempLookAt = UWHUD.instance.MessageScroll.NewUIOUt.text; //UWHUD.instance.MessageScroll.NewUIOUt.text = ""; UWHUD.instance.ConversationButtonParent.SetActive(false); UWHUD.instance.MessageScroll.Set("Move how many?"); ConversationVM.EnteringQty = true; } else { UWHUD.instance.MessageScroll.Set("Move how many?"); } InputField inputctrl = UWHUD.instance.InputControl; inputctrl.gameObject.SetActive(true); inputctrl.text = objIntUsedOn.GetQty().ToString();//"1"; inputctrl.gameObject.GetComponent <InputHandler>().target = this.gameObject; inputctrl.gameObject.GetComponent <InputHandler>().currentInputMode = InputHandler.InputInventoryQty; inputctrl.contentType = InputField.ContentType.IntegerNumber; inputctrl.Select(); WindowDetect.WaitingForInput = true; Time.timeScale = 0.0f; QuantityObj = ObjectUsedOn; } } } } } }
/// <summary> /// Code for when left clicking in pickup mode /// </summary> void LeftClickPickup() { ObjectInteraction ObjectUsedOn = UWCharacter.Instance.playerInventory.GetObjectIntAtSlot(slotIndex); bool DoNotPickup = false; if (CurrentObjectInHand != null) { //Special case Eating food dropped on helm slot if (SlotCategory == HELM) { if (CurrentObjectInHand.Eat()) {//True is returned if some eating action has taken place. DoNotPickup = true; return; } } if ((SlotCategory != CurrentObjectInHand.GetItemType()) && (SlotCategory != -1)) {//Slot is not a general use one and this item type does not go in this slot. Eg putting a sword on a ring slot DoNotPickup = true; } if (CurrentObjectInHand.IsStackable()) {//Check if object is stackable and if so try and merge them together if the object being added is of the same type. if (ObjectUsedOn != null) { if (ObjectInteraction.CanMerge(ObjectUsedOn, CurrentObjectInHand)) { ObjectInteraction.Merge(ObjectUsedOn, CurrentObjectInHand); CurrentObjectInHand = null; UWCharacter.Instance.playerInventory.Refresh(); return; } } } } if (ObjectUsedOn == null)//No object in slot -> add to the slot { if (DoNotPickup == false) { if (Container.TestContainerRules(UWCharacter.Instance.playerInventory.currentContainer, slotIndex, false)) { UWCharacter.Instance.playerInventory.SetObjectAtSlot(slotIndex, CurrentObjectInHand); CurrentObjectInHand = null; } } } else { //Get the object at the slot and test if it is activated or effected by the object in the players hand if (ObjectUsedOn.Use() == false) {//if nothing happened when I clicked on the object at the slot. if (CurrentObjectInHand != null) { //TODO: Make sure this works with Equipment slots //No effect occurred. Swap the two objects. if (DoNotPickup == false) { if (Container.TestContainerRules(UWCharacter.Instance.playerInventory.currentContainer, slotIndex, true)) { UWCharacter.Instance.playerInventory.SwapObjects(ObjectUsedOn, slotIndex, CurrentObjectInHand); } } } else {//Pick up the item at that slot. //TODO: Make this work with Equipment slots CurrentObjectInHand = ObjectUsedOn; if (this.slotIndex >= 11) { UWCharacter.Instance.playerInventory.currentContainer.RemoveItemFromContainer(UWCharacter.Instance.playerInventory.ContainerOffset + this.slotIndex - 11); } UWCharacter.Instance.playerInventory.ClearSlot(this.slotIndex); } } } }
void LeftClickPickup() {//Code for when I left click in pickup mode ObjectInteraction ObjectUsedOn = UWCharacter.Instance.playerInventory.GetObjectIntAtSlot(slotIndex); bool DoNotPickup = false; if (CurrentObjectInHand != null) { //ObjectInteraction objInt =CurrentObjectInHand; //Eating food dropped in helm slot if (SlotCategory == HELM) { if (CurrentObjectInHand.GetItemType() == ObjectInteraction.FOOD) { CurrentObjectInHand.Use(); DoNotPickup = true; return; } } if ((SlotCategory != CurrentObjectInHand.GetItemType()) && (SlotCategory != -1)) {//Slot is not a general use one andThis item type does not go in this slot. //Debug.Log ("cannot pickup an " + objInt.GetItemType() + " in a " + SlotCategory + " at " + this.name); DoNotPickup = true; } if (CurrentObjectInHand.IsStackable()) { //ObjectUsedOn = UWCharacter.Instance.playerInventory.GetObjectIntAtSlot(slotIndex); if (ObjectUsedOn != null) { if (ObjectInteraction.CanMerge(ObjectUsedOn, CurrentObjectInHand)) { ObjectInteraction.Merge(ObjectUsedOn, CurrentObjectInHand); //UWHUD.instance.CursorIcon= UWHUD.instance.CursorIconDefault; CurrentObjectInHand = null; UWCharacter.Instance.playerInventory.Refresh(); return; } } } } if (ObjectUsedOn == null)//No object in slot { if (DoNotPickup == false) { if (Container.TestContainerRules(UWCharacter.Instance.playerInventory.GetCurrentContainer(), slotIndex, false)) { UWCharacter.Instance.playerInventory.SetObjectAtSlot(slotIndex, CurrentObjectInHand); //UWHUD.instance.CursorIcon= UWHUD.instance.CursorIconDefault; CurrentObjectInHand = null; } } } else { //Get the object at the slot and test it's activation. //ObjectUsedOn = UWCharacter.Instance.playerInventory.GetObjectIntAtSlot(slotIndex); if (ObjectUsedOn.Use() == false) {//if nothing happened when I clicked on the object at the slot. if (CurrentObjectInHand != null) { //TODO: Make sure this works with Equipment slots //No effect occurred. Swap the two objects. if (DoNotPickup == false) { if (Container.TestContainerRules(UWCharacter.Instance.playerInventory.GetCurrentContainer(), slotIndex, true)) { UWCharacter.Instance.playerInventory.SwapObjects(ObjectUsedOn, slotIndex, CurrentObjectInHand); } } } else {//Pick up the item at that slot. //TODO: Make this work with Equipment slots CurrentObjectInHand = ObjectUsedOn; //UWHUD.instance.CursorIcon= ObjectUsedOn.GetComponent<ObjectInteraction>().GetInventoryDisplay().texture; //UWCharacter.Instance.CurrObjectSprite = ObjectUsedOn.GetComponent<ObjectInteraction>().InventoryString; if (this.slotIndex >= 11) { Container cn = GameObject.Find(UWCharacter.Instance.playerInventory.currentContainer).GetComponent <Container>(); cn.RemoveItemFromContainer(UWCharacter.Instance.playerInventory.ContainerOffset + this.slotIndex - 11); } UWCharacter.Instance.playerInventory.ClearSlot(this.slotIndex); } } } }