using UnityEngine; using System.Collections; public class CoinPickup : MonoBehaviour { #region PUBLIC VARIABLES public int coinValue = 1; // Integer representing the value of this coin when collected #endregion #region COLLIDER 2D COMPONENT METHODS [OnEnter] /// /// Destroys the coin when touched by the Player GameObject and calls the CollectCoin() method of PlayerStats /// /// The Collider2D that is entering the trigger void OnTriggerEnter2D(Collider2D collider) { if(collider.tag == "Player") { PlayerStats stats = collider.gameObject.GetComponent(); stats.CollectCoin(this.coinValue); Destroy(this.gameObject); } } #endregion }