Newer
Older
HardPoint-Project-Abertay-University-Unity3D / Assets / Scripts / Entities / EffectAplier.cs
@Rackday Rackday on 18 Aug 736 bytes Project Added
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EffectAplier : MonoBehaviour
{
    // Start is called before the first frame update
    [SerializeField]
    private List<EffectBase> effect = new List<EffectBase>();
    public bool canApply = false;
    private void OnCollisionEnter(Collision collision)
    {
        if (canApply)
        {
            IEffectsHandler handler = collision.gameObject.GetComponent<IEffectsHandler>();
            if (handler != null)
            {
                foreach (EffectBase e in effect)
                {
                    handler.ApplyEffect(e, gameObject);
                }
                Destroy(gameObject);
            }
        }
    }
}