void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Player") { if (deactivateColliderAfterCollision) { gameObject.GetComponent <Collider>().enabled = false; } jumpScareObj = GameObject.Find("JumpScareUI"); jumpScareSpriteRenderer = jumpScareObj.GetComponent <Image>(); jumpScareObj.GetComponent <Transform>().localPosition = new Vector3(spritePosition.x, spritePosition.y, 0.3f); jumpScareObj.GetComponent <Transform>().localScale = new Vector3(spriteScale.x, spriteScale.y, 1.0f); jumpScareSpriteRenderer.sprite = jumpScareSprite; jumpScareSpriteRenderer.color = spriteColor; if (jumpScareAudio != null) { gameObject.GetComponent <AudioSource>().PlayOneShot(jumpScareAudio); } if (saveDeleteState) { FPH_ControlManager.SaveBool(deleteStateKey, true); } StartCoroutine("HideSprite"); } }
void OnMouseDrag() { if (canbeOpen) { playerRot = playerTransform.eulerAngles.y; delta = (playerRot - startPlayerRot) * openDirection; // openDirection si important or player rotation will be the inverse of door rot currRot = (startRot.y + (delta * factor)); currRot = Mathf.Clamp(currRot, minRot, maxRot); // door rotation can't be bigger or smaller than min and max rot transform.eulerAngles = new Vector3(startRot.x, currRot, startRot.z); if (FPH_InventoryManager.equippedItem == neededObject_Name && !hasBeenUnlocked) { hasBeenUnlocked = true; FPH_ControlManager.SaveBool(hasBeenUnlockedKey, hasBeenUnlocked); doorType = 0; //Afte we used the item we unequip it FPH_InventoryManager.equippedItem = ""; FPH_InventoryManager.equippedItem_Index = -1; if (removeItemWhenUsed) { FPH_InventoryManager.RemoveInventoryItem(FPH_InventoryManager.equippedItem_Index); FPH_InventoryManager.SaveInventory(); } } } }
IEnumerator SwitchLight() { objToAnimate.CrossFade(switchAnim); yield return(new WaitForSeconds(switchLightAfter)); if (switchInt == 0) // On { for (int i = 0; i < lightsToSwitch.Length; i++) { lightsToSwitch[i].SetActive(true); } } if (switchInt == 1) // Off { for (int i = 0; i < lightsToSwitch.Length; i++) { lightsToSwitch[i].SetActive(false); } } if (sendMessOnEnd) { yield return(new WaitForSeconds(sendMessageAfter)); sendMessageTo.SendMessage(messageToSend); } FPH_ControlManager.SaveBool(keyToSave, true); }
void PrivateOpen() { if (openSound) { GetComponent <AudioSource>().PlayOneShot(openSound); } objectToAnimate.GetComponent <Animation>().CrossFade(openDoorAniString); if (autoclose) { StartCoroutine("CloseAfterOpen"); } if (FPH_InventoryManager.equippedItem == neededObject_Name && !hasBeenUnlocked) { hasBeenUnlocked = true; FPH_ControlManager.SaveBool(hasBeenUnlockedKey, hasBeenUnlocked); doorType = 0; isOpen = true; if (removeItemWhenUsed) { FPH_InventoryManager.RemoveInventoryItem(FPH_InventoryManager.equippedItem_Index); } //Afte we used the item we unequip it FPH_InventoryManager.equippedItem = ""; FPH_InventoryManager.equippedItem_Index = -1; FPH_InventoryManager.SaveInventory(); } }
IEnumerator SendMess() { objToAnimate.CrossFade(switchAnim); yield return(new WaitForSeconds(switchLightAfter + sendMessageAfter)); sendMessageTo.SendMessage(messageToSend); FPH_ControlManager.SaveBool(keyToSave, true); }
public void OnMouseUp() { if (doorType == 1) { StartCoroutine("PrivateLocked"); } if (doorType == 2) { if (FPH_InventoryManager.equippedItem != neededObject_Name && FPH_InventoryManager.equippedItem != "" && FPH_InventoryManager.equippedItem != " ") { StartCoroutine("PrivateWrongItem"); } if (FPH_InventoryManager.equippedItem == "" || FPH_InventoryManager.equippedItem == " ") { StartCoroutine("PrivateLocked"); } } if (doorType == 3 && !canbeOpen) { StartCoroutine("PrivateLocked"); } if (canbeOpen) { startRot.y = currRot; delta = 0; if (FPH_InventoryManager.equippedItem == neededObject_Name && !hasBeenUnlocked) { hasBeenUnlocked = true; FPH_ControlManager.SaveBool(hasBeenUnlockedKey, hasBeenUnlocked); doorType = 0; //Afte we used the item we unequip it FPH_InventoryManager.equippedItem = ""; FPH_InventoryManager.equippedItem_Index = -1; if (removeItemWhenUsed) { FPH_InventoryManager.RemoveInventoryItem(FPH_InventoryManager.equippedItem_Index); FPH_InventoryManager.SaveInventory(); } } } }
// If the code is right we send the message/setvalue and then deactivate the numpadCamera public void DoneCode() { if (onOk == 0) // SendMessage { if (sendMessageTo != null) { sendMessageTo.SendMessage(messageToSend); } if (sendMessageTo == null) { Debug.LogWarning("No receiver for message - FPH_NumPad_Interactor " + this.gameObject.name); } if (reEnableOnOk) { thisColl.enabled = true; } if (controlWithKeyboard) { numpadButtonMeshes00.material = notSelectedMaterial; numpadButtonMeshes01.material = notSelectedMaterial; numpadButtonMeshes02.material = notSelectedMaterial; numpadButtonMeshes03.material = notSelectedMaterial; numpadButtonMeshes04.material = notSelectedMaterial; numpadButtonMeshes05.material = notSelectedMaterial; numpadButtonMeshes06.material = notSelectedMaterial; numpadButtonMeshes07.material = notSelectedMaterial; numpadButtonMeshes08.material = notSelectedMaterial; numpadButtonMeshes09.material = notSelectedMaterial; numpadButtonMeshesBack.material = notSelectedMaterial; numpadButtonMeshesConfirm.material = notSelectedMaterial; } ingameCamera.SetActive(true); numpadCamera.SetActive(false); FPH_ControlManager.canBeControlled = true; FPH_ControlManager.isScreenLocked = true; // Screen.lockCursor = true; } else if (onOk == 1) // SetVar { if (keyType == 0) // Float { PlayerPrefs.SetFloat(neededKey, valueToSet_Float); } else if (keyType == 1) // Int { PlayerPrefs.SetInt(neededKey, valueToSet_Int); } else if (keyType == 2) // String { PlayerPrefs.SetString(neededKey, valueToSet_String); } else if (keyType == 3) // Bool { FPH_ControlManager.SaveBool(neededKey, valueToSet_Bool); } if (reEnableOnOk) { thisColl.enabled = true; } if (controlWithKeyboard) { numpadButtonMeshes00.material = notSelectedMaterial; numpadButtonMeshes01.material = notSelectedMaterial; numpadButtonMeshes02.material = notSelectedMaterial; numpadButtonMeshes03.material = notSelectedMaterial; numpadButtonMeshes04.material = notSelectedMaterial; numpadButtonMeshes05.material = notSelectedMaterial; numpadButtonMeshes06.material = notSelectedMaterial; numpadButtonMeshes07.material = notSelectedMaterial; numpadButtonMeshes08.material = notSelectedMaterial; numpadButtonMeshes09.material = notSelectedMaterial; numpadButtonMeshesBack.material = notSelectedMaterial; numpadButtonMeshesConfirm.material = notSelectedMaterial; } ingameCamera.SetActive(true); numpadCamera.SetActive(false); FPH_ControlManager.canBeControlled = true; FPH_ControlManager.isScreenLocked = true; // Screen.lockCursor = true; } }
// If the code is right we send the message/setvalue and then deactivate the rotPuzzleCamera IEnumerator DoneCode() { if (onOk == 0) // SendMessage { if (sendMessageTo != null) { sendMessageTo.SendMessage(messageToSend); } if (sendMessageTo == null) { Debug.LogWarning("No receiver for message - FPH_NumPad_Interactor " + this.gameObject.name); } if (reEnableOnOk) { thisColl.enabled = true; } yield return(new WaitForSeconds(0.5f)); if (controlWithKeyboard) { rotDiskMesh01.material = notSelectedMaterial; rotDiskMesh02.material = notSelectedMaterial; rotDiskMesh03.material = notSelectedMaterial; rotDiskMesh04.material = notSelectedMaterial; } ingameCamera.SetActive(true); rotPuzzleCamera.SetActive(false); FPH_ControlManager.canBeControlled = true; FPH_ControlManager.isScreenLocked = true; // Screen.lockCursor = true; } else if (onOk == 1) // SetVar { if (keyType == 0) // Float { PlayerPrefs.SetFloat(neededKey, valueToSet_Float); } else if (keyType == 1) // Int { PlayerPrefs.SetInt(neededKey, valueToSet_Int); } else if (keyType == 2) // String { PlayerPrefs.SetString(neededKey, valueToSet_String); } else if (keyType == 3) // Bool { FPH_ControlManager.SaveBool(neededKey, valueToSet_Bool); } if (reEnableOnOk) { thisColl.enabled = true; } yield return(new WaitForSeconds(0.5f)); if (controlWithKeyboard) { rotDiskMesh01.material = notSelectedMaterial; rotDiskMesh02.material = notSelectedMaterial; rotDiskMesh03.material = notSelectedMaterial; rotDiskMesh04.material = notSelectedMaterial; } ingameCamera.SetActive(true); rotPuzzleCamera.SetActive(false); FPH_ControlManager.canBeControlled = true; FPH_ControlManager.isScreenLocked = true; // Screen.lockCursor = true; } }