public void GiveKeyOfTruth() { if (HasGivenKey == false) { //Code to spawn key of truth in player hand //Debug.Log ("You get the key of truth"); UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_none_of_your_skills_improved_)); //No skills appear //inputctrl.text=UWHUD.instance.MessageScroll.text; Shrine.HasGivenKey = true; //create the key of truth. ObjectLoaderInfo newobjt = ObjectLoader.newObject(225, 0, 0, 0, 256); GameObject key = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.InventoryMarker.gameObject, GameWorldController.instance.InventoryMarker.transform.position).gameObject; GameWorldController.MoveToInventory(key); ObjectInteraction myObjInt = key.GetComponent <ObjectInteraction>(); /*ObjectInteraction myObjInt = ObjectInteraction.CreateNewObject(225); * myObjInt.gameObject.transform.parent=GameWorldController.instance.InventoryMarker.transform; * GameWorldController.MoveToInventory(myObjInt.gameObject);*/ UWCharacter.Instance.playerInventory.ObjectInHand = myObjInt.name; UWHUD.instance.CursorIcon = myObjInt.GetInventoryDisplay().texture; UWCharacter.InteractionMode = UWCharacter.InteractionModePickup; InteractionModeControl.UpdateNow = true; } }
void DisplayGameObject(ObjectInteraction obj, RawImage Label, Text qtyDisplay, bool isEquipped, ref bool hasChanged) { if (hasChanged == true) { if (obj == null) { Label.texture = Blank; if (qtyDisplay != null) { qtyDisplay.text = ""; } hasChanged = false; return; } hasChanged = false; if (obj != null) { if (isEquipped == true) { Label.texture = obj.GetEquipDisplay().texture; } else { Label.texture = obj.GetInventoryDisplay().texture; if (qtyDisplay != null) { int qty = obj.GetQty(); if (qty <= 1) { qtyDisplay.text = ""; } else { qtyDisplay.text = qty.ToString(); } } } } else { Label.texture = Blank; if (qtyDisplay != null) { qtyDisplay.text = ""; } } } }
/// <summary> /// Fishing Code. /// </summary> private void GoFish() { int tileX = (int)(UWCharacter.Instance.transform.position.x / 1.2f); int tileY = (int)(UWCharacter.Instance.transform.position.z / 1.2f); for (int x = -1; x <= 1; x++) { //test the tile and it's neighbours for water. for (int y = -1; y <= 1; y++) { if (GameWorldController.instance.currentTileMap().Tiles[tileX + x, tileY + y].isWater) { if (Random.Range(0, 10) >= 7) { //catch something or test for encumerance //000~001~099~You catch a lovely fish. if ((GameWorldController.instance.commonObject.properties[182].mass * 0.1f) <= UWCharacter.Instance.playerInventory.getEncumberance()) { UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_you_catch_a_lovely_fish_)); GameObject fishy = CreateFish(); UWCharacter.Instance.playerInventory.ObjectInHand = fishy.name; ObjectInteraction FishobjInt = fishy.GetComponent <ObjectInteraction>(); if (FishobjInt != null) { FishobjInt.UpdateAnimation(); //UWHUD.instance.CursorIcon= //FishobjInt.InventoryDisplay.texture; UWHUD.instance.CursorIcon = FishobjInt.GetInventoryDisplay().texture; //FishobjInt.InventoryDisplay.texture; FishobjInt.isquant = 1; } UWCharacter.InteractionMode = UWCharacter.InteractionModePickup; InteractionModeControl.UpdateNow = true; } else { //000~001~102~You feel a nibble, but the fish gets away. UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_you_feel_a_nibble_but_the_fish_gets_away_)); } } else { //000~001~100~No luck this time. UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_no_luck_this_time_)); } return; } } } //000~001~101~You cannot fish there. Perhaps somewhere else. UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_you_cannot_fish_there__perhaps_somewhere_else_)); }
public virtual void Pickup(ObjectInteraction objPicked, PlayerInventory pInv) { //completes the pickup. objPicked.PickedUp = true; if (objPicked.GetComponent <Container>() != null) { Container.SetPickedUpFlag(objPicked.GetComponent <Container>(), true); Container.SetItemsParent(objPicked.GetComponent <Container>(), InvMarker.transform); Container.SetItemsPosition(objPicked.GetComponent <Container>(), InvMarker.transform.position); } CursorIcon = objPicked.GetInventoryDisplay().texture; pInv.ObjectInHand = objPicked.transform.name; //////pInv.JustPickedup=true;//To stop me throwing it away immediately. if (objPicked.GetComponent <Rigidbody>() != null) { WindowDetect.FreezeMovement(objPicked.gameObject); } objPicked.transform.position = InvMarker.transform.position; objPicked.transform.parent = InvMarker.transform; objPicked.Pickup(); //Call pickup event for this object. }
public virtual ObjectInteraction Pickup(ObjectInteraction objPicked, PlayerInventory pInv) { //completes the pickup. objPicked.PickedUp = true; if (objPicked.GetComponent <Container>() != null) { Container.SetPickedUpFlag(objPicked.GetComponent <Container>(), true); Container.SetItemsParent(objPicked.GetComponent <Container>(), GameWorldController.instance.InventoryMarker.transform); Container.SetItemsPosition(objPicked.GetComponent <Container>(), GameWorldController.instance.InventoryMarker.transform.position); } UWHUD.instance.CursorIcon = objPicked.GetInventoryDisplay().texture; pInv.ObjectInHand = objPicked.transform.name; if (objPicked.GetComponent <Rigidbody>() != null) { GameWorldController.FreezeMovement(objPicked.gameObject); } objPicked.transform.position = GameWorldController.instance.InventoryMarker.transform.position; objPicked.transform.parent = GameWorldController.instance.InventoryMarker.transform; GameWorldController.MoveToInventory(objPicked); pInv.ObjectInHand = objPicked.transform.name; objPicked.Pickup(); return(objPicked); }
private void MusicInstrumentInteaction() { if (Input.GetKeyDown("1")) { PlayNote(1); } if (Input.GetKeyDown("2")) { PlayNote(2); } if (Input.GetKeyDown("3")) { PlayNote(3); } if (Input.GetKeyDown("4")) { PlayNote(4); } if (Input.GetKeyDown("5")) { PlayNote(5); } if (Input.GetKeyDown("6")) { PlayNote(6); } if (Input.GetKeyDown("7")) { PlayNote(7); } if (Input.GetKeyDown("8")) { PlayNote(8); } if (Input.GetKeyDown("9")) { PlayNote(9); } if (Input.GetKeyDown("0")) { PlayNote(10); } if (Input.GetKeyDown(KeyCode.Escape)) { //000~001~251~You put the instrument down. PlayingInstrument = false; CurrentInstrument = ""; WindowDetectUW.WaitingForInput = false; UWCharacter.Instance.playerMotor.enabled = true; UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_you_put_the_instrument_down_)); GameWorldController.instance.getMus().Resume(); //354237875 if (_RES == GAME_UW1) { if ((NoteRecord == "354237875") && (objInt().item_id == 292)) //Flute only { //UWHUD.instance.MessageScroll.Add ("Eyesnack would be proud of your playing"); if ((GameWorldController.instance.LevelNo == 2) && (Quest.instance.isCupFound == false) && (objInt().item_id == 292)) { int tileX = TileMap.visitTileX; int tileY = TileMap.visitTileY; if (((tileX >= 23) || (tileX <= 27)) && ((tileY >= 43) || (tileY <= 45))) { //create the cup of wonder. ObjectLoaderInfo newobjt = ObjectLoader.newObject(174, 0, 0, 0, 256); GameObject cup = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.InventoryMarker.gameObject, GameWorldController.instance.InventoryMarker.transform.position).gameObject; GameWorldController.MoveToInventory(cup); ObjectInteraction myObjInt = cup.GetComponent <ObjectInteraction>(); /* ObjectInteraction myObjInt = ObjectInteraction.CreateNewObject(174); * myObjInt.gameObject.transform.parent=GameWorldController.instance.InventoryMarker.transform; * GameWorldController.MoveToInventory(myObjInt.gameObject);*/ UWCharacter.Instance.playerInventory.ObjectInHand = myObjInt.name; UWHUD.instance.CursorIcon = myObjInt.GetInventoryDisplay().texture; UWCharacter.InteractionMode = UWCharacter.InteractionModePickup; InteractionModeControl.UpdateNow = true; Quest.instance.isCupFound = true; //An object appears in the air and falls into your hands UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 136)); } } } } } }
public override bool Eat() { //TODO:Implement drag and drop feeding. if (Nutrition() + UWCharacter.Instance.FoodLevel >= 255) { UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_you_are_too_full_to_eat_that_now_)); return(false); } else { UWCharacter.Instance.FoodLevel = Nutrition() + UWCharacter.Instance.FoodLevel; switch (objInt().item_id) //TODO:update for UW2 { case 192: //plants case 207: case 212: UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_the_plant_is_plain_tasting_but_nourishing_)); break; case 217: //Dead rotworm UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 234)); break; case 283: //Rotworm stew UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 235)); break; default: UWHUD.instance.MessageScroll.Add("That " + StringController.instance.GetObjectNounUW(objInt()) + foodFlavourText()); break; } if (ObjectInteraction.PlaySoundEffects) { switch (Random.Range(1, 3)) { case 1: UWCharacter.Instance.aud.clip = GameWorldController.instance.getMus().SoundEffects[MusicController.SOUND_EFFECT_EAT_1]; break; case 2: UWCharacter.Instance.aud.clip = GameWorldController.instance.getMus().SoundEffects[MusicController.SOUND_EFFECT_EAT_2]; break; default: UWCharacter.Instance.aud.clip = GameWorldController.instance.getMus().SoundEffects[MusicController.SOUND_EFFECT_EAT_3]; break; } UWCharacter.Instance.aud.Play(); } if (_RES == GAME_UW2) { //Some food items leave left overs int LeftOverToCreate = -1; switch (objInt().item_id) { case 176: case 177: //meat LeftOverToCreate = 197; break; case 186: //honeycomb LeftOverToCreate = 210; break; case 187: case 188: case 189: //bottles. LeftOverToCreate = 317; break; } if (LeftOverToCreate != -1) { ObjectLoaderInfo newobjt = ObjectLoader.newObject(LeftOverToCreate, 40, 0, 0, 256); newobjt.InUseFlag = 1; ObjectInteraction created = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, GameWorldController.instance.InventoryMarker.transform.position); GameWorldController.MoveToWorld(created.gameObject); UWCharacter.Instance.playerInventory.ObjectInHand = created.name; UWHUD.instance.CursorIcon = created.GetInventoryDisplay().texture; UWCharacter.InteractionMode = UWCharacter.InteractionModePickup; } } objInt().consumeObject(); //destroy and remove from inventory/world. return(true); //Food was eaten. } }
public void OnSubmitPickup(int quant) { InputField inputctrl = UWHUD.instance.InputControl; inputctrl.text = ""; inputctrl.gameObject.SetActive(false); WindowDetect.WaitingForInput = false; ConversationVM.EnteringQty = false; if (ConversationVM.InConversation == false) { UWHUD.instance.MessageScroll.Clear(); Time.timeScale = 1.0f; } else { UWHUD.instance.MessageScroll.NewUIOUt.text = InventorySlot.TempLookAt; //Restore original text } if (quant == 0) { //cancel QuantityObj = null; } if (QuantityObj != null) { //Just do a normal pickup. if (quant >= QuantityObj.GetComponent <ObjectInteraction>().link) { UWCharacter.Instance.playerInventory.ObjectInHand = QuantityObj.name; UWHUD.instance.CursorIcon = QuantityObj.GetComponent <ObjectInteraction>().GetInventoryDisplay().texture; if (this.slotIndex >= 11) { UWCharacter.Instance.playerInventory.GetCurrentContainer().RemoveItemFromContainer(UWCharacter.Instance.playerInventory.ContainerOffset + this.slotIndex - 11); } UWCharacter.Instance.playerInventory.ClearSlot(this.slotIndex); } else { //split the obj. ObjectInteraction objI = QuantityObj.GetComponent <ObjectInteraction>(); objI.link = objI.link - quant; ObjectLoaderInfo newObj = ObjectLoader.newObject(objI.item_id, objI.quality, objI.owner, quant, -1); newObj.is_quant = 1; ObjectInteraction NewObjI = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newObj, GameWorldController.instance.CurrentObjectList().objInfo, GameWorldController.instance.InventoryMarker, GameWorldController.instance.InventoryMarker.transform.position); GameWorldController.MoveToInventory(NewObjI); UWCharacter.Instance.playerInventory.ObjectInHand = NewObjI.name; UWHUD.instance.CursorIcon = NewObjI.GetInventoryDisplay().texture; ObjectInteraction.Split(objI, NewObjI); UWCharacter.Instance.playerInventory.Refresh(slotIndex); QuantityObj = null; /* GameObject Split = Instantiate(QuantityObj);//What we are picking up. * Split.GetComponent<ObjectInteraction>().link =quant; * Split.name = Split.name+"_"+UWCharacter.Instance.summonCount++; * Split.transform.parent=UWCharacter.Instance.playerInventory.InventoryMarker.transform;//this.transform.parent; * QuantityObj.GetComponent<ObjectInteraction>().link=QuantityObj.GetComponent<ObjectInteraction>().link-quant; * UWCharacter.Instance.playerInventory.ObjectInHand= Split.name; * UWHUD.instance.CursorIcon= Split.GetComponent<ObjectInteraction>().GetInventoryDisplay().texture; * ObjectInteraction.Split (Split.GetComponent<ObjectInteraction>(),QuantityObj.GetComponent<ObjectInteraction>()); * UWCharacter.Instance.playerInventory.Refresh (slotIndex); * QuantityObj=null;//Clear out to avoid weirdness.*/ } } }
void RightClickPickup() { //pInv = player.GetComponent<PlayerInventory>(); GameObject ObjectUsedOn = null; //The object at the clicked slot bool DoNotPickup = false; if (UWCharacter.Instance.playerInventory.ObjectInHand != "") { ObjectInteraction objInt = UWCharacter.Instance.playerInventory.GetGameObjectInHand().GetComponent <ObjectInteraction>(); if ((SlotCategory != objInt.GetItemType()) && (SlotCategory != -1)) { //Slot is not a general use on andThis item type does not go in this slot. // Debug.Log ("cannot pickup an " + objInt.GetItemType() + " in a " + SlotCategory); DoNotPickup = true; } //Eating food dropped in helm slot if (SlotCategory == HELM) { if (objInt.GetItemType() == ObjectInteraction.FOOD) { objInt.Use(); DoNotPickup = true; return; } } //if ((objInt.isQuant()==true) && (objInt.isEnchanted()==false)) if (objInt.IsStackable()) { ObjectUsedOn = UWCharacter.Instance.playerInventory.GetGameObjectAtSlot(slotIndex); //GameObject.Find (pInv.GetObjectAtSlot(slotIndex)); if (ObjectUsedOn != null) { if (ObjectInteraction.CanMerge(ObjectUsedOn.GetComponent <ObjectInteraction>(), objInt)) // if ((objInt.item_id==ObjectUsedOn.GetComponent<ObjectInteraction>().item_id) && (objInt.quality==ObjectUsedOn.GetComponent<ObjectInteraction>().quality)) { //merge the items ObjectInteraction.Merge(ObjectUsedOn.GetComponent <ObjectInteraction>(), objInt); //ObjectUsedOn.GetComponent<ObjectInteraction>().link=ObjectUsedOn.GetComponent<ObjectInteraction>().link+objInt.link; UWHUD.instance.CursorIcon = UWHUD.instance.CursorIconDefault; UWCharacter.Instance.playerInventory.ObjectInHand = ""; UWCharacter.Instance.playerInventory.Refresh(slotIndex); //Destroy(objInt.gameObject); return; } } } } //Code for when I right click in pickup mode. if (UWCharacter.Instance.playerInventory.GetObjectAtSlot(slotIndex) != "") { //Special case for opening containers in pickup mode. ObjectUsedOn = UWCharacter.Instance.playerInventory.GetGameObjectAtSlot(slotIndex); if ((UWCharacter.Instance.playerInventory.ObjectInHand == "")) { if (ObjectUsedOn.GetComponent <Container>() != null) { if (ObjectUsedOn.GetComponent <Container>().isOpenOnPanel == true) { return; } UWCharacter.Instance.playerInventory.ObjectInHand = ObjectUsedOn.name; UWHUD.instance.CursorIcon = ObjectUsedOn.GetComponent <ObjectInteraction>().GetInventoryDisplay().texture; if (this.slotIndex >= 11) { //Container cn = //;GameObject.Find(pInv.currentContainer).GetComponent<Container>(); UWCharacter.Instance.playerInventory.GetCurrentContainer().RemoveItemFromContainer(UWCharacter.Instance.playerInventory.ContainerOffset + this.slotIndex - 11); } UWCharacter.Instance.playerInventory.ClearSlot(this.slotIndex); return; } } } if (UWCharacter.Instance.playerInventory.GetObjectAtSlot(slotIndex) == "") //No object in slot { if (DoNotPickup == false) { if (Container.TestContainerRules(UWCharacter.Instance.playerInventory.GetCurrentContainer(), slotIndex, false)) { UWCharacter.Instance.playerInventory.SetObjectAtSlot(slotIndex, UWCharacter.Instance.playerInventory.ObjectInHand); UWHUD.instance.CursorIcon = UWHUD.instance.CursorIconDefault; UWCharacter.Instance.playerInventory.SetObjectInHand(""); // .ObjectInHand=""; } } } else { bool ObjectActivated = false; //Get the object at the slot and test it's activation. ObjectUsedOn = UWCharacter.Instance.playerInventory.GetGameObjectAtSlot(slotIndex); //GameObject.Find (pInv.GetObjectAtSlot(slotIndex)); //When right clicking only try to activate when an object in in the hand if (UWCharacter.Instance.playerInventory.GetObjectInHand() != "") { 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 (UWCharacter.Instance.playerInventory.GetObjectInHand() != "") { if (DoNotPickup == false) { //TODO: Make sure this works with Equipment slots //No effect occurred. Swap the two objects. if (Container.TestContainerRules(UWCharacter.Instance.playerInventory.GetCurrentContainer(), slotIndex, true)) { UWCharacter.Instance.playerInventory.SwapObjects(ObjectUsedOn, slotIndex, UWCharacter.Instance.playerInventory.ObjectInHand); 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 ((ObjectUsedOn.GetComponent<ObjectInteraction>().isQuant() ==false) || ((ObjectUsedOn.GetComponent<ObjectInteraction>().isQuant())&&(ObjectUsedOn.GetComponent<ObjectInteraction>().link==1)) || (ObjectUsedOn.GetComponent<ObjectInteraction>().isEnchanted() ==true)) if ((!objIntUsedOn.IsStackable()) || ((objIntUsedOn.IsStackable()) && (objIntUsedOn.GetQty() <= 1))) { //Is either not a quant or is a quantity of 1 UWCharacter.Instance.playerInventory.ObjectInHand = ObjectUsedOn.name; //UWHUD.instance.CursorIcon= ObjectUsedOn.GetComponent<ObjectInteraction>().GetInventoryDisplay().texture; UWHUD.instance.CursorIcon = objIntUsedOn.GetInventoryDisplay().texture; if (this.slotIndex >= 11) { UWCharacter.Instance.playerInventory.GetCurrentContainer().RemoveItemFromContainer(UWCharacter.Instance.playerInventory.ContainerOffset + this.slotIndex - 11); } UWCharacter.Instance.playerInventory.ClearSlot(this.slotIndex); } else { //Debug.Log("attempting to pick up a quantity"); if (ConversationVM.InConversation == true) { //UWHUD.instance.MessageScroll.SetAnchorX(1.0f);//Move off screen. //UWHUD.instance.MessageScrollTemp.SetAnchorX(0.06f); InventorySlot.TempLookAt = UWHUD.instance.MessageScroll.NewUIOUt.text; 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; } } } } } }
public virtual ObjectInteraction Pickup(ObjectInteraction objPicked, PlayerInventory pInv) { //completes the pickup. objPicked.PickedUp=true; if (objPicked.GetComponent<Container>()!=null) { Container.SetPickedUpFlag(objPicked.GetComponent<Container>(),true); Container.SetItemsParent(objPicked.GetComponent<Container>(),InvMarker.transform); Container.SetItemsPosition (objPicked.GetComponent<Container>(),InvMarker.transform.position); } UWHUD.instance.CursorIcon=objPicked.GetInventoryDisplay().texture; pInv.ObjectInHand=objPicked.transform.name; //////pInv.JustPickedup=true;//To stop me throwing it away immediately. if (objPicked.GetComponent<Rigidbody>() !=null) { GameWorldController.FreezeMovement(objPicked.gameObject); } //Clone the object into the inventory if (WindowDetectUW.UsingRoomManager==true) { GameObject objClone = Instantiate(objPicked.gameObject); objClone.name=objPicked.name; objPicked.name=objPicked.name+ "_destroyed"; //objPicked.transform.DestroyChildren(); DestroyImmediate(objPicked.gameObject); objClone.transform.position = InvMarker.transform.position; objClone.transform.parent=InvMarker.transform; objClone.GetComponent<ObjectInteraction>().Pickup(); /* UniqueIdentifier uid=objClone.GetComponent<UniqueIdentifier>(); if (uid!=null) { //uid.Id=uid.GetInstanceID().ToString(); } */ objClone.GetComponent<ObjectInteraction>().Pickup(); return objClone.GetComponent<ObjectInteraction>(); } else { objPicked.transform.position=InvMarker.transform.position; objPicked.transform.parent=InvMarker.transform; objPicked.Pickup(); return objPicked; } //objPicked.transform.position = InvMarker.transform.position; //objPicked.transform.parent=InvMarker.transform; //objPicked.Pickup();//Call pickup event for this object. }