diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 928ed85d1..343744bd2 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -5729,6 +5729,11 @@ PrefabInstance: value: objectReference: {fileID: 1044089125355486785, guid: 27e93d4332ff7584bb2c96969c6c0315, type: 3} + - target: {fileID: 114424659341706264, guid: ec3b4ef72d802d7448ea4d550f88fc47, + type: 3} + propertyPath: player + value: + objectReference: {fileID: 1878101311} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: ec3b4ef72d802d7448ea4d550f88fc47, type: 3} --- !u!1 &618609699 @@ -6910,8 +6915,6 @@ MonoBehaviour: obj: {fileID: 11400000, guid: c8801550469a3d143ad093fc12424db6, type: 2} - ID: bunker_vending_blueprint obj: {fileID: 11400000, guid: 8a416ef974a215c4197b5a269040a75b, type: 2} - - ID: demo_enemy_shellcore - obj: {fileID: 11400000, guid: 8b9cce9b8a5c1d545b7eb9b9bd135b26, type: 2} - ID: clip_respawn obj: {fileID: 8300000, guid: fcdc02c551db0b94d898de488f45a1fa, type: 3} - ID: 4 Entry diff --git a/Assets/Scripts/Functional Definitions/Interaction Definitions/DialogueSystem.cs b/Assets/Scripts/Functional Definitions/Interaction Definitions/DialogueSystem.cs index bfc36373e..0e5990012 100644 --- a/Assets/Scripts/Functional Definitions/Interaction Definitions/DialogueSystem.cs +++ b/Assets/Scripts/Functional Definitions/Interaction Definitions/DialogueSystem.cs @@ -28,7 +28,7 @@ public class DialogueSystem : MonoBehaviour float nextCharacterTime; public double timeBetweenCharacters = 0.0175d; string text = ""; - Transform playerTransform; + public PlayerCore player; Vector3? speakerPos; public CoreUpgraderScript upgraderScript; private void Awake() @@ -38,7 +38,7 @@ private void Awake() private void Update() { - if(window && speakerPos != null && playerTransform && (playerTransform.position - ((Vector3)speakerPos)).sqrMagnitude > 100) + if(window && speakerPos != null && player && (player.transform.position - ((Vector3)speakerPos)).sqrMagnitude > 100) endDialogue(); // Add text if(textRenderer && characterCount < text.Length) @@ -52,9 +52,9 @@ private void Update() } } - public static void StartDialogue(Dialogue dialogue, Entity speaker = null, PlayerCore player = null) + public static void StartDialogue(Dialogue dialogue, Entity speaker = null) { - Instance.startDialogue(dialogue, speaker, player); + Instance.startDialogue(dialogue, speaker); } public static void ShowPopup(string text, Color color, Entity speaker = null) @@ -73,13 +73,17 @@ private void showPopup(string text, Color color, Entity speaker = null) if (window && window.GetActive()) return; if(window) endDialogue(); - playerTransform = null; //create window + speakerPos = null; if(!speaker) window = Instantiate(popupBoxPrefab).GetComponentInChildren(); else + { window = Instantiate(dialogueBoxPrefab).GetComponentInChildren(); + speakerPos = speaker.transform.position; + } + window.Activate(); window.transform.SetSiblingIndex(0); background = window.transform.Find("Background").GetComponent(); @@ -141,15 +145,14 @@ private void showBattleResults(bool victory) { else window.transform.Find("Defeat").gameObject.SetActive(true); } - public static void ShowDialogueNode(NodeEditorFramework.Standard.DialogueNode node, Entity speaker = null, PlayerCore player = null) + public static void ShowDialogueNode(NodeEditorFramework.Standard.DialogueNode node, Entity speaker = null) { - Instance.showDialogueNode(node, speaker, player); + Instance.showDialogueNode(node, speaker); } - private void showDialogueNode(NodeEditorFramework.Standard.DialogueNode node, Entity speaker, PlayerCore player) + private void showDialogueNode(NodeEditorFramework.Standard.DialogueNode node, Entity speaker) { if (window) endDialogue(0); - playerTransform = player ? player.transform : null; //speakerPos = speaker.transform.position; //create window window = Instantiate(dialogueBoxPrefab).GetComponentInChildren(); @@ -200,15 +203,14 @@ private void showDialogueNode(NodeEditorFramework.Standard.DialogueNode node, En } } - public static void ShowTaskPrompt(NodeEditorFramework.Standard.StartTaskNode node, Entity speaker = null, PlayerCore player = null) + public static void ShowTaskPrompt(NodeEditorFramework.Standard.StartTaskNode node, Entity speaker = null) { - Instance.showTaskPrompt(node, speaker, player); + Instance.showTaskPrompt(node, speaker); } - private void showTaskPrompt(NodeEditorFramework.Standard.StartTaskNode node, Entity speaker, PlayerCore player) //TODO: reward part image + private void showTaskPrompt(NodeEditorFramework.Standard.StartTaskNode node, Entity speaker) //TODO: reward part image { if (window) endDialogue(0, false); - playerTransform = player ? player.transform : null; //speakerPos = speaker.transform.position; //create window window = Instantiate(taskDialogueBoxPrefab).GetComponentInChildren(); @@ -230,6 +232,9 @@ private void showTaskPrompt(NodeEditorFramework.Standard.StartTaskNode node, Ent nextCharacterTime = (float)(Time.time + timeBetweenCharacters); textRenderer.color = node.dialogueColor; + // update speakerPos + if(speaker) speakerPos = speaker.transform.position; + // Objective list var objectiveList = background.transform.Find("ObjectiveList").GetComponent(); objectiveList.text = node.objectiveList; @@ -310,10 +315,9 @@ private void showTaskPrompt(NodeEditorFramework.Standard.StartTaskNode node, Ent } } - private void startDialogue(Dialogue dialogue, Entity speaker, PlayerCore player) + private void startDialogue(Dialogue dialogue, Entity speaker) { if(window) endDialogue(); - playerTransform = player ? player.transform : null; speakerPos = speaker.transform.position; //create window window = Instantiate(dialogueBoxPrefab).GetComponentInChildren(); @@ -324,15 +328,15 @@ private void startDialogue(Dialogue dialogue, Entity speaker, PlayerCore player) textRenderer = background.transform.Find("Text").GetComponent(); textRenderer.font = shellcorefont; - next(dialogue, 0, speaker, player); + next(dialogue, 0, speaker); } - public static void Next(Dialogue dialogue, int ID, Entity speaker, PlayerCore player) + public static void Next(Dialogue dialogue, int ID, Entity speaker) { - Instance.next(dialogue, ID, speaker, player); + Instance.next(dialogue, ID, speaker); } - public void next(Dialogue dialogue, int ID, Entity speaker, PlayerCore player) + public void next(Dialogue dialogue, int ID, Entity speaker) { if(dialogue.nodes.Count == 0) { @@ -430,7 +434,7 @@ public void next(Dialogue dialogue, int ID, Entity speaker, PlayerCore player) button.SetParent(background, false); button.anchoredPosition = new Vector2(0, 24 + 16 * (current.nextNodes.Count - (i + 1))); button.GetComponent