]> git.lizzy.rs Git - SuperMouseAdventure.git/blob - 2DGame/Assets/Scripts/Mouse/CheckpointManager.cs
checkpoint-system v0.3
[SuperMouseAdventure.git] / 2DGame / Assets / Scripts / Mouse / 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
9     public Vector3 lastCheckpointPos;
10
11     [SerializeField]
12     Transform firstCheckpoint;
13
14     CheeseCollection cheese;
15
16     CheeseCoin cheeseCoin;
17
18     public Transform mouse;
19
20     public int lastCheeseCount;
21
22     public bool isCheeseCoinCollected;
23
24     void Awake()
25     {
26         if (instance == null)
27         {
28             instance = this;
29             DontDestroyOnLoad(instance);
30         }
31         else
32         {
33             Destroy(gameObject);
34         }
35     }
36
37     private void Start()
38     {
39         firstCheckpoint.position = mouse.position;
40     }
41
42
43     public void SavePlayer ()
44     {
45         SaveSystem.SavePlayer(instance, cheese, cheeseCoin);
46     }
47
48     public void LoadPlayer()
49     {
50         PlayerData data = SaveSystem.LoadPlayer();
51
52         cheeseCoin.cheeseCoinCollected = data.isCheeseCoinCollected;
53
54         Vector3 position;
55         position.x = data.position[0];
56         position.y = data.position[1];
57         position.z = data.position[2];
58         mouse.transform.position = position;
59     }
60 }