// Create a list of NPCStates, one for each audio source. Audio delays aren't implemented yet, standard of 1f for all. Every trigger plays on "Next". // Initialize the initial question and prompt states as well as the stateController. stateController is hardcoded. void Start() { reactionTimer = System.Diagnostics.Stopwatch.StartNew(); curAnimator = markNPC.GetComponent <Animator>(); NPCIndex = 0; NPCStates = new List <NPCState>(); foreach (var audio in audioSources) { NPCStates.Add(new NPCState(audio, "Next", 1f)); } questionState = BasicQuestionsEnum.Question0; promptState = BasicPromptEnum.Prompt0; // The sequence that the states will progress in. questionState and promptState will be changing too so this just controls whether a prompt or question will appear. stateIndex = 0; stateController = new List <string> { "Prompt", "Question", "Prompt", "Question", "Prompt", "Question", "Prompt", "Prompt", "Question", "Prompt", "Question", "Prompt", "Question" }; Debug.Log("NPCStates size: " + NPCStates.Count); running = true; countDownTimer = new System.Diagnostics.Stopwatch(); DatabaseInserts.CreateSession(Constants.BASIC_SCENEID); data = new List <BasicAnswerData>(); }
// The button press for a prompt. It advances the prompt state and plays the next state. // Prompt4 corresponds to the switch from talking to Mark to talking to John. public void PromptContinue() { // Only switch if the user is close to John. if (promptState.Equals(BasicPromptEnum.Prompt4)) { directions.SetActive(false); } Debug.Log("Prompt continue pressed"); prompt.SetActive(false); promptState = promptState.next(); PlayNextState(); // If the user hits continue at the switching point, switch control and move the menu and prompt next to John. if (promptState.Equals(BasicPromptEnum.Prompt4)) { johnNPC.SetActive(true); curAnimator = johnNPC.GetComponent <Animator>(); johnPlay = true; var newPos = prompt.transform.position; newPos.x = -1.5f; newPos.z = 25f; prompt.transform.position = newPos; newPos.y = questions.transform.position.y; questions.transform.position = newPos; } }
// Gets the next Prompt state. public static BasicPromptEnum next(this BasicPromptEnum value) { return(Enum.GetValues(typeof(BasicPromptEnum)).Cast <BasicPromptEnum>() .SkipWhile(e => e != value).Skip(1).First()); }
// Returns the Prompt delay. public static float GetDelay(this BasicPromptEnum value) { return(value.GetBasicPromptAttribute <BasicPromptAttribute>().Delay); }
// Returns the Prompt. public static string GetPrompt(this BasicPromptEnum value) { return(value.GetBasicPromptAttribute <BasicPromptAttribute>().Prompt); }