Some checks failed
Build project / Build for (StandaloneWindows64, 6000.0.37f1) (push) Has been cancelled
Build project / Publish to itch.io (StandaloneLinux64) (push) Has been cancelled
Build project / Publish to itch.io (StandaloneWindows64) (push) Has been cancelled
Build project / Build for (StandaloneLinux64, 6000.0.37f1) (push) Has been cancelled
87 lines
2.9 KiB
C#
87 lines
2.9 KiB
C#
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 GameObject closeTabletPrompt;
|
|
|
|
public bool isShowing = false;
|
|
// private bool isMoving = false;
|
|
|
|
public void setIsOnMainMenu(bool isOnMainMenu)
|
|
{
|
|
Debug.Log("Setting isOnMainMenu to " + 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.Tab))
|
|
{
|
|
// 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;
|
|
mouseLook.moveLocked = true;
|
|
}
|
|
// unlock cursor
|
|
Cursor.lockState = CursorLockMode.None;
|
|
Cursor.visible = true;
|
|
}
|
|
// if is showing play tablet close animation
|
|
else
|
|
{
|
|
// closeTabletPrompt.enabled = false;
|
|
closeTabletPrompt.SetActive(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;
|
|
mouseLook.moveLocked = false;
|
|
}
|
|
}
|
|
isShowing = !isShowing; // Toggle state
|
|
|
|
|
|
}
|
|
}
|
|
}
|