/// <summary> /// This method is used to open the EndDoor gameObject. distanceTest2 is used to measure the distance between the FPSController and the /// EndDoor gameObject. When this distance is less than 3 metres and the player has the EndKey in their inventory slot, the OpenDoorPanel method /// from the FPSController class will play. This displays text on the screen telling the player how to open the door. When the player /// presses Q, the EndDoor gameObject is set to not active. If the player moves away from the door, or they do not posses the EndKey inventory /// item, then the CloseDoorPanel plays and the text on screen will not display. /// </summary> void EndControlDoor() { if (distanceTest2 < 3 && personController.EndKeyEnabled == true) { personController.OpenDoorPanel(); if (Input.GetKeyDown(KeyCode.Q)) { isLevelComplete = true; //Debug.Log("end door open"); endDoor.SetActive(false); } } if (distanceTest2 > 3 || endDoor.activeInHierarchy == false) { personController.CloseDoorPanel(); } }
/// <summary> /// This method is used to open the Door gameObject. distanceTest is used to measure the distance between the FPSController and the /// Door gameObject. When this distance is less than 3 metres and the player has the Key in their inventory slot, the OpenDoorPanel method /// from the FPSController class will play. This displays text on the screen telling the player how to open the door. When the player /// presses Q, the Door gameObject is set to not active. If the player moves away from the door, or they do not posses the Key inventory /// item, then the CloseDoorPanel plays and the text on screen will not display. /// </summary> void ControlDoor() { if (distanceTest < 3 && personController.KeyEnabled == true) { personController.OpenDoorPanel(); if (Input.GetKeyDown(KeyCode.Q)) { //Debug.Log("door open"); door.SetActive(false); } } if (distanceTest > 3 || door.activeInHierarchy == false) { personController.CloseDoorPanel(); } }