68 lines
1.9 KiB
C#
68 lines
1.9 KiB
C#
using UnityEngine;
|
|
|
|
public class EffectBase : MonoBehaviour
|
|
{
|
|
bool isActor;
|
|
Actor m_Actor;
|
|
eEffectPivot m_pivot;
|
|
Vector3 offset = new Vector3(0f, 0f);
|
|
|
|
private void Awake()
|
|
{
|
|
var particles = GetComponentsInChildren<ParticleSystem>();
|
|
for (int i = 0; i < particles.Length; i++)
|
|
{
|
|
var main = particles[i].main;
|
|
main.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
|
var rend = particles[i].GetComponent<ParticleSystemRenderer>();
|
|
if (rend != null)
|
|
rend.sortingOrder += 10; // 기존 값에서 +10
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (isActor)
|
|
transform.position = m_Actor.Get_World_Position(m_pivot) + offset;
|
|
}
|
|
|
|
public void Set(string effect, Vector3 pos, float offtime)
|
|
{
|
|
var data = table_effect.Ins.Get_Data(effect);
|
|
offset = new Vector3(data.f_PositionX, data.f_PositionY);
|
|
pos += offset;
|
|
transform.position = pos;
|
|
transform.localScale = data.f_Scale * Vector3.one;
|
|
Set_OffTime(offtime);
|
|
}
|
|
|
|
public void Set(string effect, eEffectPivot pivot, Actor actor, Vector3 pos, float offtime)
|
|
{
|
|
m_Actor = actor; isActor = m_Actor;
|
|
m_pivot = pivot;
|
|
var data = table_effect.Ins.Get_Data(effect);
|
|
offset = new Vector3(data.f_PositionX, data.f_PositionY);
|
|
pos += offset;
|
|
transform.position = pos;
|
|
transform.localScale = data.f_Scale * Vector3.one;
|
|
Set_OffTime(offtime);
|
|
}
|
|
|
|
public void Set_OffTime(float offtime)
|
|
{
|
|
gameObject.SetActive(true);
|
|
|
|
if (IsInvoking("Off"))
|
|
CancelInvoke("Off");
|
|
|
|
if (offtime > 0f)
|
|
Invoke("Off", offtime);
|
|
|
|
// offtime 이 0 보다 작은 경우는 알아서 끄는 경우
|
|
}
|
|
|
|
public void Off()
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
} |