apply final level up vfx

This commit is contained in:
NguyenVanDat
2025-11-12 14:05:00 +07:00
parent cfeebf3a15
commit f1e15cdc2d
6 changed files with 192 additions and 30 deletions
@@ -87,12 +87,6 @@ MonoBehaviour:
m_SerializedLabels:
- models
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 55af737b2941ead45a871fdefa955831
m_Address: "\u7A0B\u5E8F\u8054\u5165/\u89D2\u8272\u5347\u7EA7\u4EBA\u7C7B.gfx"
m_ReadOnly: 0
m_SerializedLabels:
- models
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 576e84b3fd877477eb7f0a424f30d5df
m_Address: "models/\u573A\u666F\u6D3B\u7269/\u51E4\u7FBD\u9E7F/\u96C4\u6027\u51E4\u7FBD\u9E7F/\u96CC\u6027\u51E4\u7FBD\u9E7F.ecm"
m_ReadOnly: 0
@@ -165,6 +159,12 @@ MonoBehaviour:
m_SerializedLabels:
- models
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: a81dab17b00ef4b4494a71ee88b10cc0
m_Address: "\u7A0B\u5E8F\u8054\u5165/\u89D2\u8272\u5347\u7EA7\u4EBA\u7C7B.gfx"
m_ReadOnly: 0
m_SerializedLabels:
- models
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: b058f8968d5aa4a8f9285fa891b7b9ba
m_Address: "models/npcs/npc/\u5973npc14/\u5973npc14/\u5973npc14.ecm"
m_ReadOnly: 0
@@ -0,0 +1,91 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &5546156283002964263
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1952331788120894226, guid: feaf190f48ec05741ad3801331ed8508, type: 3}
propertyPath: m_Name
value: "\u89D2\u8272\u5347\u7EA7\u4EBA\u7C7B Variant"
objectReference: {fileID: 0}
- target: {fileID: 3242001840766556792, guid: feaf190f48ec05741ad3801331ed8508, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5551675107189332503, guid: feaf190f48ec05741ad3801331ed8508, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5551675107189332503, guid: feaf190f48ec05741ad3801331ed8508, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5551675107189332503, guid: feaf190f48ec05741ad3801331ed8508, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5551675107189332503, guid: feaf190f48ec05741ad3801331ed8508, type: 3}
propertyPath: m_LocalRotation.w
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: 5551675107189332503, guid: feaf190f48ec05741ad3801331ed8508, type: 3}
propertyPath: m_LocalRotation.x
value: -0.7071068
objectReference: {fileID: 0}
- target: {fileID: 5551675107189332503, guid: feaf190f48ec05741ad3801331ed8508, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5551675107189332503, guid: feaf190f48ec05741ad3801331ed8508, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5551675107189332503, guid: feaf190f48ec05741ad3801331ed8508, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: -90
objectReference: {fileID: 0}
- target: {fileID: 5551675107189332503, guid: feaf190f48ec05741ad3801331ed8508, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5551675107189332503, guid: feaf190f48ec05741ad3801331ed8508, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 1952331788120894226, guid: feaf190f48ec05741ad3801331ed8508, type: 3}
insertIndex: -1
addedObject: {fileID: 4119270388443505588}
m_SourcePrefab: {fileID: 100100000, guid: feaf190f48ec05741ad3801331ed8508, type: 3}
--- !u!198 &561032351675239899 stripped
ParticleSystem:
m_CorrespondingSourceObject: {fileID: 5421991121161782524, guid: feaf190f48ec05741ad3801331ed8508, type: 3}
m_PrefabInstance: {fileID: 5546156283002964263}
m_PrefabAsset: {fileID: 0}
--- !u!1 &6336552220164055605 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1952331788120894226, guid: feaf190f48ec05741ad3801331ed8508, type: 3}
m_PrefabInstance: {fileID: 5546156283002964263}
m_PrefabAsset: {fileID: 0}
--- !u!114 &4119270388443505588
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6336552220164055605}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9dcde7b030da4a94a9b5c05323a411bf, type: 3}
m_Name:
m_EditorClassIdentifier:
_vfx: {fileID: 561032351675239899}
_lifeTime: 7
m_iState: 0
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a81dab17b00ef4b4494a71ee88b10cc0
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -65,7 +65,7 @@ MonoBehaviour:
monsterPrefab: {fileID: 2542060226037108388, guid: 244942d3fb9382846b82581ce24fbf4e, type: 3}
npcServerPrefab: {fileID: -5899287755522118344, guid: 9bd42cdc18b3d624db35707155fc50de, type: 3}
cinemachineCamera: {fileID: 0}
_testVfxPrefab: {fileID: 0}
_testVfxPrefab: {fileID: 2282869967233380084, guid: 88e840e5dac12ed4383d994c7fadfef1, type: 3}
freeLookCam: {fileID: 0}
rotateSpeedX: 300
rotateSpeedY: 2
+14 -3
View File
@@ -128,6 +128,7 @@ public abstract class CECPlayer : CECObject
new A3DVECTOR3(0.3f, 0.85f, 0.3f),
};
private BaseVfxObject _levelUpVfx;
protected void Awake()
{
m_PlayerActions = _default_actions;
@@ -1171,10 +1172,20 @@ public abstract class CECPlayer : CECObject
GameObject prefab = await AddressableManager.Instance.LoadPrefabAsync(path);
if(prefab != null)
{
if (_levelUpVfx != null)
{
if(_levelUpVfx.IsPlaying())
return;
_levelUpVfx.Play();
return;
}
// Instantiate at player's current position and rotation
var vfx = Instantiate(prefab, transform.position, transform.rotation).GetComponent<BaseVfxObject>();
vfx.transform.SetParent(transform);
vfx.transform.localPosition = Vector3.zero;
_levelUpVfx = Instantiate(prefab, transform).GetComponent<BaseVfxObject>();
_levelUpVfx.Play();
// vfx.transform.SetParent(transform); transform.position, prefab.transform.rotation
_levelUpVfx.transform.localPosition = Vector3.zero;
Debug.LogError("Parent: "+transform.name);
}
else
{
@@ -1,3 +1,4 @@
using System;
using BrewMonster.Scripts;
using UnityEngine;
@@ -13,10 +14,18 @@ namespace BrewMonster.PerfectWorld.Scripts.Vfx
public class BaseVfxObject : MonoBehaviour
{
[SerializeField] private ParticleSystem _vfx;
[SerializeField] private float _lifeTime =-1;
private string _vfxPath;
private Vector3 _originalScale = Vector3.one;
private Vector3 _offset = Vector3.zero;
private GFX_STATE m_iState;
[SerializeField]private GFX_STATE m_iState;
private float _elapsedTime = 0f;
private bool _lifetimeCompleted = false;
/// <summary>
/// 生命周期完成事件 / Event triggered when lifetime is completed
/// </summary>
public event Action OnLifetimeCompleted;
private void Awake()
{
@@ -37,6 +46,21 @@ namespace BrewMonster.PerfectWorld.Scripts.Vfx
AddressableManager.Instance.UnloadAsset(_vfxPath);
}
}
private void Update()
{
if (_lifeTime > 0 && m_iState == GFX_STATE.ST_PLAY && !_lifetimeCompleted)
{
_elapsedTime += Time.deltaTime;
if (_elapsedTime >= _lifeTime)
{
_lifetimeCompleted = true;
Stop();
OnLifetimeCompleted?.Invoke();
}
}
}
public void Init(string vfxPath)
{
@@ -159,19 +183,12 @@ namespace BrewMonster.PerfectWorld.Scripts.Vfx
if (_vfx != null)
{
m_iState = GFX_STATE.ST_PLAY;
gameObject.SetActive(true);
_vfx.Play();
}
}
/// <summary>
/// Play VFX with children
/// </summary>
public void PlayWithChildren()
{
if (_vfx != null)
{
m_iState = GFX_STATE.ST_PLAY;
_vfx.Play(true);
// 重置生命周期计时器 / Reset lifetime timer
_elapsedTime = 0f;
_lifetimeCompleted = false;
}
}
@@ -184,6 +201,7 @@ namespace BrewMonster.PerfectWorld.Scripts.Vfx
{
m_iState = GFX_STATE.ST_STOP;
_vfx.Stop();
gameObject.SetActive(false);
}
}
@@ -221,6 +239,11 @@ namespace BrewMonster.PerfectWorld.Scripts.Vfx
_vfx.Stop();
_vfx.Clear();
_vfx.Play();
// 重置生命周期计时器 / Reset lifetime timer
m_iState = GFX_STATE.ST_PLAY;
_elapsedTime = 0f;
_lifetimeCompleted = false;
}
}
@@ -229,23 +252,53 @@ namespace BrewMonster.PerfectWorld.Scripts.Vfx
/// </summary>
public bool IsPlaying()
{
return _vfx != null && _vfx.isPlaying;
return m_iState == GFX_STATE.ST_PLAY;
}
/// <summary>
/// 检查特效是否已结束 / Check if VFX is stopped
/// Set lifetime duration
/// </summary>
public bool IsStopped()
/// <param name="lifeTime">生命周期时长(秒),-1表示无限 / Lifetime in seconds, -1 for infinite</param>
public void SetLifeTime(float lifeTime)
{
return _vfx != null && _vfx.isStopped;
_lifeTime = lifeTime;
_elapsedTime = 0f;
_lifetimeCompleted = false;
}
/// <summary>
/// 获取粒子系统 / Get ParticleSystem component
/// Get lifetime duration
/// </summary>
public ParticleSystem GetParticleSystem()
public float GetLifeTime()
{
return _vfx;
return _lifeTime;
}
/// <summary>
/// Get elapsed time
/// </summary>
public float GetElapsedTime()
{
return _elapsedTime;
}
/// <summary>
/// Get remaining lifetime
/// </summary>
public float GetRemainingLifeTime()
{
if (_lifeTime <= 0)
return -1f;
return Mathf.Max(0f, _lifeTime - _elapsedTime);
}
/// <summary>
/// Check if lifetime is completed
/// </summary>
public bool IsLifetimeCompleted()
{
return _lifetimeCompleted;
}
}
}