mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
Remove Unused Codes.
Remove Unused Codes.
This commit is contained in:
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: ab10a5a730054c5aaa942164c750abfb
|
|
||||||
timeCreated: 1689576189
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 94212c40840344b5bd6ba4fc82097d47
|
|
||||||
timeCreated: 1689576337
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 78e93a657ea64d5d97000e8b6cc83ffc
|
|
||||||
timeCreated: 1689576342
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 3212280593954784b888cf6e9fa088a8
|
|
||||||
timeCreated: 1689584199
|
|
@@ -1,11 +0,0 @@
|
|||||||
using TEngine;
|
|
||||||
|
|
||||||
namespace GameLogic.BattleDemo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Actor属性数据管理。
|
|
||||||
/// </summary>
|
|
||||||
public class ActorData : EntityLogicComponent
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: a344b822c96449a29d78fb64b02c762d
|
|
||||||
timeCreated: 1689584206
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: cc314cd9682f4c1d8a870e2b4c6a5c88
|
|
||||||
timeCreated: 1689584122
|
|
@@ -1,86 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using TEngine;
|
|
||||||
|
|
||||||
namespace GameLogic.BattleDemo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 实体类的Buff管理。
|
|
||||||
/// </summary>
|
|
||||||
public class BuffComponent:EntityLogicComponent
|
|
||||||
{
|
|
||||||
private readonly Dictionary<int, BufferItem> _allBuff = new Dictionary<int, BufferItem>();
|
|
||||||
private readonly List<BufferItem> _listBuff = new List<BufferItem>();
|
|
||||||
|
|
||||||
|
|
||||||
public override void Dispose()
|
|
||||||
{
|
|
||||||
foreach (var bufferItem in _listBuff)
|
|
||||||
{
|
|
||||||
BufferItem.Release(bufferItem);
|
|
||||||
}
|
|
||||||
_listBuff.Clear();
|
|
||||||
_allBuff.Clear();
|
|
||||||
base.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 增加Buff。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="buffId">BuffId。</param>
|
|
||||||
/// <param name="caster">施法者。</param>
|
|
||||||
/// <param name="addStackNum">增加层数。</param>
|
|
||||||
/// <param name="skillId">技能Id。</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 移除Buff。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="buffID">BuffID。</param>
|
|
||||||
/// <param name="caster">移除施放来源。</param>
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 刷新Buff带来的属性。
|
|
||||||
/// </summary>
|
|
||||||
private void RefreshBuffAttr()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 刷新Buff改变的状态。
|
|
||||||
/// </summary>
|
|
||||||
private void UpdateBuffState()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 29088ba5001247628aefb072c6d82705
|
|
||||||
timeCreated: 1689582372
|
|
@@ -1,62 +0,0 @@
|
|||||||
using GameConfig.Battle;
|
|
||||||
using TEngine;
|
|
||||||
|
|
||||||
namespace GameLogic.BattleDemo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Buff实例。
|
|
||||||
/// </summary>
|
|
||||||
public class BufferItem:IMemory
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// BuffId。
|
|
||||||
/// </summary>
|
|
||||||
public int BuffID => BuffConfig?.BuffID ?? 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// BUff配置表。
|
|
||||||
/// </summary>
|
|
||||||
public BuffConfig BuffConfig { private set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 清理内存。
|
|
||||||
/// </summary>
|
|
||||||
public void Clear()
|
|
||||||
{
|
|
||||||
BuffConfig = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 生成Buff实例。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="buffId">buffId。</param>
|
|
||||||
/// <returns>Buff实例。</returns>
|
|
||||||
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<BufferItem>();
|
|
||||||
ret.BuffConfig = buffConfig;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 释放Buff实例。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="bufferItem"></param>
|
|
||||||
public static void Release(BufferItem bufferItem)
|
|
||||||
{
|
|
||||||
if (bufferItem == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
MemoryPool.Release(bufferItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 8915b9545484419eb2642a69d4056daf
|
|
||||||
timeCreated: 1689584322
|
|
@@ -1,39 +0,0 @@
|
|||||||
using TEngine;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace GameLogic.BattleDemo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 实体创建预数据。
|
|
||||||
/// </summary>
|
|
||||||
public class EntityCreateData:IMemory
|
|
||||||
{
|
|
||||||
public ActorEntityType actorEntityType;
|
|
||||||
|
|
||||||
public bool HasBornPos = false;
|
|
||||||
|
|
||||||
public Vector3 BornPos;
|
|
||||||
|
|
||||||
public Vector3 BornForward;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置出生点。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="bornPos"></param>
|
|
||||||
/// <param name="forward"></param>
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 4ba847c6eb944645a4b693f1a432d933
|
|
||||||
timeCreated: 1689583498
|
|
@@ -1,65 +0,0 @@
|
|||||||
using TEngine;
|
|
||||||
|
|
||||||
namespace GameLogic.BattleDemo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 逻辑层实体。
|
|
||||||
/// </summary>
|
|
||||||
public abstract class EntityLogic : Entity
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 逻辑层实体类型。
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public abstract ActorEntityType GetActorEntityType();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 是否是战斗起始的Actor。
|
|
||||||
/// <remarks>,比如双方参与战斗的玩家,或者技能编辑器里的Caster。</remarks>
|
|
||||||
/// </summary>
|
|
||||||
public bool IsStartActor;
|
|
||||||
|
|
||||||
public EntityCreateData CreateData { private set; get; }
|
|
||||||
|
|
||||||
public virtual string GetActorName()
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void OnLogicCreate()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void LogicDestroy()
|
|
||||||
{
|
|
||||||
OnLogicDestroy();
|
|
||||||
if (CreateData != null)
|
|
||||||
{
|
|
||||||
MemoryPool.Release(CreateData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void OnLogicDestroy()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: e7b01c5b166445d680dc411dfbe5c781
|
|
||||||
timeCreated: 1689576203
|
|
@@ -1,12 +0,0 @@
|
|||||||
using TEngine;
|
|
||||||
|
|
||||||
namespace GameLogic.BattleDemo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 逻辑层组件实体。
|
|
||||||
/// </summary>
|
|
||||||
public abstract class EntityLogicComponent: Entity
|
|
||||||
{
|
|
||||||
public EntityLogic Owner => (EntityLogic)Parent;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 92574294d8144f218f323f63f72a8374
|
|
||||||
timeCreated: 1689585864
|
|
@@ -1,143 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using TEngine;
|
|
||||||
|
|
||||||
namespace GameLogic.BattleDemo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 实体类型。
|
|
||||||
/// </summary>
|
|
||||||
public enum ActorEntityType
|
|
||||||
{
|
|
||||||
None,
|
|
||||||
Player,
|
|
||||||
Monster,
|
|
||||||
Pet,
|
|
||||||
Npc,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 逻辑层实体管理器。
|
|
||||||
/// </summary>
|
|
||||||
public class EntityLogicMgr
|
|
||||||
{
|
|
||||||
private static readonly Dictionary<long, EntityLogic> EntityLogicPool = new Dictionary<long, EntityLogic>();
|
|
||||||
private static readonly List<EntityLogic> ListEntityLogics = new List<EntityLogic>();
|
|
||||||
|
|
||||||
public static event Action<EntityLogic> OnEntityCreate;
|
|
||||||
public static event Action<EntityLogic> OnEntityDestroy;
|
|
||||||
|
|
||||||
public static List<EntityLogic> GetAllActor(ref List<EntityLogic> temp)
|
|
||||||
{
|
|
||||||
if (temp == null)
|
|
||||||
{
|
|
||||||
temp = new List<EntityLogic>();
|
|
||||||
}
|
|
||||||
temp.AddRange(ListEntityLogics);
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<EntityLogic> GetTypeActor(ref List<EntityLogic> temp,ActorEntityType type)
|
|
||||||
{
|
|
||||||
if (temp == null)
|
|
||||||
{
|
|
||||||
temp = new List<EntityLogic>();
|
|
||||||
}
|
|
||||||
|
|
||||||
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<PlayerEntity>(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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 513b12007c8f408698d12aee22fc44db
|
|
||||||
timeCreated: 1689579220
|
|
@@ -1,18 +0,0 @@
|
|||||||
namespace GameLogic.BattleDemo
|
|
||||||
{
|
|
||||||
public class PlayerEntity : EntityLogic
|
|
||||||
{
|
|
||||||
public override ActorEntityType GetActorEntityType()
|
|
||||||
{
|
|
||||||
return ActorEntityType.Player;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnLogicCreate()
|
|
||||||
{
|
|
||||||
base.OnLogicCreate();
|
|
||||||
ActorData = AddComponent<ActorData>();
|
|
||||||
BuffComponent = AddComponent<BuffComponent>();
|
|
||||||
SkillCaster = AddComponent<SkillCasterComponent>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 9939517fe9f04f0d9c0c544fbdd43564
|
|
||||||
timeCreated: 1689576650
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 8d126355d2da45c8899a7a4fff5d376c
|
|
||||||
timeCreated: 1689584135
|
|
@@ -1,35 +0,0 @@
|
|||||||
using TEngine;
|
|
||||||
|
|
||||||
namespace GameLogic.BattleDemo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 技能释放组件。
|
|
||||||
/// </summary>
|
|
||||||
public class SkillCasterComponent:EntityLogicComponent
|
|
||||||
{
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 播放技能。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="skillId">技能Id。</param>
|
|
||||||
/// <param name="target">目标。</param>
|
|
||||||
/// <param name="checkCd">是否检测CD。</param>
|
|
||||||
/// <param name="forceCaster">是否强制释放。</param>
|
|
||||||
/// <returns>是否播放成功。</returns>
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 9b445989d175457db064ef74adeb4181
|
|
||||||
timeCreated: 1689582410
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 0c20684aa6954a80abe88ef8ee599800
|
|
||||||
timeCreated: 1689585664
|
|
@@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace GameLogic.BattleDemo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 技能表现数据。
|
|
||||||
/// <remarks>表现数据再由SkillElementData组成。</remarks>
|
|
||||||
/// </summary>
|
|
||||||
[Serializable]
|
|
||||||
public class SkillDisplayData
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 7ffa4d74525b4c55ac6013a4372c6d42
|
|
||||||
timeCreated: 1689586727
|
|
@@ -1,232 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using GameConfig.Battle;
|
|
||||||
using TEngine;
|
|
||||||
|
|
||||||
namespace GameLogic.BattleDemo
|
|
||||||
{
|
|
||||||
public enum SkillPlayStatus
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 初始状态。
|
|
||||||
/// </summary>
|
|
||||||
PlayInit,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 技能施法前摇。
|
|
||||||
/// <remarks>播放动作阶段。</remarks>
|
|
||||||
/// </summary>
|
|
||||||
PlayingAim,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 播放技能阶段,该阶段同时只能有一个技能播放。
|
|
||||||
/// </summary>
|
|
||||||
PlayingFront,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 后台播放阶段,前台播放完后,可能还有一些元素要继续生效,这个时候转为后台播放阶段。
|
|
||||||
/// 同时玩家可以释放新的技能。
|
|
||||||
/// </summary>
|
|
||||||
PlayingBack,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 播放完毕,等待播放.
|
|
||||||
/// </summary>
|
|
||||||
PlayingToFree
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 技能播放的数据。
|
|
||||||
/// </summary>
|
|
||||||
public class SkillPlayData:IMemory
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 技能内存Id,代表该玩家当前的唯一技能Id。
|
|
||||||
/// </summary>
|
|
||||||
public uint skillGid = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 技能的配置Id。
|
|
||||||
/// </summary>
|
|
||||||
public uint skillId;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 技能的配置。
|
|
||||||
/// </summary>
|
|
||||||
public SkillBaseConfig skillBaseConfig;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 技能表现ID.
|
|
||||||
/// </summary>
|
|
||||||
public int skillDisplayId;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 技能表现数据。
|
|
||||||
/// </summary>
|
|
||||||
public SkillDisplayData skillDisplayData;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 是否已经创建过visual表现层。
|
|
||||||
/// </summary>
|
|
||||||
public bool HasVisualPlayData = false;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 开始时间。
|
|
||||||
/// </summary>
|
|
||||||
public float startTime;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 开始技能进入后台的时间。
|
|
||||||
/// </summary>
|
|
||||||
public float startBackTime;
|
|
||||||
|
|
||||||
private SkillPlayStatus _status = SkillPlayStatus.PlayInit;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 播放状态
|
|
||||||
/// </summary>
|
|
||||||
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;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取技能施法者。
|
|
||||||
/// </summary>
|
|
||||||
public EntityLogic CasterActor
|
|
||||||
{
|
|
||||||
get => _casterActor;
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_casterActor = value;
|
|
||||||
_skillCaster = _casterActor.SkillCaster;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取施法者的运行时ID。
|
|
||||||
/// </summary>
|
|
||||||
public long CasterId
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_casterActor != null)
|
|
||||||
{
|
|
||||||
return _casterActor.RuntimeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 目标对象。
|
|
||||||
/// </summary>
|
|
||||||
public EntityLogic targetActor;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取技能播放模块。
|
|
||||||
/// </summary>
|
|
||||||
internal SkillCasterComponent SkillCaster => _skillCaster;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 处理动画元素。
|
|
||||||
/// </summary>
|
|
||||||
internal SkillAnimationHandle animHandle;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 技能元素处理列表。
|
|
||||||
/// </summary>
|
|
||||||
internal List<SkillElementHandle> handleList = new List<SkillElementHandle>();
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 增加技能元素处理。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="handle">技能元素处理。</param>
|
|
||||||
/// <returns>是否增加成功。</returns>
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 创建表现层技能对象。
|
|
||||||
/// </summary>
|
|
||||||
internal void CreateVisualObject()
|
|
||||||
{
|
|
||||||
if (HasVisualPlayData)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
HasVisualPlayData = true;
|
|
||||||
//发送给visual事件
|
|
||||||
//TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 销毁表现层技能对象。
|
|
||||||
/// </summary>
|
|
||||||
internal void DestroyVisualObject()
|
|
||||||
{
|
|
||||||
if (HasVisualPlayData && _casterActor != null)
|
|
||||||
{
|
|
||||||
HasVisualPlayData = false;
|
|
||||||
//TODO
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 05013b249849443eb8c5cb10491233ed
|
|
||||||
timeCreated: 1689586140
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 29cd06d7bab9405481fc35365616dac3
|
|
||||||
timeCreated: 1689587459
|
|
@@ -1,7 +0,0 @@
|
|||||||
namespace GameLogic.BattleDemo
|
|
||||||
{
|
|
||||||
public abstract class SkillElementData
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 7d6aefa939104f9d89a18ab78e385d05
|
|
||||||
timeCreated: 1689587502
|
|
@@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace GameLogic.BattleDemo
|
|
||||||
{
|
|
||||||
[Serializable]
|
|
||||||
public enum SkillTriggerEvent
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 无触发。
|
|
||||||
/// </summary>
|
|
||||||
NoneEvent,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 时间点触发。
|
|
||||||
/// </summary>
|
|
||||||
TimeEvent,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 施法结束触发。
|
|
||||||
/// </summary>
|
|
||||||
AnimStopEvent,
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 0413bfaea7674c68bde372498c15cc2d
|
|
||||||
timeCreated: 1689588039
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 503ad5f03b8b4f8aab31436f9c5f44eb
|
|
||||||
timeCreated: 1689587434
|
|
@@ -1,7 +0,0 @@
|
|||||||
namespace GameLogic.BattleDemo
|
|
||||||
{
|
|
||||||
public class SkillAnimationHandle:SkillElementHandle
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: f93a8f3fc1e34bb8a03bdb3c0ba56e27
|
|
||||||
timeCreated: 1689587524
|
|
@@ -1,152 +0,0 @@
|
|||||||
using GameConfig.Battle;
|
|
||||||
using TEngine;
|
|
||||||
|
|
||||||
namespace GameLogic.BattleDemo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 每个元素的状态。
|
|
||||||
/// </summary>
|
|
||||||
public enum SkillElementStatus
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 元素状态初始化。
|
|
||||||
/// </summary>
|
|
||||||
ELEM_STATUS_INIT,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 元素状态运行中。
|
|
||||||
/// </summary>
|
|
||||||
ELEM_STATUS_RUN,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 元素状态停止。
|
|
||||||
/// </summary>
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 初始化接口
|
|
||||||
/// </summary>
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 触发Element开始。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="playData">技能播放数据。</param>
|
|
||||||
/// <param name="eventType">技能触发类型。</param>
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 触发Element结束。
|
|
||||||
/// </summary>
|
|
||||||
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
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 检查配置是否正常
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public virtual string CheckElementConfig(ref string errField)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 初始化一些数,在加入到技能列表的时候触发
|
|
||||||
/// </summary>
|
|
||||||
protected virtual void OnInit()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 触发销毁。
|
|
||||||
/// </summary>
|
|
||||||
protected virtual void OnDestroy()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 触发开始
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="playData">触发开始的消息类型</param>
|
|
||||||
/// <param name="eventType">触发开始的消息类型</param>
|
|
||||||
protected virtual void OnStart(SkillPlayData playData, SkillTriggerEvent eventType)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 触发结束。
|
|
||||||
/// </summary>
|
|
||||||
protected virtual void OnStop()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 调试绘制。
|
|
||||||
/// </summary>
|
|
||||||
public virtual void OnDrawGizmos()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 689c542f2f41447395080f93982a872f
|
|
||||||
timeCreated: 1689587448
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: fad718b498934a5d8c63aa6d1e115485
|
|
||||||
timeCreated: 1689576347
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 489220b19d954b69be5e170287e92210
|
|
||||||
timeCreated: 1689584174
|
|
@@ -1,18 +0,0 @@
|
|||||||
using TEngine;
|
|
||||||
|
|
||||||
namespace GameLogic.BattleDemo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 外观显示组件。
|
|
||||||
/// </summary>
|
|
||||||
public class DisplayComponent:EntityLogicComponent
|
|
||||||
{
|
|
||||||
public DisplayInfo displayInfo;
|
|
||||||
|
|
||||||
public override void Dispose()
|
|
||||||
{
|
|
||||||
MemoryPool.Release(displayInfo);
|
|
||||||
base.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: e1b7fbc52816477c9fc7de9eabe17667
|
|
||||||
timeCreated: 1689582273
|
|
@@ -1,12 +0,0 @@
|
|||||||
using TEngine;
|
|
||||||
|
|
||||||
namespace GameLogic.BattleDemo
|
|
||||||
{
|
|
||||||
public class DisplayInfo:IMemory
|
|
||||||
{
|
|
||||||
public void Clear()
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 7ee020b854aa4c62b684df994d73ad7a
|
|
||||||
timeCreated: 1689585424
|
|
@@ -1,14 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace GameLogic.BattleDemo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 表现层实体。
|
|
||||||
/// </summary>
|
|
||||||
public abstract class EntityVisual:MonoBehaviour
|
|
||||||
{
|
|
||||||
public EntityLogic Entity { protected set; get;}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 892288dabf264b20b49b03ae91ccf5f8
|
|
||||||
timeCreated: 1689576255
|
|
Reference in New Issue
Block a user