107 lines
3.0 KiB
C#
107 lines
3.0 KiB
C#
|
|
|
|
using Thousandto.Cfg.Data;
|
|
using Thousandto.Code.Center;
|
|
using Thousandto.Core.Asset;
|
|
using Thousandto.Plugins.Common.UniScene;
|
|
|
|
namespace Thousandto.Code.Logic
|
|
{
|
|
//简单技能召唤物
|
|
public class SimpleSkillObject : Entity
|
|
{
|
|
#region//私有变量
|
|
private bool _postDelete = false;
|
|
private float _lifeTimer = 0f;
|
|
private float _lifeTime = 0f;
|
|
#endregion
|
|
|
|
#region//属性
|
|
public Character Owner { get; private set; }
|
|
public DeclareSkill SkillCfg { get; private set; }
|
|
public SkillVisualInfo VisualInfo { get; private set; }
|
|
public PlaySimpleSkillObjectEventInfo EventInfo { get; private set; }
|
|
public FGameObjectVFX Vfx { get; private set; }
|
|
#endregion
|
|
|
|
protected override FSkinBase OnSetupSkin()
|
|
{
|
|
FSkinModel skin = GameCenter.LuaSystem.Adaptor.CreateFSkinModel(FSkinTypeCode.Custom);
|
|
skin.SetLayer(LayerUtils.SummonObj);
|
|
return skin;
|
|
}
|
|
|
|
protected override bool OnInitializeAfter(EntityInitInfo baseInfo)
|
|
{
|
|
base.OnInitializeAfter(baseInfo);
|
|
var info = baseInfo as SimpleSkillObjectInitInfo;
|
|
SyncInfo(info);
|
|
return true;
|
|
}
|
|
|
|
protected override void OnUninitializeBefore()
|
|
{
|
|
//GameCenter.WarningFiledManager.RemoveFiled(this);
|
|
base.OnUninitializeBefore();
|
|
}
|
|
|
|
public void SyncInfo(SimpleSkillObjectInitInfo info)
|
|
{
|
|
Owner = info.Owner;
|
|
SkillCfg = info.SkillCfg;
|
|
VisualInfo = info.VisualInfo;
|
|
EventInfo = info.EventInfo;
|
|
|
|
|
|
Vfx = new FGameObjectVFX(ModelTypeCode.SkillVFX, EventInfo.VfxID);
|
|
Vfx.SetParent(this.ModelTransform);
|
|
Vfx.SetPosition(Position);
|
|
Vfx.SetLayer(this.Layer);
|
|
if (!VisualInfo.EndClearVfx)
|
|
{
|
|
Vfx.IsNotLoop = true;
|
|
}
|
|
Vfx.Play();
|
|
|
|
//10倍技能帧数
|
|
var vfxLifeTime = VisualInfo.FrameCount * Skill.OneFrameTime * 10;
|
|
if (vfxLifeTime < 5f)
|
|
{
|
|
vfxLifeTime = 5f;
|
|
}
|
|
Vfx.LiftTime = vfxLifeTime;
|
|
|
|
_lifeTimer = 0f;
|
|
_lifeTime = EventInfo.LifeFrame * Skill.OneFrameTime;
|
|
_postDelete = false;
|
|
}
|
|
|
|
protected override void OnUpdate(float elapsedTime)
|
|
{
|
|
base.OnUpdate(elapsedTime);
|
|
|
|
if (_postDelete)
|
|
return;
|
|
|
|
_lifeTimer += elapsedTime;
|
|
if(_lifeTimer >= _lifeTime)
|
|
{
|
|
PostDelete();
|
|
}
|
|
}
|
|
|
|
private void PostDelete()
|
|
{
|
|
if (!_postDelete)
|
|
{
|
|
var baseScene = Scene as BaseScene;
|
|
if (baseScene != null)
|
|
{
|
|
baseScene.DeleteEntity(ID);
|
|
}
|
|
_postDelete = true;
|
|
}
|
|
}
|
|
}
|
|
}
|