-
Notifications
You must be signed in to change notification settings - Fork 1
/
fireball_boss.cs
52 lines (42 loc) · 940 Bytes
/
fireball_boss.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using UnityEngine;
using System.Collections;
public class fireball_boss : MonoBehaviour
{
private int damage = 5;
void Start()
{
StartCoroutine(destroy());
}
void Update()
{
}
void set_player_pos(Vector3 pos)
{
Vector3 vel = pos - transform.position;
vel.Normalize();
rigidbody.velocity = vel * 25;
}
void set_damage(int dmg)
{
damage = dmg;
}
IEnumerator destroy()
{
yield return new WaitForSeconds(10f);
Destroy(gameObject);
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag.Equals("Player"))
{
other.gameObject.SendMessage("receive_damage", damage);
Destroy(gameObject);
}
}
void OnCollisionEnter(Collision other)
{
if (other.gameObject.tag.Equals("weapon"))
return;
Destroy(gameObject);
}
}