void Update() { //if we are pressing the interact button, have an object target and aren't frozen: if (Input.GetButtonDown("Interact") && currentInterobj && moveScript.canMove) { //Do something with the object //send message to object interacting with currentInterobj.SendMessage("DoInteraction"); currentInterobjScript.DoInteraction(); freezeScript.freeze = true; //check to see if the object has a message and talks //if (currentInterobjScript.talks) // { // currentInterobjScript.Talk(); // } } }
//public bool StoreOnDisplay = false; //void Awake() //{ // StoreDeHell.SetActive(false); //} void Update() { // Is Player trying to interact // if (Input.GetButtonDown("Interact") || Input.GetButton("Interact")) if (Input.GetButtonDown("Interact")) { Debug.Log("Player is attempting to interact"); // Check if the player is with D4N if (WithD4N == true) { Debug.Log(D4NManager.PlayerInteracting); Debug.Log("player is interacting with D4N"); D4NManager.PlayerInteracting = true; } // Check if the player is at the store //if (GameManager.AtStore == true) // Player at the store //{ // // Check if the store is on display // if (StoreOnDisplay == false) // Store is not on display // { // StoreDeHell.SetActive(true); // Turn on StoreDeHell canvas // StoreOnDisplay = true; // } // else if (StoreOnDisplay == true) // Store is on display // { // StoreDeHell.SetActive(false); // Turn off StoreDeHell Canvas // StoreOnDisplay = false; // } //} if (currentInteractionObject) { currentInteractionScript.DoInteraction(currentInteractionObject); } else if (gameObjectInventory) { currentInteractionScript.DoInteraction(gameObjectInventory); } } if (Input.GetKey("s") && onStair || Input.GetAxis("VerticalDown") >= 1 && onStair) { playerInteractionStair.isClimbing = true; playerInteractionStair.ClimbDown(); } else if (Input.GetKey("w") && onStair || Input.GetAxis("VerticalUp") == -1 && onStair) { playerInteractionStair.isClimbing = true; playerInteractionStair.ClimbUp(); } else if (onStair) { playerInteractionStair.StopClimbing(); } else if (nameEnviroment) { playerInteractionStair.StopClimbing2(); } if (Input.GetButtonDown("Cancel") || Input.GetButton("CloseInventory")) { currentInteractionScript.HideCanvas(); } }
void Update() { // If player presses 'e' and that object is the current interactable object (in object trigger point) if (Input.GetButtonDown("Interact") && currentInterObj) { // If player has interacted with a medkit and is bleeding from the monster if (currentInterObjScript.IsMedkit() && GetComponent <Bleeding>().bleeding) { // Stops the player from bleeding, resets timer back to 120 and disables it, plays a sound and removes medkit from game GetComponent <Bleeding>().bleeding = false; GetComponent <Bleeding>().timer = 120; GetComponent <Bleeding>().Countdown.enabled = false; audioSource.PlayOneShot(heal); currentInterObj.SetActive(false); } else { //Alert player they can't use medkit } // If the item is an item that can be put in the inventory if (currentInterObjScript.inventory) { // Adds the item to the inventory, removes the item from game, plays sound, adds 1 to the counter and displays it to player. inventory.AddItem(currentInterObj); currentInterObjScript.DoInteraction(); audioSource.clip = keys; audioSource.pitch = 1.5f; audioSource.Play(); count = count + 1; SetCountText(); Debug.Log(currentInterObj.activeInHierarchy); } // uses tags to check which note in particular has been interacted with if (currentInterObj.CompareTag("Note")) { Debug.Log("inside"); // shows that specific note the player interacts with currentInterObj.GetComponent <Note>().ShowNoteImage(); } if (currentInterObj.CompareTag("otherNote")) { Debug.Log("inside"); currentInterObj.GetComponent <Note1>().ShowNoteImage(); } if (currentInterObj.CompareTag("otherNote1")) { Debug.Log("inside"); currentInterObj.GetComponent <Note2>().ShowNoteImage(); } if (currentInterObj.CompareTag("otherNote2")) { Debug.Log("inside"); currentInterObj.GetComponent <Note3>().ShowNoteImage(); } if (currentInterObj.CompareTag("otherNote3")) { Debug.Log("inside"); currentInterObj.GetComponent <Note4>().ShowNoteImage(); } // checks if the interactable object can be opened (eg. doors) if (currentInterObjScript.openable) { // checks if door is locked if (currentInterObjScript.locked) { // checks if player has a key in their inventory if (inventory.FindKey()) { // key is found in inventory: door is unlocked, plays animation, removes 1 from the counter and shows player, plays sound. currentInterObjScript.locked = false; Debug.Log(currentInterObj.name + " was unlocked"); currentInterObjScript.Open(); count = count - 1; SetCountText(); currentInterObjScript.DoInteraction(); audioSource.clip = dooropening; audioSource.pitch = 1f; audioSource.PlayOneShot(dooropening); } else { // key was not found: door stays locked and plays sound. Debug.Log("locked"); currentInterObjScript.locked = true; audioSource.clip = doorlocked; audioSource.pitch = 1f; audioSource.Play(); Debug.Log(currentInterObj.name + " was not unlocked"); } } else { Debug.Log(currentInterObj.name + " is open"); } } currentInterObj = null; } }