RiftMayhem/Assets/Scripts/UI/GameOptionsController.cs
Pedro Gomes d75d51a9c4 Gameplay update
- Added multiple input modes:
   - Point and click (as before)
   - WASD + mouse aiming (fully supported) (need QoL for interactables)
   - Gamepad controls (partial support)

- Sprite indexer to avoid gamebreaking issues when serializing sprites
- Movement speed penalty on casting abilities instead of fully stopping agent
2025-01-17 20:16:02 +00:00

53 lines
1.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameOptionsController : MonoBehaviour
{
[SerializeField]
public List<GameObject> otherUIs;
[SerializeField] private GameObject GameOptionsUI;
[SerializeField] private GameEvent OnGameOptionsOpenned;
[SerializeField] private GameInputBinding gamepadBinding; // New field for gamepad binding
bool isInputTriggered;
private void Start()
{
GameOptionsUI.SetActive(false);
QualitySettings.vSyncCount = 1;
}
// Update is called once per frame
void Update()
{
if (GameStateController.Instance.CurrentState != GameState.GameScene) return;
//if (Input.GetKeyDown(KeyCode.Escape)) ToggleGameOptionsUI();
// Check for input using both keyboard and gamepad
isInputTriggered =
(!string.IsNullOrEmpty(gamepadBinding.bindingName) && GameInputManager.Instance.GetButtonDown(gamepadBinding.bindingName));
if (isInputTriggered)
{
ToggleGameOptionsUI();
}
}
private void ToggleGameOptionsUI()
{
GameOptionsUI.SetActive(!GameOptionsUI.activeSelf);
if (!GameOptionsUI.activeSelf) return;
for (int i = 0; i < otherUIs.Count; i++)
{
otherUIs[i].SetActive(false);
}
OnGameOptionsOpenned.Raise();
}
}