using UnityEngine; using System.Collections; using UnityEngine.UI; using TMPro; public class TabletController : MonoBehaviour { [SerializeField] Animator TabletAnimator; [SerializeField] StarterAssets.StarterAssetsInputs mouseLook; [SerializeField] GameObject crosshair; [SerializeField] GameObject mainMenuCanvas; [SerializeField] GameObject puzzleCanvas; [SerializeField] public bool isOnMainMenu = true; [SerializeField] public TextMeshProUGUI closeTabletPrompt; public bool isShowing = false; private bool isMoving = false; public void setIsOnMainMenu(bool isOnMainMenu) { this.isOnMainMenu = isOnMainMenu; } void Update() { // calculate if player is moving // if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.D)) // { // isMoving = true; // } // else if (Input.GetKeyUp(KeyCode.W) || Input.GetKeyUp(KeyCode.A) || Input.GetKeyUp(KeyCode.S) || Input.GetKeyUp(KeyCode.D)) // { // isMoving = false; // }&& !isMoving if (Input.GetKeyDown(KeyCode.T)) { // if is not showing play tablet open animation if (!isShowing) { // disable prompt to close tablet closeTabletPrompt.enabled = false; TabletAnimator.Play("Tablet_Open"); crosshair.SetActive(false); // set player motion to 0 mouseLook.move = Vector2.zero; mouseLook.look = Vector2.zero; if (mouseLook != null) { mouseLook.cursorInputForLook = false; } // unlock cursor Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } // if is showing play tablet close animation else { closeTabletPrompt.enabled = false; // disable puzzle canvas puzzleCanvas.SetActive(false); // enable main menu canvas mainMenuCanvas.SetActive(true); isOnMainMenu = true; TabletAnimator.Play("Tablet_Close"); crosshair.SetActive(true); // lock cursor Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; if (mouseLook != null) { mouseLook.cursorInputForLook = true; } } isShowing = !isShowing; // Toggle state } } }