58 lines
1.5 KiB
C#
58 lines
1.5 KiB
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using Sirenix.OdinInspector;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.Pool;
|
||
|
|
||
|
// ReSharper disable once CheckNamespace
|
||
|
namespace BlueWaterProject
|
||
|
{
|
||
|
public class WeaponParticle : MonoBehaviour
|
||
|
{
|
||
|
#region properties and variables
|
||
|
|
||
|
[SerializeField] private List<string> targetTags;
|
||
|
|
||
|
[DisableIf("@true")]
|
||
|
[SerializeField] private float power;
|
||
|
|
||
|
private IObjectPool<WeaponParticle> managedWeaponPool;
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region Unity built-in methods
|
||
|
|
||
|
private void OnParticleCollision(GameObject other)
|
||
|
{
|
||
|
// 여러 태그 중 하나와 일치하는지 확인
|
||
|
foreach (var item in targetTags)
|
||
|
{
|
||
|
if (!other.CompareTag(item)) continue;
|
||
|
|
||
|
var iDamageable = other.GetComponent<IDamageable>();
|
||
|
iDamageable?.TakeDamage(power);
|
||
|
print("충돌");
|
||
|
|
||
|
Destroy(gameObject);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
Destroy(gameObject);
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region Custom methods
|
||
|
|
||
|
public void SetPower(float value) => power = value;
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
// #region ObjectPool function
|
||
|
//
|
||
|
// private void DestroyObject() => managedWeaponPool.Release(this);
|
||
|
// public void SetManagedPool(IObjectPool<WeaponParticle> pool) => managedWeaponPool = pool;
|
||
|
//
|
||
|
// #endregion
|
||
|
}
|
||
|
}
|