void RunDialogue() //function that runs the dialogue { try { //dialogueText.text = treeToRun.dialogueNodes[nodeIndex].dialogueLines[lineIndex].line; nameText.text = activeNPC.npcInfo.npcName; //characterImage.sprite = activeNPC.npcInfo.npcSprites[0].thisSprite; HandleUISprites(treeToRun.dialogueNodes[nodeIndex].dialogueLines[lineIndex], activeNPC.npcInfo); if (typing == false && lineComplete == false) { dialogueText.text = ""; print("let's type " + treeToRun.dialogueNodes[nodeIndex].dialogueLines[lineIndex].line); type = StartCoroutine(TypeText(treeToRun.dialogueNodes[nodeIndex].dialogueLines[lineIndex].line, dialogueText)); } if (treeToRun.dialogueNodes[nodeIndex].dialogueLines[lineIndex].valuableInfo) { dialogueText.color = importantText; variableStorage.AddInfo(treeToRun.dialogueNodes[nodeIndex].dialogueLines[lineIndex].line, treeToRun.dialogueNodes[nodeIndex]); variableStorage.DiscoverClue(treeToRun.dialogueNodes[nodeIndex]); //play important sfx here if (!hasPlayed) { importantInfoSFX.PlayOneShot(importante); Debug.Log("importante"); } hasPlayed = true; } else { dialogueText.color = normalText; hasPlayed = false; } if (Input.GetKeyDown(KeyCode.E) && typing && lineComplete == false) { StopCoroutine(type); typing = false; dialogueText.text = (treeToRun.dialogueNodes[nodeIndex].dialogueLines[lineIndex].line); lineComplete = true; } else if (Input.GetKeyDown(KeyCode.E) && currentGameState == GameState.DialogueActive && lineComplete) { lineIndex++; lineComplete = false; } if (lineIndex > treeToRun.dialogueNodes[nodeIndex].dialogueLines.Length - 1) { nodeIndex++; lineIndex = 0; } if (treeToRun.dialogueNodes[nodeIndex].dialogueLines[lineIndex].duelTrigger && activeNPC.duelingStatus == NPC.DuelingStatus.CanDuel) { duelTrigger.SetActive(true); if (Input.GetKeyUp(KeyCode.Space)) { currentGameState = GameState.DuelActive; bgNorm.Stop(); bgDuel.Play(); Debug.Log("duel music start"); } } else { duelTrigger.SetActive(false); } UnlockInformation(treeToRun.dialogueNodes[nodeIndex]); if (nodeIndex == treeToRun.dialogueNodes.Length - 1 && lineIndex > treeToRun.dialogueNodes[nodeIndex].dialogueLines.Length) { currentGameState = GameState.OverworldActive; } } catch (System.IndexOutOfRangeException) { currentGameState = GameState.OverworldActive; } }