void Interact() { //This code allows the player to interact with the envirenment using a Raycast RaycastHit hit; if (Physics.Raycast(transform.position, transform.forward, out hit, interactRange)) { //Here is where we check if something gets hit by the Raycast Debug.Log(hit.collider.gameObject); //This code checks if the object that has been hit has dialogue for the player DialogueNPC dialogueHit = hit.collider.gameObject.GetComponent <DialogueNPC>(); if (dialogueHit != null && dialogueHit.canInteract == true) { //If true, we inaite the dialogue and bring the cursor back into existence //We also stop the player from moving during the dialogue dialogueHit.BeginDialogue(); movementScript.movementLock = true; Cursor.lockState = CursorLockMode.None; Cursor.visible = true; cameraLock = true; } ExitToArea exitHit = hit.collider.gameObject.GetComponent <ExitToArea>(); if (exitHit == true) { //Sniff something is missing here exitHit.EnterArea(); } } }
public override void RespondToInput(GameController controller, string[] separatedInputWords, string[] separatedCompleteInputWords) { if (separatedInputWords.Length > 1) { DialogueNPC npc = controller.dialogueController.tryTalkingTo(separatedInputWords); if (npc == null) { controller.LogStringWithReturn("No existe '" + separatedInputWords[separatedInputWords.Length - 1] + "' con quien hablar."); return; } controller.dialogueController.StartCoroutine("talk"); string tempNarrationText = ""; if (controller.dialogueController.currentDialogue.narrator == Dialogue.NarratorType.character) { string code = ColorUtility.ToHtmlStringRGB(controller.dialogueController.currentNpc.color); tempNarrationText = "<b><color=#" + code + ">" + controller.dialogueController.currentNpc.npcName + ":</color></b> "; } controller.LogStringWithReturn(tempNarrationText + npc.dialogueTree.getText() + controller.dialogueController.getChoicesText() + controller.dialogueController.endText); //controller.dialogueController.input = separatedInputWords[0]; } }
public void ShowBox(DialogueNPC dialogueNPC) { if (dialogueNPC.rdmText) { dialogueActive = true; dialogueBox.SetActive(true); int rdm = Random.Range(0, dialogueNPC.dialoguesList.Length); dialogueText.text = dialogueNPC.dialoguesList[rdm]; } }
public DialogueNPC tryTalkingTo(string[] keywords) { npcsInRoom = roomNav.currentRoom.charactersInRoom; string temp = keywords[keywords.Length - 1]; if (keywords.Length == 2) { foreach (DialogueNPC npc in npcsInRoom) { foreach (string k in npc.keywords) { if (keywords[1] == k) { currentNpc = npc; setDialogue(); controller.questManager.updateQuests(); return(currentNpc); } } } } for (int i = keywords.Length - 2; i > 0; i--) { temp = keywords[i] + " " + temp; foreach (DialogueNPC npc in npcsInRoom) { foreach (string k in npc.keywords) { if (keywords[keywords.Length - 1] == k) { currentNpc = npc; setDialogue(); controller.questManager.updateQuests(); return(currentNpc); } else { if (k == temp) { currentNpc = npc; setDialogue(); controller.questManager.updateQuests(); return(currentNpc); } } } } } return(null); }
public void StartDialogue(Dialogue dialogueEvent, DialogueNPC dialogueNPC) { if (dialogueEvent == null) { return; } npcThatIsBeingTalkedTo = dialogueNPC; dialogueContainer.gameObject.SetActive(true); GameOverseer.Instance.playerCharacterStats.playerController.enabled = false; dialogueSentenceQueue = dialogueEvent.GetDialogueSentences(); StartNextDialogueSentence(); }
// Start the conversation public void StartDialogue(DialogueNPC npc) { activeNPCDialogue = npc; if (activeNPCDialogue.activeDialogueState) { dialogueScreen.SetActive(true); linesContainer.ResetPointer(); closingDialogue = false; activeNPCDialogue.activeDialogueState = activeNPCDialogue.activeNPCState.defaultDialogueState; npcLineContainer.text = ""; if (activeNPCDialogue.activeNPCState.portrait != null) { npcPortrait.sprite = activeNPCDialogue.activeNPCState.portrait; } else { if (activeNPCDialogue.DefaltNPCPortrait != null) { npcPortrait.sprite = activeNPCDialogue.DefaltNPCPortrait; } else { npcPortrait.sprite = defaultEmptyPortrait; } } NPCSpeak(new string[] { activeNPCDialogue.activeNPCState.defaultDialogueState.greeting }); if (!activeNPCDialogue.activeDialogueState.blankState) { RefreshActiveLines(); lockedOptions = false; //activeLines.Add(activeNPCDialogue.activeDialogueState.endDialogueLine); linesContainer.FillConteiners(activeLines); StartCoroutine(ShowResponses()); } else { foreach (Button button in linesContainer.uITextContainers) { button.interactable = false; button.GetComponentInChildren <Text>().enabled = false; } StartCoroutine(EndConversation(1f)); } } }