diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Attr.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Attr.meta new file mode 100644 index 00000000..10d27cac --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Attr.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3212280593954784b888cf6e9fa088a8 +timeCreated: 1689584199 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Attr/ActorData.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Attr/ActorData.cs new file mode 100644 index 00000000..3b56d018 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Attr/ActorData.cs @@ -0,0 +1,11 @@ +using TEngine; + +namespace GameLogic.BattleDemo +{ + /// + /// Actor属性数据管理。 + /// + public class ActorData : EntityLogicComponent + { + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Attr/ActorData.cs.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Attr/ActorData.cs.meta new file mode 100644 index 00000000..74e9f36f --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Attr/ActorData.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a344b822c96449a29d78fb64b02c762d +timeCreated: 1689584206 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Buff.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Buff.meta new file mode 100644 index 00000000..9a828f71 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Buff.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cc314cd9682f4c1d8a870e2b4c6a5c88 +timeCreated: 1689584122 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Buff/BuffComponent.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Buff/BuffComponent.cs new file mode 100644 index 00000000..23879881 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Buff/BuffComponent.cs @@ -0,0 +1,86 @@ +using System.Collections.Generic; +using System.Linq; +using TEngine; + +namespace GameLogic.BattleDemo +{ + /// + /// 实体类的Buff管理。 + /// + public class BuffComponent:EntityLogicComponent + { + private readonly Dictionary _allBuff = new Dictionary(); + private readonly List _listBuff = new List(); + + + public override void Dispose() + { + foreach (var bufferItem in _listBuff) + { + BufferItem.Release(bufferItem); + } + _listBuff.Clear(); + _allBuff.Clear(); + base.Dispose(); + } + + /// + /// 增加Buff。 + /// + /// BuffId。 + /// 施法者。 + /// 增加层数。 + /// 技能Id。 + /// + public bool AddBuff(int buffId, EntityLogic caster, int addStackNum = 1, uint skillId = 0) + { + BufferItem bufferItem = BufferItem.Alloc(buffId); + if (bufferItem == null) + { + return false; + } + RefreshBuffAttr(); + UpdateBuffState(); + _allBuff.Add(buffId, bufferItem); + _listBuff.Add(bufferItem); + return true; + } + + /// + /// 移除Buff。 + /// + /// BuffID。 + /// 移除施放来源。 + public void RmvBuff(int buffID, EntityLogic caster) + { + if (_allBuff.TryGetValue(buffID, out BufferItem buffItem)) + { + RemoveBuffFromList(buffItem); + RefreshBuffAttr(); + UpdateBuffState(); + } + } + + private void RemoveBuffFromList(BufferItem buffItem) + { + Log.Info("remove buff: {0}", buffItem.BuffID); + BufferItem.Release(buffItem); + _allBuff.Remove(buffItem.BuffID); + _listBuff.Remove(buffItem); + } + + /// + /// 刷新Buff带来的属性。 + /// + private void RefreshBuffAttr() + { + } + + /// + /// 刷新Buff改变的状态。 + /// + private void UpdateBuffState() + { + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Buff/BuffComponent.cs.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Buff/BuffComponent.cs.meta new file mode 100644 index 00000000..87408c77 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Buff/BuffComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 29088ba5001247628aefb072c6d82705 +timeCreated: 1689582372 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Buff/BufferItem.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Buff/BufferItem.cs new file mode 100644 index 00000000..5b1c2fab --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Buff/BufferItem.cs @@ -0,0 +1,62 @@ +using GameConfig.Battle; +using TEngine; + +namespace GameLogic.BattleDemo +{ + /// + /// Buff实例。 + /// + public class BufferItem:IMemory + { + /// + /// BuffId。 + /// + public int BuffID => BuffConfig?.BuffID ?? 0; + + /// + /// BUff配置表。 + /// + public BuffConfig BuffConfig { private set; get; } + + /// + /// 清理内存。 + /// + public void Clear() + { + BuffConfig = null; + } + + /// + /// 生成Buff实例。 + /// + /// buffId。 + /// Buff实例。 + public static BufferItem Alloc(int buffId) + { + Log.Debug($"Alloc buffItem buffId:{buffId}"); + BuffConfig buffConfig = ConfigLoader.Instance.Tables.TbBuff.Get(buffId); + if (buffConfig == null) + { + Log.Warning($"Alloc buffItem Failed ! buffId:{buffId}"); + return null; + } + + BufferItem ret = MemoryPool.Acquire(); + ret.BuffConfig = buffConfig; + return ret; + } + + /// + /// 释放Buff实例。 + /// + /// + public static void Release(BufferItem bufferItem) + { + if (bufferItem == null) + { + return; + } + MemoryPool.Release(bufferItem); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Buff/BufferItem.cs.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Buff/BufferItem.cs.meta new file mode 100644 index 00000000..153ef7bb --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Buff/BufferItem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8915b9545484419eb2642a69d4056daf +timeCreated: 1689584322 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityCreateData.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityCreateData.cs new file mode 100644 index 00000000..02d711f6 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityCreateData.cs @@ -0,0 +1,39 @@ +using TEngine; +using UnityEngine; + +namespace GameLogic.BattleDemo +{ + /// + /// 实体创建预数据。 + /// + public class EntityCreateData:IMemory + { + public ActorEntityType actorEntityType; + + public bool HasBornPos = false; + + public Vector3 BornPos; + + public Vector3 BornForward; + + /// + /// 设置出生点。 + /// + /// + /// + public void SetBornPos(Vector3 bornPos, Vector3 forward) + { + HasBornPos = true; + BornPos = bornPos; + BornForward = forward; + } + + public void Clear() + { + actorEntityType = ActorEntityType.None; + HasBornPos = false; + BornPos = Vector3.zero; + BornForward = Vector3.zero; + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityCreateData.cs.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityCreateData.cs.meta new file mode 100644 index 00000000..0965d4b3 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityCreateData.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4ba847c6eb944645a4b693f1a432d933 +timeCreated: 1689583498 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogic.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogic.cs index 285f9ec9..3e717007 100644 --- a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogic.cs +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogic.cs @@ -7,14 +7,59 @@ namespace GameLogic.BattleDemo /// public abstract class EntityLogic : Entity { - public override void OnCreate() + /// + /// 逻辑层实体类型。 + /// + /// + public abstract ActorEntityType GetActorEntityType(); + + /// + /// 是否是战斗起始的Actor。 + /// ,比如双方参与战斗的玩家,或者技能编辑器里的Caster。 + /// + public bool IsStartActor; + + public EntityCreateData CreateData { private set; get; } + + public virtual string GetActorName() { - base.OnCreate(); + return string.Empty; + } + + #region 缓存常用组件 + public ActorData ActorData { protected set; get; } + + public BuffComponent BuffComponent { protected set; get; } + public SkillCasterComponent SkillCaster { protected set; get; } + #endregion + + #region 生命周期 + + internal bool LogicCreate(EntityCreateData entityCreateData) + { + CreateData = entityCreateData; + OnLogicCreate(); + return true; } - public override void Dispose() + protected virtual void OnLogicCreate() { - base.Dispose(); + } + + internal void LogicDestroy() + { + OnLogicDestroy(); + if (CreateData != null) + { + MemoryPool.Release(CreateData); + } + } + + protected virtual void OnLogicDestroy() + { + + } + #endregion } } \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogicComponent.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogicComponent.cs new file mode 100644 index 00000000..f2c53484 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogicComponent.cs @@ -0,0 +1,12 @@ +using TEngine; + +namespace GameLogic.BattleDemo +{ + /// + /// 逻辑层组件实体。 + /// + public abstract class EntityLogicComponent: Entity + { + public EntityLogic Owner => (EntityLogic)Parent; + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogicComponent.cs.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogicComponent.cs.meta new file mode 100644 index 00000000..013b5a33 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogicComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 92574294d8144f218f323f63f72a8374 +timeCreated: 1689585864 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogicMgr.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogicMgr.cs new file mode 100644 index 00000000..10c1658c --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogicMgr.cs @@ -0,0 +1,143 @@ +using System; +using System.Collections.Generic; +using TEngine; + +namespace GameLogic.BattleDemo +{ + /// + /// 实体类型。 + /// + public enum ActorEntityType + { + None, + Player, + Monster, + Pet, + Npc, + } + + /// + /// 逻辑层实体管理器。 + /// + public class EntityLogicMgr + { + private static readonly Dictionary EntityLogicPool = new Dictionary(); + private static readonly List ListEntityLogics = new List(); + + public static event Action OnEntityCreate; + public static event Action OnEntityDestroy; + + public static List GetAllActor(ref List temp) + { + if (temp == null) + { + temp = new List(); + } + temp.AddRange(ListEntityLogics); + return temp; + } + + public static List GetTypeActor(ref List temp,ActorEntityType type) + { + if (temp == null) + { + temp = new List(); + } + + foreach (var actor in ListEntityLogics) + { + if (actor.GetActorEntityType() == type) + { + temp.Add(actor); + } + } + return temp; + } + + public static EntityLogic CreateEntityLogic(EntityCreateData entityCreateData, bool isStartActor = false) + { + if (entityCreateData == null) + { + Log.Error("create actor failed, create data is null"); + return null; + } + var actor = CreateActorEntityObject(entityCreateData.actorEntityType); + if (actor == null) + { + Log.Error("create actor failed, create data is {0}", entityCreateData); + return null; + } + + actor.IsStartActor = isStartActor; + if (!actor.LogicCreate(entityCreateData)) + { + DestroyActor(actor); + return null; + } + + if (OnEntityCreate != null) + { + OnEntityCreate(actor); + } + + Log.Debug("entityLogic created: {0}", actor.GetActorName()); + return actor; + } + + private static EntityLogic CreateActorEntityObject(ActorEntityType actorType) + { + EntityLogic entityLogic = null; + + switch (actorType) + { + case ActorEntityType.Player: + { + entityLogic = Entity.Create(GameApp.Instance.Scene); + break; + } + default: + { + Log.Error("unknown actor type:{0}", actorType); + break; + } + } + + if (entityLogic != null) + { + EntityLogicPool.Add(entityLogic.RuntimeId, entityLogic); + ListEntityLogics.Add(entityLogic); + } + return entityLogic; + } + + + public static bool DestroyActor(long runtimeId) + { + EntityLogicPool.TryGetValue(runtimeId, out EntityLogic entityLogic); + if (entityLogic != null) + { + return DestroyActor(entityLogic); + } + return false; + } + + public static bool DestroyActor(EntityLogic entityLogic) + { + Log.Debug("on destroy entityLogic {0}", entityLogic.RuntimeId); + + + var runtimeId = entityLogic.RuntimeId; + Log.Assert(EntityLogicPool.ContainsKey(runtimeId)); + + if (OnEntityDestroy != null) + { + OnEntityDestroy(entityLogic); + } + + entityLogic.LogicDestroy(); + EntityLogicPool.Remove(runtimeId); + ListEntityLogics.Remove(entityLogic); + return true; + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogicMgr.cs.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogicMgr.cs.meta new file mode 100644 index 00000000..58b70cc7 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/EntityLogicMgr.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 513b12007c8f408698d12aee22fc44db +timeCreated: 1689579220 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/PlayerEntity.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/PlayerEntity.cs index 03fdeb69..9568e688 100644 --- a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/PlayerEntity.cs +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/PlayerEntity.cs @@ -2,14 +2,17 @@ { public class PlayerEntity : EntityLogic { - public override void OnCreate() + public override ActorEntityType GetActorEntityType() { - base.OnCreate(); + return ActorEntityType.Player; } - public override void Dispose() + protected override void OnLogicCreate() { - base.Dispose(); + base.OnLogicCreate(); + ActorData = AddComponent(); + BuffComponent = AddComponent(); + SkillCaster = AddComponent(); } } } \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill.meta new file mode 100644 index 00000000..75d3e45a --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8d126355d2da45c8899a7a4fff5d376c +timeCreated: 1689584135 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillCasterComponent.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillCasterComponent.cs new file mode 100644 index 00000000..a3bf7540 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillCasterComponent.cs @@ -0,0 +1,35 @@ +using TEngine; + +namespace GameLogic.BattleDemo +{ + /// + /// 技能释放组件。 + /// + public class SkillCasterComponent:EntityLogicComponent + { + + /// + /// 播放技能。 + /// + /// 技能Id。 + /// 目标。 + /// 是否检测CD。 + /// 是否强制释放。 + /// 是否播放成功。 + internal void PlaySkill(int skillId, EntityLogic target = null, bool forceCaster = false, bool checkCd = true) + { + Log.Assert(skillId > 0, $"ActorName: {Owner.GetActorName()}"); + Log.Debug("Start Play SKill[{0}]", skillId); + + var skillBaseConfig = ConfigLoader.Instance.Tables.TbSkill.Get(skillId); + + if (skillBaseConfig == null) + { + Log.Error("GetSkillBaseConfig Failed, invalid skillID: {0}", skillId); + return; + } + + + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillCasterComponent.cs.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillCasterComponent.cs.meta new file mode 100644 index 00000000..f1ba36aa --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillCasterComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9b445989d175457db064ef74adeb4181 +timeCreated: 1689582410 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillData.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillData.meta new file mode 100644 index 00000000..8ce14534 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillData.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0c20684aa6954a80abe88ef8ee599800 +timeCreated: 1689585664 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillData/SkillDisplayData.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillData/SkillDisplayData.cs new file mode 100644 index 00000000..5eb211d8 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillData/SkillDisplayData.cs @@ -0,0 +1,14 @@ +using System; + +namespace GameLogic.BattleDemo +{ + /// + /// 技能表现数据。 + /// 表现数据再由SkillElement组成。 + /// + [Serializable] + public class SkillDisplayData + { + + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillData/SkillDisplayData.cs.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillData/SkillDisplayData.cs.meta new file mode 100644 index 00000000..db66dcba --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillData/SkillDisplayData.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7ffa4d74525b4c55ac6013a4372c6d42 +timeCreated: 1689586727 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillData/SkillPlayData.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillData/SkillPlayData.cs new file mode 100644 index 00000000..b21cf9a0 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillData/SkillPlayData.cs @@ -0,0 +1,232 @@ +using System.Collections.Generic; +using GameConfig.Battle; +using TEngine; + +namespace GameLogic.BattleDemo +{ + public enum SkillPlayStatus + { + /// + /// 初始状态。 + /// + PlayInit, + + /// + /// 技能施法前摇。 + /// 播放动作阶段。 + /// + PlayingAim, + + /// + /// 播放技能阶段,该阶段同时只能有一个技能播放。 + /// + PlayingFront, + + /// + /// 后台播放阶段,前台播放完后,可能还有一些元素要继续生效,这个时候转为后台播放阶段。 + /// 同时玩家可以释放新的技能。 + /// + PlayingBack, + + /// + /// 播放完毕,等待播放. + /// + PlayingToFree + } + + /// + /// 技能播放的数据。 + /// + public class SkillPlayData:IMemory + { + /// + /// 技能内存Id,代表该玩家当前的唯一技能Id。 + /// + public uint skillGid = 0; + + /// + /// 技能的配置Id。 + /// + public uint skillId; + + /// + /// 技能的配置。 + /// + public SkillBaseConfig skillBaseConfig; + + /// + /// 技能表现ID. + /// + public int skillDisplayId; + + /// + /// 技能表现数据。 + /// + public SkillDisplayData skillDisplayData; + + /// + /// 是否已经创建过visual表现层。 + /// + public bool HasVisualPlayData = false; + + /// + /// 开始时间。 + /// + public float startTime; + + /// + /// 开始技能进入后台的时间。 + /// + public float startBackTime; + + private SkillPlayStatus _status = SkillPlayStatus.PlayInit; + + /// + /// 播放状态 + /// + public SkillPlayStatus Status + { + set + { + if (_status != value) + { + _status = value; + if (_status == SkillPlayStatus.PlayingBack) + { + startBackTime = GameTime.time; + } + } + } + get => _status; + } + + public bool IsFrontStatus => _status == SkillPlayStatus.PlayingAim || _status == SkillPlayStatus.PlayingFront; + + public bool IsRunningStatus => _status == SkillPlayStatus.PlayingFront || _status == SkillPlayStatus.PlayingBack; + + private EntityLogic _casterActor = null; + private SkillCasterComponent _skillCaster = null; + + /// + /// 获取技能施法者。 + /// + public EntityLogic CasterActor + { + get => _casterActor; + + set + { + _casterActor = value; + _skillCaster = _casterActor.SkillCaster; + } + } + + /// + /// 获取施法者的运行时ID。 + /// + public long CasterId + { + get + { + if (_casterActor != null) + { + return _casterActor.RuntimeId; + } + + return 0; + } + } + + /// + /// 目标对象。 + /// + public EntityLogic targetActor; + + /// + /// 获取技能播放模块。 + /// + internal SkillCasterComponent SkillCaster => _skillCaster; + + /// + /// 处理动画元素。 + /// + internal SkillAnimationHandle animHandle; + + /// + /// 技能元素处理列表。 + /// + internal List handleList = new List(); + + public void Clear() + { + skillId = 0; + skillGid = 0; + skillDisplayId = 0; + skillDisplayData = null; + skillBaseConfig = null; + + Status = SkillPlayStatus.PlayInit; + startTime = 0; + startBackTime = 0; + + CasterActor = null; + targetActor = null; + DestroyAllElement(); + } + + private void DestroyAllElement() + { + //销毁所有的ElementHandle + foreach (var elemHandle in handleList) + { + elemHandle?.Destroy(); + } + handleList.Clear(); + animHandle = null; + } + + /// + /// 增加技能元素处理。 + /// + /// 技能元素处理。 + /// 是否增加成功。 + internal bool AddElementHandle(SkillElementHandle handle) + { + string errField = null; + string checkResult = handle.CheckElementConfig(ref errField); + if (!string.IsNullOrEmpty(checkResult)) + { + Log.Warning("skill Element config[{0}] error: {1}, RandomSkillLibraryId[{2}]", handle.GetType().ToString(), checkResult, skillId); + return false; + } + handleList.Add(handle); + return true; + } + + /// + /// 创建表现层技能对象。 + /// + internal void CreateVisualObject() + { + if (HasVisualPlayData) + { + return; + } + HasVisualPlayData = true; + //发送给visual事件 + //TODO + } + + /// + /// 销毁表现层技能对象。 + /// + internal void DestroyVisualObject() + { + if (HasVisualPlayData && _casterActor != null) + { + HasVisualPlayData = false; + //TODO + } + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillData/SkillPlayData.cs.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillData/SkillPlayData.cs.meta new file mode 100644 index 00000000..4f12c859 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillData/SkillPlayData.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 05013b249849443eb8c5cb10491233ed +timeCreated: 1689586140 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementData.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementData.meta new file mode 100644 index 00000000..009172cd --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementData.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 29cd06d7bab9405481fc35365616dac3 +timeCreated: 1689587459 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementData/SkillElementData.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementData/SkillElementData.cs new file mode 100644 index 00000000..ebc9d882 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementData/SkillElementData.cs @@ -0,0 +1,7 @@ +namespace GameLogic.BattleDemo +{ + public abstract class SkillElementData + { + + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementData/SkillElementData.cs.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementData/SkillElementData.cs.meta new file mode 100644 index 00000000..a27b4ecc --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementData/SkillElementData.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7d6aefa939104f9d89a18ab78e385d05 +timeCreated: 1689587502 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementData/SkillTriggerEvent.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementData/SkillTriggerEvent.cs new file mode 100644 index 00000000..4ec64512 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementData/SkillTriggerEvent.cs @@ -0,0 +1,23 @@ +using System; + +namespace GameLogic.BattleDemo +{ + [Serializable] + public enum SkillTriggerEvent + { + /// + /// 无触发。 + /// + NoneEvent, + + /// + /// 时间点触发。 + /// + TimeEvent, + + /// + /// 施法结束触发。 + /// + AnimStopEvent, + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementData/SkillTriggerEvent.cs.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementData/SkillTriggerEvent.cs.meta new file mode 100644 index 00000000..6a0596dc --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementData/SkillTriggerEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0413bfaea7674c68bde372498c15cc2d +timeCreated: 1689588039 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementHandle.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementHandle.meta new file mode 100644 index 00000000..72297f63 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementHandle.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 503ad5f03b8b4f8aab31436f9c5f44eb +timeCreated: 1689587434 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementHandle/SkillAnimationHandle.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementHandle/SkillAnimationHandle.cs new file mode 100644 index 00000000..8639101b --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementHandle/SkillAnimationHandle.cs @@ -0,0 +1,7 @@ +namespace GameLogic.BattleDemo +{ + public class SkillAnimationHandle:SkillElementHandle + { + + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementHandle/SkillAnimationHandle.cs.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementHandle/SkillAnimationHandle.cs.meta new file mode 100644 index 00000000..ed106565 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementHandle/SkillAnimationHandle.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f93a8f3fc1e34bb8a03bdb3c0ba56e27 +timeCreated: 1689587524 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementHandle/SkillElementHandle.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementHandle/SkillElementHandle.cs new file mode 100644 index 00000000..35e41549 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementHandle/SkillElementHandle.cs @@ -0,0 +1,152 @@ +using GameConfig.Battle; +using TEngine; + +namespace GameLogic.BattleDemo +{ + /// + /// 每个元素的状态。 + /// + public enum SkillElementStatus + { + /// + /// 元素状态初始化。 + /// + ELEM_STATUS_INIT, + + /// + /// 元素状态运行中。 + /// + ELEM_STATUS_RUN, + + /// + /// 元素状态停止。 + /// + ELEM_STATUS_STOP + } + + public abstract class SkillElementHandle + { + private static uint m_nextHandleGID = 1; + + public uint m_handleGID; + public EntityLogic CasterActor; + protected uint m_skillId; + protected SkillAttrDamageData[] m_damageAttr; + + protected SkillPlayData m_playData; + public SkillElementStatus Status = SkillElementStatus.ELEM_STATUS_INIT; + + public void Destroy() + { + if (Status == SkillElementStatus.ELEM_STATUS_RUN) + { + Stop(); + } + + OnDestroy(); + } + + /// + /// 初始化接口 + /// + public void Init(SkillPlayData playData, SkillAttrDamageData[] damageAttr) + { + m_handleGID = m_nextHandleGID++; + CasterActor = playData.CasterActor; + m_skillId = playData.skillId; + m_playData = playData; + m_damageAttr = damageAttr; + + Status = SkillElementStatus.ELEM_STATUS_INIT; + OnInit(); + } + + /// + /// 触发Element开始。 + /// + /// 技能播放数据。 + /// 技能触发类型。 + public void Start(SkillPlayData playData, SkillTriggerEvent eventType) + { + if (Status != SkillElementStatus.ELEM_STATUS_INIT) + { + Log.Error("invalid status skillId[{0}] element Type[{1}]", m_skillId, GetType().Name); + return; + } + + Status = SkillElementStatus.ELEM_STATUS_RUN; + + //如果是重复触发的机制,则不需要开始就触发。 + OnStart(playData, eventType); + } + + /// + /// 触发Element结束。 + /// + public void Stop() + { + if (Status == SkillElementStatus.ELEM_STATUS_STOP) + { + return; + } + + if (Status != SkillElementStatus.ELEM_STATUS_RUN) + { + Status = SkillElementStatus.ELEM_STATUS_STOP; + return; + } + + Status = SkillElementStatus.ELEM_STATUS_STOP; + OnStop(); + } + + #region override function + + /// + /// 检查配置是否正常 + /// + /// + public virtual string CheckElementConfig(ref string errField) + { + return null; + } + + /// + /// 初始化一些数,在加入到技能列表的时候触发 + /// + protected virtual void OnInit() + { + } + + /// + /// 触发销毁。 + /// + protected virtual void OnDestroy() + { + } + + /// + /// 触发开始 + /// + /// 触发开始的消息类型 + /// 触发开始的消息类型 + protected virtual void OnStart(SkillPlayData playData, SkillTriggerEvent eventType) + { + } + + /// + /// 触发结束。 + /// + protected virtual void OnStop() + { + } + + /// + /// 调试绘制。 + /// + public virtual void OnDrawGizmos() + { + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementHandle/SkillElementHandle.cs.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementHandle/SkillElementHandle.cs.meta new file mode 100644 index 00000000..52c6b62f --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Logic/Skill/SkillElementHandle/SkillElementHandle.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 689c542f2f41447395080f93982a872f +timeCreated: 1689587448 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/Display.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/Display.meta new file mode 100644 index 00000000..28156186 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/Display.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 489220b19d954b69be5e170287e92210 +timeCreated: 1689584174 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/Display/DisplayComponent.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/Display/DisplayComponent.cs new file mode 100644 index 00000000..0c1e61da --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/Display/DisplayComponent.cs @@ -0,0 +1,18 @@ +using TEngine; + +namespace GameLogic.BattleDemo +{ + /// + /// 外观显示组件。 + /// + public class DisplayComponent:EntityLogicComponent + { + public DisplayInfo displayInfo; + + public override void Dispose() + { + MemoryPool.Release(displayInfo); + base.Dispose(); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/Display/DisplayComponent.cs.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/Display/DisplayComponent.cs.meta new file mode 100644 index 00000000..879eb152 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/Display/DisplayComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e1b7fbc52816477c9fc7de9eabe17667 +timeCreated: 1689582273 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/Display/DisplayInfo.cs b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/Display/DisplayInfo.cs new file mode 100644 index 00000000..d8f45684 --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/Display/DisplayInfo.cs @@ -0,0 +1,12 @@ +using TEngine; + +namespace GameLogic.BattleDemo +{ + public class DisplayInfo:IMemory + { + public void Clear() + { + throw new System.NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/Display/DisplayInfo.cs.meta b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/Display/DisplayInfo.cs.meta new file mode 100644 index 00000000..da2ca0ad --- /dev/null +++ b/Assets/GameScripts/HotFix/GameLogic/BattleDemo/Core/Visual/Display/DisplayInfo.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7ee020b854aa4c62b684df994d73ad7a +timeCreated: 1689585424 \ No newline at end of file