59 lines
1.6 KiB
C#
59 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Projectile : MonoBehaviour
|
|
{
|
|
private bool collided;
|
|
Vector3 oldEulerAngles;
|
|
|
|
public float damage;
|
|
|
|
private void Start()
|
|
{
|
|
// Will always be destroyed after 10 seconds.
|
|
Destroy(gameObject, 10);
|
|
|
|
//oldEulerAngles = transform.rotation.eulerAngles;
|
|
}
|
|
private void Update()
|
|
{
|
|
/*if (oldEulerAngles != transform.rotation.eulerAngles)
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
*/
|
|
}
|
|
|
|
private void OnCollisionEnter(Collision collision)
|
|
{
|
|
Debug.LogWarning(collision.gameObject.name);
|
|
if (collision.gameObject.tag != "IceBolt" && collision.gameObject.tag != "Player" && !collided)
|
|
{
|
|
collided = true;
|
|
if (collision.gameObject.tag == "Slime")
|
|
{
|
|
collision.gameObject.GetComponent<SlimeAI>().GetHit((int)damage);
|
|
}
|
|
if (collision.gameObject.name == "Dummy") Destroy(collision.gameObject); //REPLACE WITH ENEMY TAG CHECK AND DAMAGE CHECKING
|
|
Destroy(gameObject);
|
|
}
|
|
|
|
}
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
Debug.LogWarning(other.gameObject.name);
|
|
if (other.gameObject.tag != "IceBolt" && other.gameObject.tag != "Player" && !collided)
|
|
{
|
|
collided = true;
|
|
Destroy(gameObject);
|
|
}
|
|
if (other.gameObject.name == "Dummy")
|
|
{
|
|
Destroy(other.gameObject);
|
|
Destroy(gameObject);
|
|
}
|
|
|
|
}
|
|
}
|