mirror of
https://github.com/ConjureETS/GameOff2024.git
synced 2026-03-24 05:00:59 +00:00
37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using GameOff.Core;
|
|
using GameOff.Quiz;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace GameOff.UI.Quiz
|
|
{
|
|
public class QuestionUI: MonoBehaviour
|
|
{
|
|
public event EventHandler<string> OnChoiceUptade;
|
|
|
|
[SerializeField] private Text number;
|
|
[SerializeField] private Image question;
|
|
[SerializeField] private Transform choiceHolder;
|
|
[SerializeField] private ChoiceUI choicePrefab;
|
|
|
|
public void SetUp(QuestionInfo info)
|
|
{
|
|
number.text = $"{info.Index}.";
|
|
question.sprite = info.Question;
|
|
|
|
foreach (string answer in info.Choices)
|
|
{
|
|
ChoiceUI choice = Instantiate(choicePrefab, choiceHolder);
|
|
choice.SetUp(answer, this);
|
|
choice.OnAswerTrigger += ChoiceUI_OnAswerTrigger;
|
|
}
|
|
}
|
|
|
|
private void ChoiceUI_OnAswerTrigger(object sender, string e)
|
|
{
|
|
OnChoiceUptade?.Invoke(this, e);
|
|
}
|
|
}
|
|
} |