34 lines
969 B
C#
34 lines
969 B
C#
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<HealthBar>();
|
|
}
|
|
|
|
// 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>();
|
|
bullet.speed = bullet.speed * 2;
|
|
Destroy(this.gameObject);
|
|
}
|
|
if (col.gameObject.tag == "Enemy"){
|
|
EnemyController enemy = col.GetComponent<EnemyController>();
|
|
enemy.maxSpeed++;
|
|
Destroy(this.gameObject);
|
|
}
|
|
}
|
|
}
|