using System.Collections; using System.Collections.Generic; using UnityEngine; public class Coin : MonoBehaviour{ HealthBar health; // Start is called before the first frame update void Start(){ health = GameObject.FindGameObjectWithTag("Health").GetComponent(); } // Update is called once per frame void Update(){ } private void OnTriggerEnter2D(Collider2D col){ if(col.gameObject.tag == "Player"){ Destroy(this.gameObject); health.SendMessage("TakeDamage", -1); } if(col.gameObject.tag == "Bullet"){ Bullet bullet = col.GetComponent(); bullet.speed = bullet.speed * 2; Destroy(this.gameObject); } if (col.gameObject.tag == "Enemy"){ EnemyController enemy = col.GetComponent(); enemy.maxSpeed++; Destroy(this.gameObject); } } }