// Update is called once per frame void Update() { if (objectType == 1) { if (pnjScript.GetItemTrigger() == true) { functions.AddItem(idElement, quantity); pnjScript.SetItemTrigger(false); pnjScript.SetItemGiven(true); } } else { //Si l'objet est visible if (this.GetComponent <MeshRenderer>().enabled == true) { playerPosition = GameObject.Find("Tempus").transform.position; distanceItemPlayer = functions.DistanceBetween(playerPosition, itemPosition); //Si le joueur est proche de l'objet if (distanceItemPlayer.x < hitBoxDistance && distanceItemPlayer.y < hitBoxDistance && distanceItemPlayer.z < hitBoxDistance) { playerDetected = true; this.transform.GetChild(0).GetComponent <MeshRenderer>().enabled = true; if (Input.GetKeyDown(KeyCode.Return) || mouseTrigger == true) { mouseTrigger = false; //Le Mesh renderer de l’objet 3d est désactivé this.GetComponent <MeshRenderer>().enabled = false; this.transform.GetChild(0).GetComponent <MeshRenderer>().enabled = false; //On ajoute l'objet à l'invenaire du joueur et on le lui signal dans la fen^tre de dialogue centrale functions.AddItem(idElement, quantity); functions.SetCentralWindow(true, "Received " + quantity + " " + linkedItem.GetComponent <ItemOld>().GetName()); functions.SetDialogueMode(true); } } else { this.transform.GetChild(0).GetComponent <MeshRenderer>().enabled = false; } } //Si le mode dialogue est activé ici, cela signifie que le joueur vient de recevoir un objet et le jeu attend simplement que le joueur ferme la fenêtre centrale else if (functions.GetDialogueMode() == true) { if (Input.GetKeyDown(KeyCode.Return) || Input.GetMouseButtonDown(0) == true) { functions.SetCentralWindow(false); functions.SetDialogueMode(false); } } } }
// Update is called once per frame void Update() { if (functions.GetPauseMode() == false) { pnjPosition = this.transform.position; playerPosition = GameObject.Find("Tempus").transform.position; distancePnjPlayer = functions.DistanceBetween(playerPosition, pnjPosition); //Si le joueur est proche du PNJ if (distancePnjPlayer.x < hitBoxDistance && distancePnjPlayer.y < hitBoxDistance && distancePnjPlayer.z < hitBoxDistance) { if (sendDetection == true) { functions.playerDetection(this.name); sendDetection = false; } if (functions.CheckIfNearest(this.name) == true) { this.transform.GetChild(0).GetComponent <MeshRenderer>().enabled = true; //Debug.Log(functions.GetDialogueMode()); if (Input.GetKeyDown(KeyCode.Return) || mouseTrigger == true) { activateDialogue = true; } else if (functions.GetDialogueMode() == true && Input.GetMouseButtonDown(0) == true) { activateDialogue = true; } if (activateDialogue == true && itemTrigger == false) { activateDialogue = false; mouseTrigger = false; //Debug.Log(functions.GetFrame()); if (functions.GetDialogueMode() == false) { functions.SetDialogueMode(true); } if (characterType == 1) //Si le type de ce personnage est 1, le personnage dit entre 1 et plusieurs phrases puis donne quelque chose au héro et enfin dit entre 1 et plusieurs phrases pour conclure la conversation { if (eventTriggered == false) { if (dialogProgression < partitions[0] + partitions[1]) { if (dialogProgression < partitions[0]) //Le PNJ dit quelque chose { if (faceId == 0) { screenManager.GetComponent <ScreenManager>().SetActiveDialogue(2); noFaceWindow.gameObject.SetActive(true); noFaceWindow.GetChild(0).GetComponent <Text>().text = this.name; noFaceWindow.GetChild(1).GetComponent <Text>().text = dialogList[dialogProgression]; } else { screenManager.GetComponent <ScreenManager>().SetActiveDialogue(1); faceWindow.gameObject.SetActive(true); faceWindow.GetChild(0).GetComponent <Text>().text = this.name; faceWindow.GetChild(1).GetComponent <Text>().text = dialogList[dialogProgression]; } dialogProgression++; } else //Le PNJ donne un objet { if (itemGiven == false) { itemTrigger = true; screenManager.GetComponent <ScreenManager>().SetActiveDialogue(0); } else //Le PNJ dit quelque chose { if (dialogProgression < partitions[0] + partitions[1]) { if (faceId == 0) { screenManager.GetComponent <ScreenManager>().SetActiveDialogue(2); noFaceWindow.GetChild(1).GetComponent <Text>().text = dialogList[dialogProgression]; } else { screenManager.GetComponent <ScreenManager>().SetActiveDialogue(1); faceWindow.GetChild(1).GetComponent <Text>().text = dialogList[dialogProgression]; } dialogProgression++; } } } } else //Fin de conversation { screenManager.GetComponent <ScreenManager>().SetActiveDialogue(0); if (faceId == 0) { noFaceWindow.GetChild(0).GetComponent <Text>().text = "Name"; noFaceWindow.GetChild(1).GetComponent <Text>().text = "Text"; } else { faceWindow.GetChild(0).GetComponent <Text>().text = "Name"; faceWindow.GetChild(1).GetComponent <Text>().text = "Text"; } functions.SetNoLoop(true); functions.SetDialogueMode(false); eventTriggered = true; } } else //Le PNJ dit quelque chose { if (dialogProgression < partitions[0] + partitions[1] + partitions[2]) { if (faceId == 0) { screenManager.GetComponent <ScreenManager>().SetActiveDialogue(2); noFaceWindow.gameObject.SetActive(true); noFaceWindow.GetChild(0).GetComponent <Text>().text = this.name; noFaceWindow.GetChild(1).GetComponent <Text>().text = dialogList[dialogProgression]; } else { screenManager.GetComponent <ScreenManager>().SetActiveDialogue(1); faceWindow.gameObject.SetActive(true); faceWindow.GetChild(0).GetComponent <Text>().text = this.name; faceWindow.GetChild(1).GetComponent <Text>().text = dialogList[dialogProgression]; } dialogProgression++; } else //Fin de conversation { screenManager.GetComponent <ScreenManager>().SetActiveDialogue(0); if (faceId == 0) { noFaceWindow.GetChild(0).GetComponent <Text>().text = "Name"; noFaceWindow.GetChild(1).GetComponent <Text>().text = "Text"; } else { faceWindow.GetChild(0).GetComponent <Text>().text = "Name"; faceWindow.GetChild(1).GetComponent <Text>().text = "Text"; } functions.SetNoLoop(true); functions.SetDialogueMode(false); dialogProgression = partitions[0] + partitions[1]; } } } else if (characterType == 2) //Si le type de ce personnage est 2, le personnage pose une question (en 1 ou plusieurs phrases) puis attend la réponse du joueur. Enfin, selon la réponse, il dit quelques phrases et ne fait plus rien. { } else //Si le type de ce personnage est 0 ou autre, le personnage dit entre 1 et plusieurs phrases puis ne fait plus rien { if (dialogProgression < partitions[0]) { if (faceId == 0) { screenManager.GetComponent <ScreenManager>().SetActiveDialogue(2); noFaceWindow.GetChild(0).GetComponent <Text>().text = this.name; noFaceWindow.GetChild(1).GetComponent <Text>().text = dialogList[dialogProgression]; } else { screenManager.GetComponent <ScreenManager>().SetActiveDialogue(1); faceWindow.GetChild(0).GetComponent <Text>().text = this.name; faceWindow.GetChild(1).GetComponent <Text>().text = dialogList[dialogProgression]; } dialogProgression++; } else //Fin de conversation { screenManager.GetComponent <ScreenManager>().SetActiveDialogue(0); if (faceId == 0) { noFaceWindow.GetChild(0).GetComponent <Text>().text = "Name"; noFaceWindow.GetChild(1).GetComponent <Text>().text = "Text"; } else { faceWindow.GetChild(0).GetComponent <Text>().text = "Name"; faceWindow.GetChild(1).GetComponent <Text>().text = "Text"; } functions.SetNoLoop(true); functions.SetDialogueMode(false); dialogProgression = 0; } } } } else { this.transform.GetChild(0).GetComponent <MeshRenderer>().enabled = false; } } else { this.transform.GetChild(0).GetComponent <MeshRenderer>().enabled = false; sendDetection = true; } } }