witches
This commit is contained in:
parent
ffb1f1caa1
commit
b21d392ff6
80 changed files with 2888 additions and 221 deletions
|
@ -0,0 +1,38 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
public class HealthPotion : ProjectileHandler
|
||||
{
|
||||
[SerializeField] private float healthAdd;
|
||||
[SerializeField] private SphereCollider healthPotionEffectArea;
|
||||
[SerializeField] private GameObject explodeMesh;
|
||||
[SerializeField] private float exploseMeshTime = 0.5f;
|
||||
|
||||
void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
Collider[] targets = Physics.OverlapSphere(transform.position, healthPotionEffectArea.radius, healthPotionEffectArea.includeLayers);
|
||||
foreach (Collider target in targets)
|
||||
{
|
||||
if (!target.CompareTag("Unit")) continue;
|
||||
// GetComponent is expensive in performance, optimize here if it's slow
|
||||
AbstractUnit targetUnit = target.GetComponent<AbstractUnit>();
|
||||
|
||||
// No EnemyHealing
|
||||
if (targetUnit.IsTeamA != FromTeamA) continue;
|
||||
|
||||
targetUnit.Heal(healthAdd);
|
||||
|
||||
}
|
||||
CoroutineManager.Instance.StartCoroutine(ExplodeVisual());
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
private IEnumerator ExplodeVisual()
|
||||
{
|
||||
GameObject explosion = Instantiate(explodeMesh, transform.position, Quaternion.identity);
|
||||
explosion.transform.parent = null;
|
||||
yield return new WaitForSeconds(exploseMeshTime);
|
||||
Destroy(explosion);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue