]> git.lizzy.rs Git - SuperMouseAdventure.git/blob - 2DGame/Assets/Scripts/Maus/CheckpointManager.cs
afb7c2fc8bdebf6150d1be92345271181ed11262
[SuperMouseAdventure.git] / 2DGame / Assets / Scripts / Maus / CheckpointManager.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4
5 public class CheckpointManager : MonoBehaviour
6 {
7     private static CheckpointManager instance;
8     public Vector3 lastCheckpointPos;
9     public Cheese cheese;
10     public int lastCheeseCount;
11     public Transform mouse;
12
13     void Awake()
14     {
15         if (instance == null)
16         {
17             instance = this;
18             DontDestroyOnLoad(instance);
19         }
20         else
21         {
22             Destroy(gameObject);
23         }
24     }
25     //cheese muss noch definiert werden
26
27
28     public void SavePlayer ()
29     {
30         SaveSystem.SavePlayer(instance, cheese);
31     }
32
33     public void LoadPlayer()
34     {
35         PlayerData data = SaveSystem.LoadPlayer();
36
37         cheese.cheesecount = data.collectedCheese;
38
39         Vector3 position;
40         position.x = data.position[0];
41         position.y = data.position[1];
42         position.z = data.position[2];
43         mouse.transform.position = position;
44     }
45 }