32 lines
762 B
C#
32 lines
762 B
C#
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
public class FreezeShardProjectile : MonoBehaviour
|
|
{
|
|
public float damage;
|
|
public float freezeDuration;
|
|
public Transform ownerRoot;
|
|
public float armTime = 0.05f;
|
|
float spawnTime;
|
|
|
|
void Awake() => spawnTime = Time.time;
|
|
|
|
void OnTriggerEnter(Collider other)
|
|
{
|
|
if (Time.time - spawnTime < armTime) return;
|
|
if (ownerRoot && other.transform.root == ownerRoot) return;
|
|
|
|
if (other.TryGetComponent<IDamageable>(out var dmg))
|
|
{
|
|
if (damage > 0) dmg.ApplyDamage(damage);
|
|
}
|
|
|
|
if (other.TryGetComponent<IFreezable>(out var freezable))
|
|
{
|
|
freezable.Freeze(freezeDuration);
|
|
}
|
|
|
|
Destroy(gameObject);
|
|
}
|
|
}
|