]> git.lizzy.rs Git - SuperMouseAdventure.git/commitdiff
Checkpoint-Soundeffekt
authorKG0104 <konstantin.gerlach@kabelmail.de>
Fri, 13 Aug 2021 13:07:06 +0000 (15:07 +0200)
committerKG0104 <konstantin.gerlach@kabelmail.de>
Fri, 13 Aug 2021 13:07:06 +0000 (15:07 +0200)
2DGame/Assets/Audio/SFX/checkpoint.wav [new file with mode: 0644]
2DGame/Assets/Audio/SFX/checkpoint.wav.meta [new file with mode: 0644]
2DGame/Assets/Scenes/Green_Idyll/green_idyll_1.unity
2DGame/Assets/Scripts/Maus/Checkpoint.cs
2DGame/Assets/Scripts/Maus/CheckpointManager.cs
2DGame/Assets/Scripts/Maus/CheeseCoin.cs
2DGame/Assets/Scripts/Saving/PlayerData.cs
2DGame/Assets/Scripts/Saving/SaveSystem.cs

diff --git a/2DGame/Assets/Audio/SFX/checkpoint.wav b/2DGame/Assets/Audio/SFX/checkpoint.wav
new file mode 100644 (file)
index 0000000..bec5306
Binary files /dev/null and b/2DGame/Assets/Audio/SFX/checkpoint.wav differ
diff --git a/2DGame/Assets/Audio/SFX/checkpoint.wav.meta b/2DGame/Assets/Audio/SFX/checkpoint.wav.meta
new file mode 100644 (file)
index 0000000..0919836
--- /dev/null
@@ -0,0 +1,22 @@
+fileFormatVersion: 2
+guid: 8aec8274cc2da4671a712185e5f84971
+AudioImporter:
+  externalObjects: {}
+  serializedVersion: 6
+  defaultSettings:
+    loadType: 0
+    sampleRateSetting: 0
+    sampleRateOverride: 44100
+    compressionFormat: 1
+    quality: 1
+    conversionMode: 0
+  platformSettingOverrides: {}
+  forceToMono: 0
+  normalize: 1
+  preloadAudioData: 1
+  loadInBackground: 0
+  ambisonic: 0
+  3D: 1
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
index f62121488c2f5b54dedc3de45bee4947c8877b28..02122e91a155b930784a18b4c970b081a2192b9f 100644 (file)
@@ -2663,6 +2663,11 @@ MonoBehaviour:
     volume: 1
     pitch: 1
     source: {fileID: 0}
+  - name: checkpoint
+    clip: {fileID: 8300000, guid: 8aec8274cc2da4671a712185e5f84971, type: 3}
+    volume: 0.2
+    pitch: 1
+    source: {fileID: 0}
 --- !u!4 &292106544
 Transform:
   m_ObjectHideFlags: 0
index 5814fe95ca8b90908237113fa3d9ded4a488db7c..c41d5b952c713721de12218a708e0a9ffaef1968 100644 (file)
@@ -6,23 +6,30 @@ public class Checkpoint : MonoBehaviour
 {
     private CheckpointManager cm;
     private Cheese cheese;
+    private CheeseCoin cheeseCoin;
 
-    public Sprite red;
     public Sprite green;
 
     void Start()
     {
         cm = GameObject.FindGameObjectWithTag("CheckpointManager").GetComponent<CheckpointManager>();
         cheese = GameObject.FindGameObjectWithTag("Player").GetComponent<Cheese>();
+        cheeseCoin = GameObject.FindGameObjectWithTag("Player").GetComponent<CheeseCoin>();
     }
 
     void OnTriggerEnter2D(Collider2D collision)
     {
-        if(collision.CompareTag("Player"))
+        if (collision.CompareTag("Player"))
         {
             cm.lastCheckpointPos = transform.position;
             cm.lastCheeseCount = cheese.cheesecount;
-            GetComponent<SpriteRenderer>().sprite = green;
+            cm.isCheeseCoinCollected = cheeseCoin.cheeseCoinCollected;
+
+            if (GetComponent<SpriteRenderer>().sprite != green)
+            {
+                FindObjectOfType<AudioManager>().Play("checkpoint");
+                GetComponent<SpriteRenderer>().sprite = green;
+            }
         }
     }
 }
index afb7c2fc8bdebf6150d1be92345271181ed11262..95b5333dafb6426db9d1ece23094b279d0e6813e 100644 (file)
@@ -5,11 +5,20 @@ using UnityEngine;
 public class CheckpointManager : MonoBehaviour
 {
     private static CheckpointManager instance;
+
     public Vector3 lastCheckpointPos;
-    public Cheese cheese;
-    public int lastCheeseCount;
+
+    Cheese cheese;
+
+    CheeseCoin cheeseCoin;
+
     public Transform mouse;
 
+    public int lastCheeseCount;
+
+    public bool isCheeseCoinCollected;
+
+
     void Awake()
     {
         if (instance == null)
@@ -27,7 +36,7 @@ public class CheckpointManager : MonoBehaviour
 
     public void SavePlayer ()
     {
-        SaveSystem.SavePlayer(instance, cheese);
+        SaveSystem.SavePlayer(instance, cheese, cheeseCoin);
     }
 
     public void LoadPlayer()
@@ -35,6 +44,7 @@ public class CheckpointManager : MonoBehaviour
         PlayerData data = SaveSystem.LoadPlayer();
 
         cheese.cheesecount = data.collectedCheese;
+        cheeseCoin.cheeseCoinCollected = data.isCheeseCoinCollected;
 
         Vector3 position;
         position.x = data.position[0];
index f64c987295e7cb5920f05e2957e0e8f2a57bd19f..e2f25422a9c5e65b4926f9db7eec307d92728b10 100644 (file)
@@ -5,7 +5,7 @@ using UnityEngine.UI;
 
 public class CheeseCoin : MonoBehaviour
 {
-    private bool cheeseCoinCollected;
+    public bool cheeseCoinCollected;
 
     public GameObject cheeseCoin;
      
@@ -22,7 +22,6 @@ public class CheeseCoin : MonoBehaviour
         }
         else
         {
-            //gibt eine NullReferenceException aus
             cheeseCoinImage.sprite = missingCheeseCoin;
         }
 
index 9c742bba3f0bc0e94bb9bd66bc38dd71e05c54f4..3cc7aa2bd9a77dfc8650e92635f270fc0e98c7ec 100644 (file)
@@ -6,10 +6,12 @@ public class PlayerData
 {
     public float [] position;
     public int collectedCheese;
+    public bool isCheeseCoinCollected;
 
-    public PlayerData (CheckpointManager cm, Cheese cheese)
+    public PlayerData (CheckpointManager cm, Cheese cheese, CheeseCoin cheeseCoin)
     {
         collectedCheese = cheese.cheesecount;
+        isCheeseCoinCollected = cheeseCoin.cheeseCoinCollected;
         position = new float[3];
         position[0] = cm.lastCheckpointPos.x;
         position[1] = cm.lastCheckpointPos.y;
index 7bfe50a55cb7599a70393e4a38808756931eb207..0e1711b96fc0203f5da7949254075347aafedbaf 100644 (file)
@@ -4,13 +4,13 @@ using System.Runtime.Serialization.Formatters.Binary;
 
 public static class SaveSystem
 {
-    public static void SavePlayer (CheckpointManager cm, Cheese cheese)
+    public static void SavePlayer (CheckpointManager cm, Cheese cheese, CheeseCoin cheeseCoin)
     {
         BinaryFormatter formatter = new BinaryFormatter();
         string path = Application.persistentDataPath + "/data.lol";
         FileStream stream = new FileStream(path, FileMode.Create);
 
-        PlayerData data = new PlayerData(cm, cheese);
+        PlayerData data = new PlayerData(cm, cheese, cheeseCoin);
 
         formatter.Serialize(stream, data);
         stream.Close();