123456789101112131415161718192021222324252627282930313233 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System.Linq;
- using JetBrains.Annotations;
- using Pools;
- //Jeder Coin besitzt dieses Skript
- public class CoinCollection : MonoBehaviour
- {
- private CoinPool coinPool;
- // Start is called before the first frame update
- void Start()
- {
- coinPool = GameObject.FindGameObjectWithTag("CoinPool").GetComponent<CoinPool>();
- }
- //Keep count of collisions with player
- private void OnTriggerEnter(Collider other)
- {
- Debug.Log("Coin Hit!");
- if (other.gameObject.CompareTag("bike"))
- {
- // Increase Hit Counter
- var bike = other.gameObject;
- bike.GetComponent<PlayerStats>().IncreaseCoinCounter();
- //Returning Coin to Pool
- coinPool.ReturnToPool(gameObject);
- }
- }
- }
|