// Use this for initialization void Start() { if (FPH_ControlManager.LoadBool(deleteStateKey)) { gameObject.SetActive(false); } }
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(); } }
// Use this for initialization void Start() { isOpen = false; hasBeenUnlocked = FPH_ControlManager.LoadBool(hasBeenUnlockedKey); if (hasBeenUnlocked) { doorType = 0; } }
IEnumerator SendMess() { objToAnimate.CrossFade(switchAnim); yield return(new WaitForSeconds(switchLightAfter + sendMessageAfter)); sendMessageTo.SendMessage(messageToSend); FPH_ControlManager.SaveBool(keyToSave, true); }
void Start() { openDirection = -1.0f; playerTransform = GameObject.FindWithTag("Player").transform; startRot = this.gameObject.GetComponent <Transform>().eulerAngles; delta = 0; hasBeenUnlocked = FPH_ControlManager.LoadBool(hasBeenUnlockedKey); if (hasBeenUnlocked) { doorType = 0; } }
public void OpenDoor() { if (doorType == 0) { if (!isOpen) { isOpen = true; PrivateOpen(); return; } if (isOpen) { isOpen = false; PrivateClose(); return; } } 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 (FPH_InventoryManager.equippedItem == neededObject_Name) { PrivateOpen(); } } if (doorType == 3) { bool boolValue = FPH_ControlManager.LoadBool(neededKey); if (boolValue) { PrivateOpen(); } else { StartCoroutine("PrivateLocked"); } } }
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(); } } } }
// Use this for initialization void Start() { thisColl = gameObject.GetComponent <Collider>(); checkedCode = false; selectedPosition = 0; if (onOk == 1) // SetVar // We check if the value has been setted before, in this case we toggle the collider { if (keyType == 0) // Float { float floatToCheck = PlayerPrefs.GetFloat(neededKey); if (floatToCheck == valueToSet_Float) { thisColl.enabled = false; } } else if (keyType == 1) // Int { int intToCheck = PlayerPrefs.GetInt(neededKey); if (intToCheck == valueToSet_Int) { thisColl.enabled = false; } } else if (keyType == 2) // String { string stringToCheck = PlayerPrefs.GetString(neededKey); if (stringToCheck == valueToSet_String) { thisColl.enabled = false; } } else if (keyType == 3) // Bool { bool boolToCheck = FPH_ControlManager.LoadBool(neededKey); if (boolToCheck == valueToSet_Bool) { thisColl.enabled = false; } } } }
// Use this for initialization void Start() { if (interactionInt == 0) // SwitchLight { if (FPH_ControlManager.LoadBool(keyToSave)) { for (int i = 0; i < lightsToSwitch.Length; i++) { lightsToSwitch[i].SetActive(true); } this.GetComponent <Collider>().enabled = false; } } if (interactionInt == 2) // Send Message { if (FPH_ControlManager.LoadBool(keyToSave)) { this.GetComponent <Collider>().enabled = false; } } }
void Update() { if (doorType == 0) { canbeOpen = true; } if (doorType == 1) { canbeOpen = false; } if (doorType == 2) { if (FPH_InventoryManager.equippedItem != neededObject_Name && FPH_InventoryManager.equippedItem != "" && FPH_InventoryManager.equippedItem != " ") { canbeOpen = false; } if (FPH_InventoryManager.equippedItem == "" || FPH_InventoryManager.equippedItem == " ") { canbeOpen = false; } if (FPH_InventoryManager.equippedItem == neededObject_Name) { canbeOpen = true; } } if (doorType == 3) { bool boolValue = FPH_ControlManager.LoadBool(neededKey); if (boolValue) { canbeOpen = true; } else { canbeOpen = false; } } }
// 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; } }
// Use this for initialization void Start() { if (eventType == 0) { if (keyType == 0) { float retrievedFloat = PlayerPrefs.GetFloat(neededKey); if (retrievedFloat == valueToCheck_Float) { if (actionType == 0) { if (toggleThisObj) { gameObject.SetActive(false); } else { for (int i = 0; i < objList.Length; i++) { objList[i].SetActive(false); } } } if (actionType == 1) { sendMessageTo.SendMessage(messageToSend); } } } else if (keyType == 1) { int retrievedInt = PlayerPrefs.GetInt(neededKey); if (retrievedInt == valueToCheck_Int) { if (actionType == 0) { if (toggleThisObj) { gameObject.SetActive(false); } else { for (int i = 0; i < objList.Length; i++) { objList[i].SetActive(false); } } } if (actionType == 1) { sendMessageTo.SendMessage(messageToSend); } } } else if (keyType == 2) { string retrievedString = PlayerPrefs.GetString(neededKey); if (retrievedString == valueToCheck_String) { if (actionType == 0) { if (toggleThisObj) { gameObject.SetActive(false); } else { for (int i = 0; i < objList.Length; i++) { objList[i].SetActive(false); } } } if (actionType == 1) { sendMessageTo.SendMessage(messageToSend); } } } else if (keyType == 3) { bool retrievedBool = FPH_ControlManager.LoadBool(neededKey); if (retrievedBool == valueToCheck_Bool) { if (actionType == 0) { if (toggleThisObj) { gameObject.SetActive(false); } else { for (int i = 0; i < objList.Length; i++) { objList[i].SetActive(false); } } } if (actionType == 1) { sendMessageTo.SendMessage(messageToSend); } } } } }
/* * If we already have this object in our inventory we deactivate it. * Since and object has different inventory name for different languages * we must perform a check for every languages. */ void Start() { if (FPH_LanguageManager.gameLanguage == FPH_LanguageManager.LanguagesEnum.English) { hasObj = FPH_InventoryManager.HasObject(objName_English); } if (FPH_LanguageManager.gameLanguage == FPH_LanguageManager.LanguagesEnum.Italian) { hasObj = FPH_InventoryManager.HasObject(objName_Italian); } if (FPH_LanguageManager.gameLanguage == FPH_LanguageManager.LanguagesEnum.Spanish) { hasObj = FPH_InventoryManager.HasObject(objName_Spanish); } if (FPH_LanguageManager.gameLanguage == FPH_LanguageManager.LanguagesEnum.German) { hasObj = FPH_InventoryManager.HasObject(objName_German); } if (FPH_LanguageManager.gameLanguage == FPH_LanguageManager.LanguagesEnum.French) { hasObj = FPH_InventoryManager.HasObject(objName_French); } if (FPH_LanguageManager.gameLanguage == FPH_LanguageManager.LanguagesEnum.Japanese) { hasObj = FPH_InventoryManager.HasObject(objName_Japanese); } if (FPH_LanguageManager.gameLanguage == FPH_LanguageManager.LanguagesEnum.Chinese) { hasObj = FPH_InventoryManager.HasObject(objName_Chinese); } if (FPH_LanguageManager.gameLanguage == FPH_LanguageManager.LanguagesEnum.Russian) { hasObj = FPH_InventoryManager.HasObject(objName_Russian); } if (deleteIfKey) { hasKey = FPH_ControlManager.LoadBool(neededKey); if (hasKey) { if (obtainedObj == null && gameObject.activeSelf) { gameObject.SetActive(false); } else if (obtainedObj != null && obtainedObj.activeSelf) { obtainedObj.SetActive(false); } } } if (hasObj) { if (obtainedObj == null && gameObject.activeSelf) { gameObject.SetActive(false); } else if (obtainedObj != null && obtainedObj.activeSelf) { obtainedObj.SetActive(false); } } }
// 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; } }