Skip to content
Snippets Groups Projects
EmployeeInteraction.cs 2.67 KiB
Newer Older
JonuziFlorina's avatar
JonuziFlorina committed
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class EmployeeInteraction : MonoBehaviour
{
    public GameObject employeePanel;
    public TextMeshProUGUI employeeIDText;
    public TextMeshProUGUI questionText;
    public Button questionButton;
    public Button yesButton;
    public Button noButton;
    public Color correctAnswerColor = Color.green; // Farbe fr die richtige Antwort

    private void Start()
    {
        employeePanel.SetActive(false); // Verstecke das Panel beim Start
        yesButton.gameObject.SetActive(false); // Verstecke JA Button
        noButton.gameObject.SetActive(false); // Verstecke NEIN Button
        questionText.gameObject.SetActive(false); // Verstecke die Frage
    }

    private void OnMouseDown()
    {
        ShowEmployeeID();
    }

    private void ShowEmployeeID()
    {
        employeePanel.SetActive(true);
        employeeIDText.text = "Mitarbeiter ID: 12345"; // Beispielhafte ID
        questionButton.gameObject.SetActive(true);
        questionButton.onClick.RemoveAllListeners();
        questionButton.onClick.AddListener(() => ShowQuestion());
    }

    private void ShowQuestion()
    {
        employeeIDText.text = "Mitarbeiter ID: 12345";
        questionText.text = "Jeder Mitarbeiter muss stets zu jeder Arbeitszeit die Mitarbeiter ID tragen";
        questionText.gameObject.SetActive(true);
        questionButton.gameObject.SetActive(false); // Verstecke den Frage Button
        yesButton.gameObject.SetActive(true); // Zeige JA Button
        noButton.gameObject.SetActive(true); // Zeige NEIN Button

        yesButton.onClick.RemoveAllListeners();
        noButton.onClick.RemoveAllListeners();

        yesButton.onClick.AddListener(() => OnYesButtonClicked());
        noButton.onClick.AddListener(() => OnNoButtonClicked());
    }

    private void OnYesButtonClicked()
    {
        Debug.Log("Ja Button geklickt");
        yesButton.GetComponent<Image>().color = correctAnswerColor; // Markiere JA Button grn
        // Optional: Zeige eine Nachricht an oder fhre eine weitere Aktion aus
    }

    private void OnNoButtonClicked()
    {
        Debug.Log("Nein Button geklickt");
        employeePanel.SetActive(false); // Verstecke das Panel oder fhre andere Aktionen aus
        ResetUI();
    }

    private void ResetUI()
    {
        questionButton.gameObject.SetActive(true); // Zeige den Frage Button
        questionText.gameObject.SetActive(false); // Verstecke die Frage
        yesButton.gameObject.SetActive(false); // Verstecke JA Button
        noButton.gameObject.SetActive(false); // Verstecke NEIN Button
        yesButton.GetComponent<Image>().color = Color.white; // Setze die Farbe des JA Buttons zurck
    }
}