--- /dev/null
+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:
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
{
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;
+ }
}
}
}
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)
public void SavePlayer ()
{
- SaveSystem.SavePlayer(instance, cheese);
+ SaveSystem.SavePlayer(instance, cheese, cheeseCoin);
}
public void LoadPlayer()
PlayerData data = SaveSystem.LoadPlayer();
cheese.cheesecount = data.collectedCheese;
+ cheeseCoin.cheeseCoinCollected = data.isCheeseCoinCollected;
Vector3 position;
position.x = data.position[0];
public class CheeseCoin : MonoBehaviour
{
- private bool cheeseCoinCollected;
+ public bool cheeseCoinCollected;
public GameObject cheeseCoin;
}
else
{
- //gibt eine NullReferenceException aus
cheeseCoinImage.sprite = missingCheeseCoin;
}
{
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;
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();