From 439215614b562dbcdceeeaea658dd5d13f9ec187 Mon Sep 17 00:00:00 2001 From: "FRANKWALTERSTEI\\bib" Date: Fri, 26 Sep 2025 08:32:47 +0200 Subject: [PATCH] Neues Script --- .../Assets/Scenes/GameScene.unity | 57 +++++-- .../Assets/Scripts/ManageDialogue.cs | 116 ++++++++++++++ .../Assets/Scripts/ManageDialogue.cs.meta | 2 + .../Assets/Scripts/PutInPlace.cs | 148 +++++++++++++++++- .../Assets/Scripts/TriggerDialoque.cs | 41 +++++ .../Assets/Scripts/TriggerDialoque.cs.meta | 2 + 6 files changed, 353 insertions(+), 13 deletions(-) create mode 100644 UnnamedFishProject/Assets/Scripts/ManageDialogue.cs create mode 100644 UnnamedFishProject/Assets/Scripts/ManageDialogue.cs.meta create mode 100644 UnnamedFishProject/Assets/Scripts/TriggerDialoque.cs create mode 100644 UnnamedFishProject/Assets/Scripts/TriggerDialoque.cs.meta diff --git a/UnnamedFishProject/Assets/Scenes/GameScene.unity b/UnnamedFishProject/Assets/Scenes/GameScene.unity index f60e088..aef7b41 100644 --- a/UnnamedFishProject/Assets/Scenes/GameScene.unity +++ b/UnnamedFishProject/Assets/Scenes/GameScene.unity @@ -239,6 +239,7 @@ GameObject: - component: {fileID: 330585545} - component: {fileID: 330585544} - component: {fileID: 330585547} + - component: {fileID: 330585548} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -364,6 +365,28 @@ MonoBehaviour: m_MipBias: 0 m_VarianceClampScale: 0.9 m_ContrastAdaptiveSharpening: 0 +--- !u!114 &330585548 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 330585543} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c9abe543b11ffd848a05bfacb99512fb, type: 3} + m_Name: + m_EditorClassIdentifier: + unterschrank: {fileID: 1226968860} + aquarium: {fileID: 827936917} + elektronik: {fileID: 1048975205} + duengerFlaschen: {fileID: 1518591050} + testFlaschen: {fileID: 2130494277} + fischfutter: {fileID: 809139278} + fisch1: {fileID: 0} + fisch2: {fileID: 0} + pflanzen: {fileID: 0} + weiter: 275 --- !u!1 &410087039 GameObject: m_ObjectHideFlags: 0 @@ -983,6 +1006,9 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: -8679921383154817045, guid: 52b92fdb14f33884baf4a43477cb083c, type: 3} insertIndex: -1 addedObject: {fileID: 1992194362} + - targetCorrespondingSourceObject: {fileID: -8679921383154817045, guid: 52b92fdb14f33884baf4a43477cb083c, type: 3} + insertIndex: -1 + addedObject: {fileID: 1653188870} m_AddedComponents: - targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: 52b92fdb14f33884baf4a43477cb083c, type: 3} insertIndex: -1 @@ -1964,6 +1990,11 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 10ce1ce4c10044246ba2702ecd59f38a, type: 3} +--- !u!1 &1226968860 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: 10ce1ce4c10044246ba2702ecd59f38a, type: 3} + m_PrefabInstance: {fileID: 1226968859} + m_PrefabAsset: {fileID: 0} --- !u!1 &1255467087 GameObject: m_ObjectHideFlags: 0 @@ -2455,31 +2486,31 @@ PrefabInstance: serializedVersion: 2 m_Modification: serializedVersion: 3 - m_TransformParent: {fileID: 0} + m_TransformParent: {fileID: 827936919} m_Modifications: - target: {fileID: -8679921383154817045, guid: f61bcc9191e790e4fa28c1c289eca462, type: 3} propertyPath: m_LocalScale.x - value: 90 + value: 1.6363641 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: f61bcc9191e790e4fa28c1c289eca462, type: 3} propertyPath: m_LocalScale.y - value: 183.95 + value: 5.5733128 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: f61bcc9191e790e4fa28c1c289eca462, type: 3} propertyPath: m_LocalScale.z - value: 90 + value: 3.2727268 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: f61bcc9191e790e4fa28c1c289eca462, type: 3} propertyPath: m_LocalPosition.x - value: -2.018 + value: -0.000018180499 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: f61bcc9191e790e4fa28c1c289eca462, type: 3} propertyPath: m_LocalPosition.y - value: 0.92 + value: 0.002457164 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: f61bcc9191e790e4fa28c1c289eca462, type: 3} propertyPath: m_LocalPosition.z - value: -2.21 + value: 0.022581821 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: f61bcc9191e790e4fa28c1c289eca462, type: 3} propertyPath: m_LocalRotation.w @@ -2487,15 +2518,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: f61bcc9191e790e4fa28c1c289eca462, type: 3} propertyPath: m_LocalRotation.x - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: f61bcc9191e790e4fa28c1c289eca462, type: 3} propertyPath: m_LocalRotation.y - value: 0.7071068 + value: -0 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: f61bcc9191e790e4fa28c1c289eca462, type: 3} propertyPath: m_LocalRotation.z - value: 0.7071068 + value: 1 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: f61bcc9191e790e4fa28c1c289eca462, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -2526,6 +2557,11 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: f61bcc9191e790e4fa28c1c289eca462, type: 3} +--- !u!4 &1653188870 stripped +Transform: + m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: f61bcc9191e790e4fa28c1c289eca462, type: 3} + m_PrefabInstance: {fileID: 1653188869} + m_PrefabAsset: {fileID: 0} --- !u!1001 &1677791534 PrefabInstance: m_ObjectHideFlags: 0 @@ -3245,5 +3281,4 @@ SceneRoots: - {fileID: 1518591051} - {fileID: 809139279} - {fileID: 626182426} - - {fileID: 1653188869} - {fileID: 1048975206} diff --git a/UnnamedFishProject/Assets/Scripts/ManageDialogue.cs b/UnnamedFishProject/Assets/Scripts/ManageDialogue.cs new file mode 100644 index 0000000..aa57769 --- /dev/null +++ b/UnnamedFishProject/Assets/Scripts/ManageDialogue.cs @@ -0,0 +1,116 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine.UI; +using UnityEngine; +using TMPro; +using Unity.VisualScripting; +using UnityEngine.SceneManagement; + +public class ManageDialogue : MonoBehaviour +{ + public static ManageDialogue Instance; + + public KeyCode continueKey = KeyCode.Space; + + public Canvas canvas; + + public Image characterIcon; + public TextMeshProUGUI characterName; + public TextMeshPro characterDerscription; + public TextMeshProUGUI dialogueArea; + + private Queue lines; + + public bool isDialogueActive = false; + + public float typingSpeed = 0.2f; + + public Animator animator; + + public bool finishedAll = false; + + + void Start() + { + canvas = GetComponent(); + canvas.enabled = false; + + } + + private void Awake() + { + + if (Instance == null) + Instance = this; + + lines = new Queue(); + } + + public void StartDialogue(Dialogue dialogue) + { + isDialogueActive = true; + + animator.Play("show"); + + lines.Clear(); + + foreach (DialogueLine dialogueLine in dialogue.dialogueLines) + { + lines.Enqueue(dialogueLine); + } + + DisplayNextDialogueLine(); + } + + public void DisplayNextDialogueLine() + { + if (lines.Count == 0) + { + EndDialogue(); + return; + } + + DialogueLine currentLine = lines.Dequeue(); + + characterIcon.sprite = currentLine.character.icon; + characterName.text = currentLine.character.name; + + StopAllCoroutines(); + + StartCoroutine(TypeSentence(currentLine)); + } + + IEnumerator TypeSentence(DialogueLine dialogueLine) + { + dialogueArea.text = ""; + foreach (char letter in dialogueLine.line.ToCharArray()) + { + dialogueArea.text += letter; + yield return new WaitForSeconds(typingSpeed); + } + } + + void EndDialogue() + { + + finishedAll = true; + isDialogueActive = false; + animator.Play("hide"); + + SceneManager.LoadSceneAsync(2); + } + + private void Update() + { + if (Input.GetKeyDown(continueKey)) + { + DisplayNextDialogueLine(); + } + + if (finishedAll == true) + { + canvas.enabled = !canvas.enabled; + } + + } +} \ No newline at end of file diff --git a/UnnamedFishProject/Assets/Scripts/ManageDialogue.cs.meta b/UnnamedFishProject/Assets/Scripts/ManageDialogue.cs.meta new file mode 100644 index 0000000..6fc73da --- /dev/null +++ b/UnnamedFishProject/Assets/Scripts/ManageDialogue.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 549a31f164332f64e9a9024efb126d6b \ No newline at end of file diff --git a/UnnamedFishProject/Assets/Scripts/PutInPlace.cs b/UnnamedFishProject/Assets/Scripts/PutInPlace.cs index f8cef7c..e6a7247 100644 --- a/UnnamedFishProject/Assets/Scripts/PutInPlace.cs +++ b/UnnamedFishProject/Assets/Scripts/PutInPlace.cs @@ -1,16 +1,160 @@ +using System.Numerics; using UnityEngine; public class PutInPlace : MonoBehaviour { + + public GameObject unterschrank; + public GameObject aquarium; + public GameObject elektronik; + public GameObject duengerFlaschen; + public GameObject testFlaschen; + public GameObject fischfutter; + public GameObject fisch1; + public GameObject fisch2; + public GameObject pflanzen; + + bool moveSchrankDone = false; + bool moveBeckenDone = false; + bool moveElektroDone = false; + bool moveDuengerDone = false; + bool moveTestsDone = false; + bool moveFutterDone = false; + bool movePlantDone = false; + bool moveFisch1Done = false; + bool moveFisch2Done = false; + + + [SerializeField] KeyCode weiter; + // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { - + unterschrank.SetActive(false); + aquarium.SetActive(false); + elektronik.SetActive(false); + duengerFlaschen.SetActive(false); + testFlaschen.SetActive(false); + fischfutter.SetActive(false); + pflanzen.SetActive(false); + fisch1.SetActive(false); + fisch2.SetActive(false); + } // Update is called once per frame void Update() { - + if (Input.GetKey(weiter)) + { + if (moveSchrankDone == false) + { + MoveSchrank(); + } + + if (moveSchrankDone == true && moveBeckenDone == false) + { + MoveBecken(); + } + + if (moveBeckenDone == true && moveElektroDone == false) + { + MoveElektro(); + } + + if(moveElektroDone == true && moveDuengerDone == false) + { + MoveDuenger(); + } + + if(moveElektroDone == true && moveTestsDone == false) + { + MoveTests(); + } + + if(moveTestsDone == true && moveFutterDone == false) + { + MoveFutter(); + } + + if(moveFutterDone == true && movePlantDone == false) + { + MovePlant(); + } + + if(movePlantDone == true && moveFisch1Done == false) + { + MoveFisch1(); + } + + if(moveFisch1Done == true && moveFisch2Done == false) + { + MoveFisch2(); + } + } + } + + public void MoveSchrank() + { + //unterschrank.transform.position += new Vector3(-2.015, 0.188, -2.1306); + unterschrank.SetActive(true); + + moveSchrankDone = true; + } + + public void MoveBecken() + { + aquarium.SetActive(true); + + moveBeckenDone = true; + } + + public void MoveElektro() + { + elektronik.SetActive(true); + + moveElektroDone = true; + } + + public void MoveDuenger() + { + duengerFlaschen.SetActive(true); + + moveDuengerDone = true; + } + + public void MoveTests() + { + testFlaschen.SetActive(true); + + moveTestsDone = true; + } + + public void MoveFutter() + { + fischfutter.SetActive(true); + + moveFutterDone = true; + } + + public void MovePlant() + { + pflanzen.SetActive(true); + + movePlantDone = true; + } + + public void MoveFisch1() + { + fisch1.SetActive(true); + + moveFisch1Done = true; + } + + public void MoveFisch2() + { + fisch2.SetActive(true); + + moveFisch2Done = true; } } diff --git a/UnnamedFishProject/Assets/Scripts/TriggerDialoque.cs b/UnnamedFishProject/Assets/Scripts/TriggerDialoque.cs new file mode 100644 index 0000000..2b43237 --- /dev/null +++ b/UnnamedFishProject/Assets/Scripts/TriggerDialoque.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; +using UnityEngine; + +[System.Serializable] +public class DialogueCharacter +{ + public string name; + public Sprite icon; +} + +[System.Serializable] +public class DialogueLine +{ + public DialogueCharacter character; + [TextArea(3, 10)] + public string line; +} + +[System.Serializable] +public class Dialogue +{ + public List dialogueLines = new List(); +} + +public class TriggerDialogue : MonoBehaviour +{ + public Dialogue dialogue; + + public void TriggerTheDialogue() + { + ManageDialogue.Instance.StartDialogue(dialogue); + } + + private void OnTriggerEnter2D(Collider2D collision) + { + if (collision.tag == "Player") + { + TriggerTheDialogue(); + } + } +} \ No newline at end of file diff --git a/UnnamedFishProject/Assets/Scripts/TriggerDialoque.cs.meta b/UnnamedFishProject/Assets/Scripts/TriggerDialoque.cs.meta new file mode 100644 index 0000000..ca27914 --- /dev/null +++ b/UnnamedFishProject/Assets/Scripts/TriggerDialoque.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 4dad8af36b57ad04daa28033935f85bf \ No newline at end of file