97 lines
3.2 KiB
C#
97 lines
3.2 KiB
C#
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using VRC.SDKBase;
|
|
using VRC.Udon;
|
|
using VRC.Udon.Common.Interfaces;
|
|
|
|
public class NoPointsController : UdonSharpBehaviour
|
|
{
|
|
public NoPointsManager noPointsManager;
|
|
|
|
public GameObject questionListContainer;
|
|
public GameObject questionListItemPrefab;
|
|
|
|
public GameObject answerListContainer;
|
|
|
|
public GameObject answerRowPrefab;
|
|
|
|
public TMPro.TMP_Text questionTitleText;
|
|
public TMPro.TMP_Text questionDescriptionText;
|
|
public NoPointsScreen noPointsScreen;
|
|
|
|
public NoPointsMeter noPointsMeter;
|
|
public GameObject resetMeterButton;
|
|
|
|
void Start()
|
|
{
|
|
if (!Networking.IsOwner(this.gameObject))
|
|
{
|
|
this.gameObject.SetActive(false);
|
|
resetMeterButton.SetActive(false);
|
|
}
|
|
|
|
for (int i = 0; i < noPointsManager.questions.Length; i++)
|
|
{
|
|
NoPointsQuestion question = noPointsManager.questions[i];
|
|
GameObject listItemObj = Instantiate(questionListItemPrefab, questionListContainer.transform);
|
|
NoPointsQuestionListItem listItem = listItemObj.GetComponent<NoPointsQuestionListItem>();
|
|
if (listItem != null)
|
|
{
|
|
listItem.Initialize(question);
|
|
listItem.controller = this;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnTitleTextPress()
|
|
{
|
|
if (noPointsManager.currentQuestion == null) return;
|
|
|
|
noPointsScreen.SendCustomNetworkEvent(NetworkEventTarget.All, "ShowQuestionTitle", noPointsManager.currentQuestion.questionTitle);
|
|
}
|
|
|
|
public void OnAnswerInfoPress()
|
|
{
|
|
if (noPointsManager.currentQuestion == null || noPointsManager.currentQuestion.answerInfo.Length == 0) return;
|
|
|
|
noPointsScreen.SendCustomNetworkEvent(NetworkEventTarget.All, "ShowAnswerInfo", noPointsManager.currentQuestion.answerInfo);
|
|
}
|
|
|
|
public void OnAnswerListPress()
|
|
{
|
|
if (noPointsManager.currentQuestion == null) return;
|
|
|
|
|
|
}
|
|
|
|
public void ChangeQuestionPanel(NoPointsQuestion question)
|
|
{
|
|
noPointsManager.currentQuestion = question;
|
|
questionTitleText.text = question.questionTitle;
|
|
questionDescriptionText.text = question.questionDescription;
|
|
for (int i = answerListContainer.transform.childCount - 1; i >= 0; i--)
|
|
{
|
|
Destroy(answerListContainer.transform.GetChild(i).gameObject);
|
|
}
|
|
GameObject answerInfoObj = Instantiate(answerRowPrefab, answerListContainer.transform);
|
|
NoPointsAnswerRow answerInfoRow = answerInfoObj.GetComponent<NoPointsAnswerRow>();
|
|
if (answerInfoRow != null)
|
|
{
|
|
answerInfoRow.Initialize("NO ANSWER", 100);
|
|
answerInfoRow.noPointsMeter = noPointsMeter;
|
|
}
|
|
|
|
for (int i = 0; i < Mathf.Min(question.answerText.Length, question.answerPoints.Length); i++)
|
|
{
|
|
GameObject answerRowObj = Instantiate(answerRowPrefab, answerListContainer.transform);
|
|
NoPointsAnswerRow answerRow = answerRowObj.GetComponent<NoPointsAnswerRow>();
|
|
if (answerRow != null)
|
|
{
|
|
answerRow.Initialize(question.answerText[i], question.answerPoints[i]);
|
|
answerRow.noPointsMeter = noPointsMeter;
|
|
}
|
|
}
|
|
}
|
|
}
|