]> git.lizzy.rs Git - SuperMouseAdventure.git/blob - 2DGame/Assets/Scripts/Mouse/Cheese.cs
Properly set cheese counter display on respawn
[SuperMouseAdventure.git] / 2DGame / Assets / Scripts / Mouse / Cheese.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 using UnityEngine.UI;
5
6 public class Cheese : MonoBehaviour
7 {
8     public Text countText;
9
10     [HideInInspector]
11     public int cheesecount;
12
13     public bool collected;
14
15     void Start()
16     {
17         SetCheeseCount(0);
18     }
19
20     private void OnTriggerEnter2D(Collider2D collision)
21     {
22         if (collision.gameObject.CompareTag("Cheese"))
23         {
24             SetCheeseCount(cheesecount + 1);
25
26             FindObjectOfType<AudioManager>().Play("cheese_plop");
27
28             collision.gameObject.SetActive(false);
29         }
30     }
31
32     public void SetCheeseCount(int count)
33     {
34                 cheesecount = count;
35                 countText.text = cheesecount.ToString();
36         }
37 }