12345678910111213141516171819202122232425262728293031323334 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class ExplosionDamage : MonoBehaviour {
- public float hitboxDuration = 0.5f;
- public float selfDestructTime = 2.0f;
- public int power = 10;
- public float slowTime = 0;
- float timeSinceExplosion = 0;
-
- void Start () {
- Destroy(gameObject, selfDestructTime);
- }
-
-
- void Update () {
- timeSinceExplosion += Time.deltaTime;
- }
- void OnTriggerEnter(Collider other)
- {
- if (timeSinceExplosion > hitboxDuration) return;
- EnemyMovement hitEnemy = other.GetComponent<EnemyMovement>();
- if (hitEnemy != null)
- {
-
- hitEnemy.Damage(power);
- if (slowTime > 0) hitEnemy.SlowDown(slowTime);
-
- }
- }
- }
|