add unity project
add SOLID examples
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace DefaultNamespace.Solid
|
||||
{
|
||||
public abstract class AreaOfEffect : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private ParticleSystem _particleSystem;
|
||||
[SerializeField] private AudioClip _audioClip;
|
||||
[SerializeField] private float _duration;
|
||||
|
||||
private AudioSource _audioSource;
|
||||
|
||||
protected abstract bool IsInsideOfEffectArea(Collision other);
|
||||
|
||||
private void OnCollisionEnter(Collision other)
|
||||
{
|
||||
if (!IsInsideOfEffectArea(other)) return;
|
||||
|
||||
_particleSystem.Play();
|
||||
_audioSource.PlayOneShot(_audioClip);
|
||||
|
||||
ApplyEffect();
|
||||
}
|
||||
|
||||
private void ApplyEffect()
|
||||
{
|
||||
// apply effect to something
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user