rabidus-test/Assets/Scripts/Coin.cs

20 lines
372 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Coin : MonoBehaviour, ICollectable
{
private CoinCounter _coinCounter;
private void Awake()
{
_coinCounter = FindObjectOfType<CoinCounter>();
}
public void Collect()
{
_coinCounter.CollectCoin();
Destroy(gameObject);
}
}