]> git.lizzy.rs Git - SuperMouseAdventure.git/blob - 2DGame/Assets/Scripts/Maus/Checkpoint.cs
SaveSystem v0.1 NICHT FUNKTIONAL!!!
[SuperMouseAdventure.git] / 2DGame / Assets / Scripts / Maus / Checkpoint.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4
5 public class Checkpoint : MonoBehaviour
6 {
7     private CheckpointManager cm;
8     private Cheese cheese;
9
10     public Sprite red;
11     public Sprite green;
12
13     void Start()
14     {
15         cm = GameObject.FindGameObjectWithTag("CheckpointManager").GetComponent<CheckpointManager>();
16         cheese = GameObject.FindGameObjectWithTag("Player").GetComponent<Cheese>();
17     }
18
19     void OnTriggerEnter2D(Collider2D collision)
20     {
21         if(collision.CompareTag("Player"))
22         {
23             cm.lastCheckpointPos = transform.position;
24             cm.lastCheeseCount = cheese.cheesecount;
25             GetComponent<SpriteRenderer>().sprite = green;
26         }
27     }
28 }