123456789101112131415161718192021222324252627282930313233343536373839 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Pools;
- public class CoinCollection : MonoBehaviour
- {
- public CoinPool coinPool;
- public CoinCreation spawn;
- // Start is called before the first frame update
- void Start()
- {
- coinPool = GameObject.FindGameObjectWithTag("CoinPool").GetComponent<CoinPool>();
- spawn = GameObject.FindGameObjectWithTag("Route").GetComponent<CoinCreation>();
- }
- // Update is called once per frame
- void Update()
- {
- }
- //Keep count of collisions with player
- private void OnTriggerEnter(Collider other)
- {
- Debug.Log("Coin Hit!");
- if (other.gameObject.CompareTag("bike"))
- {
- Debug.Log("Collecting Coin");
- // Increase Hit Counter
- var bike = other.gameObject;
- bike.GetComponent<PlayerStats>().IncreaseCoinCounter();
- coinPool.ReturnToPool(gameObject);
- //sobald ein coin eingesammelt einen neuen erstellen/platzieren
- spawn.UpdateCoins();
- }
- }
- }
|