void Update() { if (Input.GetMouseButtonDown(0) && UIActionManager.instance.canPickUp) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100f)) { if (hit.collider.gameObject == gameObject) { switch (item.name) { case "Spiral Design": if (GetInventoryItem("Kerosene Lamp") != null) { if (GetInventoryItem("Kerosene Lamp").hasBeenUsed) { // Do use animation. UIActionManager.instance.DoAction_Pickup(item); Destroy(gameObject); } else { indy.TextUpdate("I need something to eat the tarnish to loosen it first."); indy.isTextEnabled = true; } } else { indy.TextUpdate("I need something to eat the tarnish to loosen it first."); indy.isTextEnabled = true; } break; case "Kerosene Lamp": if (DialogSystemManager.instance.isOccupied) { UIActionManager.instance.DoAction_Pickup(item); Destroy(gameObject); } else { indy.TextUpdate("I can't steal it! Well... unless I need to..."); indy.isTextEnabled = true; } break; default: break; } } } } }
IEnumerator DelayedText(CharacterTalkText ctt, string text, float delay) { yield return(new WaitForSeconds(delay)); ctt.TextUpdate(text); ctt.isTextEnabled = true; }
// Update is called once per frame void Update() { if (snakeFight.isActiveAndEnabled) { hasPlayed = true; } if (!snakeFight.isActiveAndEnabled && hasPlayed) { indy.TextUpdate("Good 'ole Mother Nature!"); indy.isTextEnabled = true; Destroy(gameObject); } }
// Used for looking at items in the world public void DoAction_LookAt() { // Check if we can look at something if (canLookAt) { // Check if the left mouse button was clicked if (Input.GetMouseButtonDown(0)) { // Set a ray from the camera to the mouse position Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; // Create a RaycastHit for ray information if (Physics.Raycast(ray, out hit, 100f)) { // Check what was hit and do the appropriate action based on the information switch (hit.collider.gameObject.tag) { case "Jungle Rodent": charTalkText.TextUpdate("It's an oversized rodent!"); charTalkText.isTextEnabled = true; break; case "Kerosene Lamp": charTalkText.TextUpdate("It's a kerosene lamp! Seems to have a little bit of kerosene left."); charTalkText.isTextEnabled = true; break; case "Jeep": charTalkText.TextUpdate("It's our jeep!"); charTalkText.isTextEnabled = true; break; case "Torch": charTalkText.TextUpdate("It's a lit torch, don't touch it!"); charTalkText.isTextEnabled = true; break; case "Sophia": charTalkText.TextUpdate("It's Sophia."); charTalkText.isTextEnabled = true; break; case "Sternhart": charTalkText.TextUpdate("It's Dr. Sternhart."); charTalkText.isTextEnabled = true; break; case "Parrot": charTalkText.TextUpdate("It's a parrot."); charTalkText.isTextEnabled = true; break; default: charTalkText.TextUpdate("You looked at something you weren't supposed to! Perv!"); charTalkText.isTextEnabled = true; break; } } } // Set canLookAt to false canLookAt = false; } }
void UpdateIndy() { indy.TextUpdate(currentChoice.text); indy.isTextEnabled = true; }
public void OnPointerClick(PointerEventData eventData) { // Set didClick flag to true didClick = true; // Get the current Image on this inventory slot button Image thisSlot = GetComponent <Image>(); // Get the instance of the UIActionManager UIActionManager actions = UIActionManager.instance; // Check if we're going to use an item and if we've selected an item from the inventory // to actually use. if (actions.canUse && assignedItem != null) { // Check the name of the item we are going to use and do the appropriate action // for that item. switch (assignedItem.name) { case "Whip": Cursor.SetCursor(whipCursor, Vector2.zero, CursorMode.Auto); InventoryUseItem.instance.currentItem = assignedItem; break; case "Kerosene Lamp": Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); if (assignedItem.isOpen) { InventoryUseItem.instance.currentItem = assignedItem; wasUsed = true; } else { UpdateSprites(assignedItem); indianaJones.TextUpdate("I think I need to open it first."); indianaJones.isTextEnabled = true; wasUsed = false; } break; case "Spiral Design": Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); InventoryUseItem.instance.currentItem = assignedItem; wasUsed = true; break; default: Debug.LogError("Something in switching the cursor went wrong!" + assignedItem); break; } // Set the assignedItem to null as we've either used it or put it back into the inventory //assignedItem = null; // Set the itemDefaultSprite and itemHighlightedSprite to null, as // we no longer have an item. //itemDefaultSprite = null; //itemHighlightedSprite = null; if (wasUsed) { UpdateSprites(null); } } else if (actions.canLookAt) { if (assignedItem != null) { actions.DoAction_LookAt(assignedItem, didClick); } else { if (InventoryUseItem.instance.currentItem != null) { if (!assignedItem.isOpen) { InventoryUIManager.instance.OnInventoryUpdate(InventoryUseItem.instance.currentItem); Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); } else { UpdateSprites(assignedItem); } } else { indianaJones.TextUpdate("There's nothing to look at!"); indianaJones.isTextEnabled = true; } } } else if (actions.canOpen) { if (assignedItem != null) { actions.DoAction_Open(assignedItem); UpdateSprites(assignedItem); } } else if (actions.canClose) { if (assignedItem != null) { actions.DoAction_Close(assignedItem); UpdateSprites(assignedItem); } } }
public void Use(GameObject clickedObj) { if (currentItem != null) { switch (currentItem.name) { case "Whip": Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); InventoryUIManager.instance.OnInventoryUpdate(currentItem); if (clickedObj.CompareTag("Jungle Rodent")) { //TODO: Play Indy whip animation SoundManager.instance.PlayIndyAudio(SoundManager.instance.whipSound); //SoundManager.instance.PlaySuccessAudio(SoundManager.instance.successMusic); RodentAI.instance.WasWhipped = true; } else { indyTalkText.TextUpdate("I can't use that with that"); indyTalkText.isTextEnabled = true; } currentItem = null; break; case "Spiral Design": if (clickedObj.CompareTag("Animal Head")) { animalHead.SetActive(false); animalHeadWithSpiral.SetActive(true); indyTalkText.TextUpdate("Hey it worked!"); indyTalkText.isTextEnabled = true; } else { Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); UIActionManager.instance.DoAction_Pickup(currentItem); currentItem = null; } break; case "Kerosene Lamp": if (currentItem.isOpen) { if (clickedObj.CompareTag("Spiral Design")) { currentItem.hasBeenUsed = true; Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); //currentItem = null; clickedObj.GetComponent <ItemPickUp>().Item.isUsable = true; SoundManager.instance.PlaySuccessAudio(SoundManager.instance.successMusic); // Do the pour animation indyTalkText.TextUpdate("Look! The kerosene ate away the tarnish!"); indyTalkText.isTextEnabled = true; } else { Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); InventoryUIManager.instance.OnInventoryUpdate(currentItem); currentItem = null; indyTalkText.TextUpdate("I can't use that with that"); indyTalkText.isTextEnabled = true; } } else { Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); InventoryUIManager.instance.OnInventoryUpdate(currentItem); currentItem = null; if (clickedObj.CompareTag("Spiral Design")) { indyTalkText.TextUpdate("I need to open it first!"); indyTalkText.isTextEnabled = true; } else { indyTalkText.TextUpdate("I can't use this with that."); indyTalkText.isTextEnabled = true; } } break; default: indyTalkText.TextUpdate("I can't use that!"); indyTalkText.isTextEnabled = true; InventoryUIManager.instance.OnInventoryUpdate(currentItem); currentItem = null; break; } } else { indyTalkText.TextUpdate("I didn't choose an item to use!"); indyTalkText.isTextEnabled = true;; } }