using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace BetterTee.Player { public class TypingController : ActController { public List submissions; [Header("Prefabs")] public GameObject actNamePrefab; public GameObject actDescriptionPrefab; public GameObject timerPrefab; public GameObject submissionFieldPrefab; public GameObject submitPrefab; public GameObject submittedCountPrefab; [Header("Objects")] protected Text actName; protected Text actDescription; protected Timer actTimer; protected InputField submissionField; protected Submit submit; protected Text submittedCount; protected override void Start() { base.Start(); submissions = new List(); } public override void ActInit() { base.ActInit(); //Load settings TypingSettings typingSettings = settings as TypingSettings; //Init actName Text actName = Instantiate(actNamePrefab, canvas.transform).GetComponent(); actName.text = typingSettings.actName; //Init actDescription Text actDescription = Instantiate(actDescriptionPrefab, canvas.transform).GetComponent(); actDescription.text = typingSettings.actDescription; //Init actTimer actTimer = Instantiate(timerPrefab, canvas.transform).GetComponent(); actTimer.TimerSet(typingSettings.timeLimit); //Init submissionInputField submissionField = Instantiate(submissionFieldPrefab, canvas.transform).GetComponent(); //Init submit Button submit = Instantiate(submitPrefab, canvas.transform).GetComponent(); submit.typingController = this; submit.inputField = submissionField; //Init submissionCount Text submittedCount = Instantiate(submittedCountPrefab, canvas.transform).GetComponent(); submittedCount.text = ""; } public override void ActStart() { base.ActStart(); //Enable submissionField and submit Button submissionField.interactable = true; submit.GetComponent