AI_FireProjectile.cs 580 Bytes
Newer Older
mthiele2's avatar
mthiele2 committed
1
2
3
4
using UnityEngine;

public class AI_FireProjectile : MonoBehaviour
{
mthiele2's avatar
mthiele2 committed
5
6
7
8
9
10
11
	private int damage;
	private float destroyTime;

	void Destroy()
	{
		Destroy(gameObject);
	}
mthiele2's avatar
mthiele2 committed
12

mthiele2's avatar
mthiele2 committed
13
14
	private void OnTriggerEnter2D(Collider2D other)
	{
mthiele2's avatar
mthiele2 committed
15
		if (other.CompareTag("Fire") || other.CompareTag("EnemyShot"))
16
17
18
19
		{
			return;
		}
			if (other.CompareTag("Player"))
mthiele2's avatar
mthiele2 committed
20
		{
mthiele2's avatar
mthiele2 committed
21
			other.GetComponentInParent<Life>().Damage(damage);
mthiele2's avatar
mthiele2 committed
22
		}
23
		Destroy(gameObject);
mthiele2's avatar
mthiele2 committed
24
	}
mthiele2's avatar
mthiele2 committed
25
26
27
28
29
30
31

	public void setValues(int damage, float destroyTime)
	{
		this.damage = damage;
		this.destroyTime = destroyTime;
		Invoke("Destroy", destroyTime);
	}
mthiele2's avatar
mthiele2 committed
32
33
}