NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Bullet/State/BulletStatePosBoom.cs

50 lines
1.5 KiB
C#

using AOT.PostProcess.BlackArea;
using Gameplay.Effect;
using LTGame;
using Gameplay.PostProcess.BlackArea;
namespace Gameplay.Bullet
{
public class BulletStatePosBoom : BaseBulletState
{
public BulletStatePosBoom(ViewBullet owner): base(owner, EBulletState.PosBoom)
{
}
protected override void _OnEnter(NBaseState exitState, object param)
{
base._OnEnter(exitState, param);
isFinished = true;
nextState = EBulletState.Destroy;
// 获取当前位置
if (!owner.map.WorldPosition2TGSCellIndex(owner.rootObj.transform.position, out var currentCellIndex))
{
DebugUtil.LogError("转换坐标出错:{0}", owner.rootObj.transform.position);
return;
}
BulletManager.instance.AddBuffs2CellIndex(currentCellIndex, owner.sender, owner.rawConfig);
if (owner.rawConfig.LightDuring > 0)
{
BlackAreaManager.instance.LightUpCell(currentCellIndex, owner.rawConfig.LightDuring);
}
// 在指定地点播放爆炸特效
var effectId = owner.rawConfig.DestroyEffectId;
if (effectId > 0)
{
var effectData = EffectManager.instance.PlayEffectById(effectId, owner.rootObj.transform.position);
effectData.owner = owner.sender;
}
owner.TriggerAddBulletIds(currentCellIndex);
}
}
}