StellarXipher/Assets/Scripts/TabletController.cs
nlevin6 5e5296c456
All checks were successful
Build project / Build for (StandaloneLinux64, 6000.0.37f1) (push) Successful in 19m32s
Build project / Build for (StandaloneWindows64, 6000.0.37f1) (push) Successful in 20m29s
Build project / Publish to itch.io (StandaloneLinux64) (push) Successful in 9s
Build project / Publish to itch.io (StandaloneWindows64) (push) Successful in 8s
wordle puzzle fully fixed, reassigned tablet button to TAB
2025-03-30 00:09:37 -04:00

86 lines
2.8 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)
{
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
}
}
}