private void DialogueNodeRead() { GameObject textbox = Resources.Load <GameObject>("TextBox"); Character findCharacter = GameDataTracker.findCharacterByName(speakerName, GameDataTracker.CharacterList); if (GameDataTracker.combatExecutor != null) { GameDataTracker.combatExecutor.FocusOnCharacter(findCharacter.CharacterObject); } FriendlyNPCClass friendlyNPC = findCharacter.CharacterObject.GetComponent <FriendlyNPCClass>(); if (friendlyNPC != null) { letter_noises = friendlyNPC.ObjectInfo.LetterNoises; letters_per_noise_list = friendlyNPC.ObjectInfo.LetterNoisesPerList; } else { letter_noises = null; letters_per_noise_list = null; } Transform target; float dialogueHeight; target = findCharacter.CharacterObject.transform; dialogueHeight = findCharacter.ObjectInfo.GetDialogueHeightOverSpeaker(); spawnedTextBox = Instantiate <GameObject>(textbox, new Vector3(target.position.x, target.position.y + dialogueHeight, target.position.z + 0.2f), Quaternion.identity); TextBoxController tbController = spawnedTextBox.GetComponent <TextBoxController>(); tbController.textfile = inputText; tbController.choices = currentLinks; tbController.speakerName = speakerName; tbController.scriptSource = deconstructerSource; tbController.letter_noises = letter_noises; tbController.letters_per_noise_list = letters_per_noise_list; }
//------------------------------------------------------------------------------------------------------------------------------------------- public void Update() { //Pause and unpause game. ================ if (controls.OverworldControls.Inventory.triggered && (GameDataTracker.cutsceneMode == GameDataTracker.cutsceneModeOptions.Mobile)) { ChangePauseState(); } if (GameDataTracker.pauseActive) { Time.timeScale = 0.0f; } else { Time.timeScale = 1.0f; } //========================================= //Check if any dialogue is available. if (GameDataTracker.cutsceneMode == GameDataTracker.cutsceneModeOptions.Mobile) { float horizontal = controls.OverworldControls.SecondaryMovement.ReadValue <Vector2>()[0]; CameraHeading += horizontal * Time.deltaTime * 90f; if (CameraHeading < 0) { CameraHeading += 360f; } if (CameraHeading > 360) { CameraHeading -= 360f; } float closestCharacterDistance = 100; GameObject closestCharacter = null; foreach (Character CharacterItem in GameDataTracker.CharacterList) { FriendlyNPCClass npcClass = CharacterItem.CharacterObject.GetComponent <FriendlyNPCClass>(); if (npcClass != null) { float distanceToPlayer = npcClass.distanceToPlayer; if (distanceToPlayer < closestCharacterDistance) { closestCharacterDistance = distanceToPlayer; closestCharacter = CharacterItem.CharacterObject; } } } foreach (Character CharacterItem in GameDataTracker.CharacterList) { FriendlyNPCClass npcClass = CharacterItem.CharacterObject.GetComponent <FriendlyNPCClass>(); if (npcClass != null) { npcClass.readyForDialogue = false; } } if (closestCharacterDistance < 1) { closestCharacter.GetComponent <FriendlyNPCClass>().readyForDialogue = true; GameDataTracker.dialogueReady = true; } else { GameDataTracker.dialogueReady = false; } } else { GameDataTracker.dialogueReady = false; } }