59 lines
1.7 KiB
C#
59 lines
1.7 KiB
C#
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
using UnityEngine.InputSystem.Utilities;
|
|
|
|
public class GameManager : MonoBehaviour
|
|
{
|
|
[Header("Interfejs")]
|
|
public GameObject startUI; // Twój Canvas z napisem
|
|
|
|
[Header("Skrypty Gracza")]
|
|
public PlayerMove playerMove; // Skrypt poruszania fasolk¹
|
|
public MouseLook mouseLook; // Skrypt obracania kamer¹
|
|
|
|
[Header("Modu³ MQTT")]
|
|
public MqttCollector mqttCollector; // Skrypt MQTTnet
|
|
|
|
private bool hasStarted = false;
|
|
|
|
void Start()
|
|
{
|
|
// 1. Upewnij siê, ¿e na starcie wszystko jest zablokowane
|
|
if (playerMove != null) playerMove.enabled = false;
|
|
if (mouseLook != null) mouseLook.canLook = false;
|
|
|
|
// 2. Kursor musi byæ widoczny i wolny, ¿eby gracz wiedzia³, ¿e gra jeszcze nie ruszy³a
|
|
Cursor.lockState = CursorLockMode.None;
|
|
Cursor.visible = true;
|
|
|
|
// 3. Czekamy na "Any Key" (dowolny przycisk klawiatury, myszy lub kontrolera VR)
|
|
InputSystem.onAnyButtonPress.CallOnce(ctrl => StartGame());
|
|
|
|
Debug.Log("GameManager: Oczekiwanie na start...");
|
|
}
|
|
|
|
void StartGame()
|
|
{
|
|
if (hasStarted) return;
|
|
hasStarted = true;
|
|
|
|
// 1. Ukrywamy UI
|
|
if (startUI != null)
|
|
startUI.SetActive(false);
|
|
|
|
// 2. Odblokowujemy ruch i kamerê
|
|
if (playerMove != null)
|
|
playerMove.enabled = true;
|
|
|
|
if (mouseLook != null)
|
|
mouseLook.EnableLooking(); // Ta funkcja schowa te¿ kursor
|
|
|
|
// 3. Odpalamy zbieranie danych MQTT
|
|
if (mqttCollector != null)
|
|
{
|
|
mqttCollector.BeginSession();
|
|
}
|
|
|
|
Debug.Log("<color=green>SYSTEM: Gra i logowanie danych uruchomione!</color>");
|
|
}
|
|
} |