NoPoints pretty much working
This commit is contained in:
89
Assets/Quiz/Scripts/NoPoints/NoPointsController.cs
Normal file
89
Assets/Quiz/Scripts/NoPoints/NoPointsController.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
|
||||
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;
|
||||
|
||||
void Start()
|
||||
{
|
||||
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;
|
||||
foreach (Transform child in answerListContainer.transform)
|
||||
{
|
||||
Destroy(child.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 < question.answerText.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user