]> git.lizzy.rs Git - SuperMouseAdventure.git/blob - 2DGame/Assets/Scripts/Maus/CheeseCoin.cs
f64c987295e7cb5920f05e2957e0e8f2a57bd19f
[SuperMouseAdventure.git] / 2DGame / Assets / Scripts / Maus / CheeseCoin.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 using UnityEngine.UI;
5
6 public class CheeseCoin : MonoBehaviour
7 {
8     private bool cheeseCoinCollected;
9
10     public GameObject cheeseCoin;
11      
12     public Image cheeseCoinImage;
13     public Sprite collectedCheeseCoin;
14     public Sprite missingCheeseCoin;
15
16     // Update is called once per frame
17     void Update()
18     {
19         if (cheeseCoinCollected == true)
20         {
21             cheeseCoinImage.sprite = collectedCheeseCoin;
22         }
23         else
24         {
25             //gibt eine NullReferenceException aus
26             cheeseCoinImage.sprite = missingCheeseCoin;
27         }
28
29         cheeseCoin.transform.Rotate(new Vector3(0, 45, 0) * Time.deltaTime);
30     }
31
32     public void OnTriggerEnter2D(Collider2D collision)
33     {
34         if(collision.CompareTag("CheeseCoin"))
35         {
36             cheeseCoinCollected = true;
37             collision.gameObject.SetActive(false);
38         }
39     }
40 }