KostraDataTransfer
This commit is contained in:
73
Assets/Scripts/logikadatatransfer.cs
Normal file
73
Assets/Scripts/logikadatatransfer.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
public static GameManager Instance;
|
||||
|
||||
[Header("Kamery")]
|
||||
public Camera kamera1;
|
||||
public Camera kamera2;
|
||||
public Camera kamera3;
|
||||
|
||||
[Header("Download animace")]
|
||||
public List<GameObject> downloadObjects;
|
||||
public float delay = 1f;
|
||||
|
||||
[Header("Kód")]
|
||||
public Text feedbackText;
|
||||
public InputField codeInput;
|
||||
public Text successText;
|
||||
|
||||
private string generatedCode;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (Instance == null) Instance = this;
|
||||
else Destroy(gameObject);
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
kamera1.enabled = true;
|
||||
kamera2.enabled = false;
|
||||
kamera3.enabled = false;
|
||||
StartCoroutine(DownloadAnimace());
|
||||
}
|
||||
|
||||
// ───── KAMERA 1 – animace + generování kódu ─────
|
||||
IEnumerator DownloadAnimace()
|
||||
{
|
||||
foreach (GameObject obj in downloadObjects)
|
||||
obj.SetActive(false);
|
||||
|
||||
foreach (GameObject obj in downloadObjects)
|
||||
{
|
||||
yield return new WaitForSeconds(delay);
|
||||
obj.SetActive(true);
|
||||
}
|
||||
|
||||
generatedCode = "CODE" + Random.Range(1000, 9999);
|
||||
feedbackText.text = "Kód: " + generatedCode;
|
||||
|
||||
kamera1.enabled = false;
|
||||
kamera2.enabled = true;
|
||||
}
|
||||
|
||||
// ───── KAMERA 2 – ověření kódu ─────
|
||||
public void VerifyCode()
|
||||
{
|
||||
if (codeInput.text == generatedCode)
|
||||
{
|
||||
kamera2.enabled = false;
|
||||
kamera3.enabled = true;
|
||||
successText.text = "Úspěch!";
|
||||
}
|
||||
else
|
||||
{
|
||||
feedbackText.text = "Špatný kód, zkus znovu.";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user