mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
Compare commits
25 Commits
TEngine3.1
...
TEngine3.1
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d6dcd8851c | ||
![]() |
bbea9c4cee | ||
![]() |
b1ccb1fd53 | ||
![]() |
0f2ad3c71d | ||
![]() |
0e6851e691 | ||
![]() |
75b9956261 | ||
![]() |
401c397fc8 | ||
![]() |
94b314e91f | ||
![]() |
a6573d9336 | ||
![]() |
abf5357f49 | ||
![]() |
aab353cca3 | ||
![]() |
e13071c4db | ||
![]() |
e071c20214 | ||
![]() |
bf73ce333b | ||
![]() |
d7a60002d4 | ||
![]() |
61f657322d | ||
![]() |
33223dc02e | ||
![]() |
0661c59877 | ||
![]() |
7c74e10857 | ||
![]() |
db935bfb5f | ||
![]() |
dc6b7bb21e | ||
![]() |
d32f3cb768 | ||
![]() |
a32ab30444 | ||
![]() |
aa0d40c758 | ||
![]() |
5239b89326 |
8
Assets/AssetRaw/Configs/bidx.meta
Normal file
8
Assets/AssetRaw/Configs/bidx.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a824de3af698c34bb4343dbb911498b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -4,6 +4,7 @@ namespace TEngine.Core.Network
|
||||
{
|
||||
None = 0,
|
||||
KCP = 1,
|
||||
TCP = 2
|
||||
TCP = 2,
|
||||
WebSocket = 3,
|
||||
}
|
||||
}
|
@@ -2,7 +2,9 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
#if !UNITY_WEBGL
|
||||
using System.Net.Sockets;
|
||||
#endif
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
@@ -49,6 +51,7 @@ namespace TEngine.Core
|
||||
return $"{self.Address}:{self.Port}";
|
||||
}
|
||||
|
||||
#if !UNITY_WEBGL
|
||||
public static void SetSioUdpConnReset(Socket socket)
|
||||
{
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
@@ -70,5 +73,6 @@ namespace TEngine.Core
|
||||
|
||||
socket.IOControl(SIO_UDP_CONNRESET, new[] {Convert.ToByte(false)}, null);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
@@ -1,3 +1,4 @@
|
||||
#if !UNITY_WEBGL
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace TEngine.Core.Network
|
||||
@@ -48,4 +49,5 @@ namespace TEngine.Core.Network
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -13,7 +13,8 @@ namespace TEngine.Core.Network
|
||||
public void Initialize(NetworkProtocolType networkProtocolType, NetworkTarget networkTarget)
|
||||
{
|
||||
switch (networkProtocolType)
|
||||
{
|
||||
{
|
||||
#if !UNITY_WEBGL
|
||||
case NetworkProtocolType.KCP:
|
||||
{
|
||||
Network = new KCPClientNetwork(Scene, networkTarget);
|
||||
@@ -24,6 +25,7 @@ namespace TEngine.Core.Network
|
||||
Network = new TCPClientNetwork(Scene, networkTarget);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
{
|
||||
throw new NotSupportedException($"Unsupported NetworkProtocolType:{networkProtocolType}");
|
||||
|
@@ -13,6 +13,7 @@ namespace TEngine.Core.Network
|
||||
{
|
||||
switch (networkProtocolType)
|
||||
{
|
||||
#if !UNITY_WEBGL
|
||||
case NetworkProtocolType.KCP:
|
||||
{
|
||||
Network = new KCPServerNetwork(Scene, networkTarget, address);
|
||||
@@ -25,6 +26,7 @@ namespace TEngine.Core.Network
|
||||
// Log.Info($"NetworkProtocol:TCP IPEndPoint:{address}");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
{
|
||||
throw new NotSupportedException($"Unsupported NetworkProtocolType:{networkProtocolType}");
|
||||
|
@@ -1,3 +1,4 @@
|
||||
#if !UNITY_WEBGL
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
@@ -565,4 +566,5 @@ namespace TEngine.Core.Network
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -1,3 +1,4 @@
|
||||
#if !UNITY_WEBGL
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -459,4 +460,5 @@ namespace TEngine.Core.Network
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -1,3 +1,4 @@
|
||||
#if !UNITY_WEBGL
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.IO;
|
||||
@@ -232,4 +233,5 @@ namespace TEngine.Core.Network
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -1,3 +1,4 @@
|
||||
#if !UNITY_WEBGL
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -538,4 +539,5 @@ namespace TEngine.Core.Network
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -1,3 +1,4 @@
|
||||
#if !UNITY_WEBGL
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -235,4 +236,5 @@ namespace TEngine.Core.Network
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -1,3 +1,4 @@
|
||||
#if !UNITY_WEBGL
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
@@ -346,4 +347,5 @@ namespace TEngine.Core.Network
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -3,7 +3,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
#if UNITY_WEBGL
|
||||
using Cysharp.Threading.Tasks;
|
||||
#else
|
||||
using System.Threading.Tasks;
|
||||
#endif
|
||||
using TEngine.DataStructure;
|
||||
#pragma warning disable CS8601
|
||||
#pragma warning disable CS8604
|
||||
@@ -25,10 +29,10 @@ namespace TEngine.Core
|
||||
private static void Load(int assemblyName)
|
||||
{
|
||||
var count = 0;
|
||||
var task = new List<Task>();
|
||||
|
||||
#if !UNITY_WEBGL
|
||||
var task = new List<Task>();
|
||||
#endif
|
||||
UnLoad(assemblyName);
|
||||
|
||||
foreach (var singletonType in AssemblyManager.ForEach(assemblyName, typeof(ISingleton)))
|
||||
{
|
||||
var instance = (ISingleton) Activator.CreateInstance(singletonType);
|
||||
@@ -38,7 +42,11 @@ namespace TEngine.Core
|
||||
|
||||
if (initializeMethodInfo != null)
|
||||
{
|
||||
#if !UNITY_WEBGL
|
||||
task.Add((Task) initializeMethodInfo.Invoke(instance, null));
|
||||
#else
|
||||
initializeMethodInfo.Invoke(instance, null);
|
||||
#endif
|
||||
}
|
||||
|
||||
registerMethodInfo?.Invoke(instance, new object[] {instance});
|
||||
@@ -58,7 +66,9 @@ namespace TEngine.Core
|
||||
Singletons.Enqueue(assemblyName, instance);
|
||||
}
|
||||
|
||||
#if !UNITY_WEBGL
|
||||
Task.WaitAll(task.ToArray());
|
||||
#endif
|
||||
Log.Info($"assembly:{assemblyName} load Singleton count:{count}");
|
||||
}
|
||||
|
||||
|
@@ -1,3 +1,4 @@
|
||||
#if !UNITY_WEBGL
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
@@ -10,19 +11,18 @@ using System.Linq;
|
||||
{
|
||||
aucThread = new Thread(ReceiveMsg);
|
||||
aucThread.Start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//进程调用主线程方法
|
||||
MainPack pack = (MainPack)MainPack.Descriptor.Parser.ParseFrom(buffer, 0, len);
|
||||
Loom.QueueOnMainThread((param) =>
|
||||
{
|
||||
UdpHandleResponse(pack);
|
||||
}, null);
|
||||
|
||||
|
||||
*******************************************************************************/
|
||||
namespace GameBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Loom多线程通信。
|
||||
/// <remarks></remarks>
|
||||
@@ -187,4 +187,5 @@ namespace GameBase
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -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
|
@@ -7,8 +7,6 @@ public partial class GameApp:Singleton<GameApp>
|
||||
{
|
||||
private static List<Assembly> _hotfixAssembly;
|
||||
|
||||
public Scene Scene { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 热更域App主入口。
|
||||
/// </summary>
|
||||
@@ -35,7 +33,7 @@ public partial class GameApp:Singleton<GameApp>
|
||||
/// </summary>
|
||||
private void StartGameLogic()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -22,6 +22,11 @@ public partial class GameApp
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Entity框架根节点。
|
||||
/// </summary>
|
||||
public Scene Scene { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 注册所有逻辑系统
|
||||
/// </summary>
|
||||
@@ -38,6 +43,7 @@ public partial class GameApp
|
||||
//带生命周期的单例系统。
|
||||
AddLogicSys(BehaviourSingleSystem.Instance);
|
||||
AddLogicSys(DataCenterSys.Instance);
|
||||
AddLogicSys(ConfigSystem.Instance);
|
||||
GMBehaviourSystem.Instance.Active();
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0fcee77031f85f84dbc6735c875d64b8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
|
||||
public enum SnapStatus
|
||||
{
|
||||
NoTargetSet = 0,
|
||||
TargetHasSet = 1,
|
||||
SnapMoving = 2,
|
||||
SnapMoveFinish = 3
|
||||
}
|
||||
|
||||
|
||||
public enum ItemCornerEnum
|
||||
{
|
||||
LeftBottom = 0,
|
||||
LeftTop,
|
||||
RightTop,
|
||||
RightBottom,
|
||||
}
|
||||
|
||||
|
||||
public enum ListItemArrangeType
|
||||
{
|
||||
TopToBottom = 0,
|
||||
BottomToTop,
|
||||
LeftToRight,
|
||||
RightToLeft,
|
||||
}
|
||||
|
||||
public enum GridItemArrangeType
|
||||
{
|
||||
TopLeftToBottomRight = 0,
|
||||
BottomLeftToTopRight,
|
||||
TopRightToBottomLeft,
|
||||
BottomRightToTopLeft,
|
||||
}
|
||||
public enum GridFixedType
|
||||
{
|
||||
ColumnCountFixed = 0,
|
||||
RowCountFixed,
|
||||
}
|
||||
|
||||
public struct RowColumnPair
|
||||
{
|
||||
public RowColumnPair(int row1, int column1)
|
||||
{
|
||||
mRow = row1;
|
||||
mColumn = column1;
|
||||
}
|
||||
|
||||
public bool Equals(RowColumnPair other)
|
||||
{
|
||||
return this.mRow == other.mRow && this.mColumn == other.mColumn;
|
||||
}
|
||||
|
||||
public static bool operator ==(RowColumnPair a, RowColumnPair b)
|
||||
{
|
||||
return (a.mRow == b.mRow)&&(a.mColumn == b.mColumn);
|
||||
}
|
||||
public static bool operator !=(RowColumnPair a, RowColumnPair b)
|
||||
{
|
||||
return (a.mRow != b.mRow) || (a.mColumn != b.mColumn); ;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (obj is RowColumnPair) && Equals((RowColumnPair)obj);
|
||||
}
|
||||
|
||||
|
||||
public int mRow;
|
||||
public int mColumn;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19e4e487f35877f4b9bb864eb43484d6
|
||||
timeCreated: 1534508353
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7f738dc5a266e94d9e9870fc76009c2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,173 @@
|
||||
namespace GameLogic
|
||||
{
|
||||
//if GridFixedType is GridFixedType.ColumnCountFixed, then the GridItemGroup is one row of the gridview
|
||||
//if GridFixedType is GridFixedType.RowCountFixed, then the GridItemGroup is one column of the gridview
|
||||
public class GridItemGroup
|
||||
{
|
||||
private int _count = 0;
|
||||
private int _groupIndex = -1;//the row index or the column index of this group
|
||||
private LoopGridViewItem _first = null;
|
||||
private LoopGridViewItem _last = null;
|
||||
public int Count => _count;
|
||||
|
||||
public LoopGridViewItem First => _first;
|
||||
|
||||
public LoopGridViewItem Last => _last;
|
||||
|
||||
public int GroupIndex
|
||||
{
|
||||
get => _groupIndex;
|
||||
set => _groupIndex = value;
|
||||
}
|
||||
|
||||
|
||||
public LoopGridViewItem GetItemByColumn(int column)
|
||||
{
|
||||
LoopGridViewItem cur = _first;
|
||||
while(cur != null)
|
||||
{
|
||||
if(cur.Column == column)
|
||||
{
|
||||
return cur;
|
||||
}
|
||||
cur = cur.NextItem;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public LoopGridViewItem GetItemByRow(int row)
|
||||
{
|
||||
LoopGridViewItem cur = _first;
|
||||
while (cur != null)
|
||||
{
|
||||
if (cur.Row == row)
|
||||
{
|
||||
return cur;
|
||||
}
|
||||
cur = cur.NextItem;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void ReplaceItem(LoopGridViewItem curItem,LoopGridViewItem newItem)
|
||||
{
|
||||
newItem.PrevItem = curItem.PrevItem;
|
||||
newItem.NextItem = curItem.NextItem;
|
||||
if(newItem.PrevItem != null)
|
||||
{
|
||||
newItem.PrevItem.NextItem = newItem;
|
||||
}
|
||||
if(newItem.NextItem != null)
|
||||
{
|
||||
newItem.NextItem.PrevItem = newItem;
|
||||
}
|
||||
if(_first == curItem)
|
||||
{
|
||||
_first = newItem;
|
||||
}
|
||||
if(_last == curItem)
|
||||
{
|
||||
_last = newItem;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddFirst(LoopGridViewItem newItem)
|
||||
{
|
||||
newItem.PrevItem = null;
|
||||
newItem.NextItem = null;
|
||||
if (_first == null)
|
||||
{
|
||||
_first = newItem;
|
||||
_last = newItem;
|
||||
_first.PrevItem = null;
|
||||
_first.NextItem = null;
|
||||
_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
_first.PrevItem = newItem;
|
||||
newItem.PrevItem = null;
|
||||
newItem.NextItem = _first;
|
||||
_first = newItem;
|
||||
_count++;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddLast(LoopGridViewItem newItem)
|
||||
{
|
||||
newItem.PrevItem = null;
|
||||
newItem.NextItem = null;
|
||||
if (_first == null)
|
||||
{
|
||||
_first = newItem;
|
||||
_last = newItem;
|
||||
_first.PrevItem = null;
|
||||
_first.NextItem = null;
|
||||
_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
_last.NextItem = newItem;
|
||||
newItem.PrevItem = _last;
|
||||
newItem.NextItem = null;
|
||||
_last = newItem;
|
||||
_count++;
|
||||
}
|
||||
}
|
||||
|
||||
public LoopGridViewItem RemoveFirst()
|
||||
{
|
||||
LoopGridViewItem ret = _first;
|
||||
if (_first == null)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
if(_first == _last)
|
||||
{
|
||||
_first = null;
|
||||
_last = null;
|
||||
--_count;
|
||||
return ret;
|
||||
}
|
||||
_first = _first.NextItem;
|
||||
_first.PrevItem = null;
|
||||
--_count;
|
||||
return ret;
|
||||
}
|
||||
public LoopGridViewItem RemoveLast()
|
||||
{
|
||||
LoopGridViewItem ret = _last;
|
||||
if (_first == null)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
if (_first == _last)
|
||||
{
|
||||
_first = null;
|
||||
_last = null;
|
||||
--_count;
|
||||
return ret;
|
||||
}
|
||||
_last = _last.PrevItem;
|
||||
_last.NextItem = null;
|
||||
--_count;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
LoopGridViewItem current = _first;
|
||||
while (current != null)
|
||||
{
|
||||
current.PrevItem = null;
|
||||
current.NextItem = null;
|
||||
current = current.NextItem;
|
||||
}
|
||||
_first = null;
|
||||
_last = null;
|
||||
_count = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f7e7eb25fe1319d4b8773ddfab7a240e
|
||||
timeCreated: 1554538573
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
public class GridItemPool
|
||||
{
|
||||
private GameObject _prefabObj;
|
||||
private string _prefabName;
|
||||
private int _initCreateCount = 1;
|
||||
private readonly List<LoopGridViewItem> _tmpPooledItemList = new List<LoopGridViewItem>();
|
||||
private readonly List<LoopGridViewItem> _pooledItemList = new List<LoopGridViewItem>();
|
||||
private static int _curItemIdCount = 0;
|
||||
private RectTransform _itemParent = null;
|
||||
public GridItemPool()
|
||||
{
|
||||
|
||||
}
|
||||
public void Init(GameObject prefabObj, int createCount, RectTransform parent)
|
||||
{
|
||||
_prefabObj = prefabObj;
|
||||
_prefabName = _prefabObj.name;
|
||||
_initCreateCount = createCount;
|
||||
_itemParent = parent;
|
||||
_prefabObj.SetActive(false);
|
||||
for (int i = 0; i < _initCreateCount; ++i)
|
||||
{
|
||||
LoopGridViewItem tViewItem = CreateItem();
|
||||
RecycleItemReal(tViewItem);
|
||||
}
|
||||
}
|
||||
public LoopGridViewItem GetItem()
|
||||
{
|
||||
_curItemIdCount++;
|
||||
LoopGridViewItem tItem = null;
|
||||
if (_tmpPooledItemList.Count > 0)
|
||||
{
|
||||
int count = _tmpPooledItemList.Count;
|
||||
tItem = _tmpPooledItemList[count - 1];
|
||||
_tmpPooledItemList.RemoveAt(count - 1);
|
||||
tItem.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
int count = _pooledItemList.Count;
|
||||
if (count == 0)
|
||||
{
|
||||
tItem = CreateItem();
|
||||
}
|
||||
else
|
||||
{
|
||||
tItem = _pooledItemList[count - 1];
|
||||
_pooledItemList.RemoveAt(count - 1);
|
||||
tItem.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
tItem.ItemId = _curItemIdCount;
|
||||
return tItem;
|
||||
|
||||
}
|
||||
|
||||
public void DestroyAllItem()
|
||||
{
|
||||
ClearTmpRecycledItem();
|
||||
int count = _pooledItemList.Count;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
GameObject.DestroyImmediate(_pooledItemList[i].gameObject);
|
||||
}
|
||||
_pooledItemList.Clear();
|
||||
}
|
||||
public LoopGridViewItem CreateItem()
|
||||
{
|
||||
|
||||
GameObject go = GameObject.Instantiate<GameObject>(_prefabObj, Vector3.zero, Quaternion.identity, _itemParent);
|
||||
go.SetActive(true);
|
||||
RectTransform rf = go.GetComponent<RectTransform>();
|
||||
rf.localScale = Vector3.one;
|
||||
rf.anchoredPosition3D = Vector3.zero;
|
||||
rf.localEulerAngles = Vector3.zero;
|
||||
LoopGridViewItem tViewItem = go.GetComponent<LoopGridViewItem>();
|
||||
tViewItem.ItemPrefabName = _prefabName;
|
||||
tViewItem.GoId = go.GetHashCode();
|
||||
return tViewItem;
|
||||
}
|
||||
void RecycleItemReal(LoopGridViewItem item)
|
||||
{
|
||||
item.gameObject.SetActive(false);
|
||||
_pooledItemList.Add(item);
|
||||
}
|
||||
public void RecycleItem(LoopGridViewItem item)
|
||||
{
|
||||
item.PrevItem = null;
|
||||
item.NextItem = null;
|
||||
_tmpPooledItemList.Add(item);
|
||||
}
|
||||
public void ClearTmpRecycledItem()
|
||||
{
|
||||
int count = _tmpPooledItemList.Count;
|
||||
if (count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
RecycleItemReal(_tmpPooledItemList[i]);
|
||||
}
|
||||
_tmpPooledItemList.Clear();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c1eb92a17e8cee642a2245950dfaabea
|
||||
timeCreated: 1554538573
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17e9881a7bce8124a8f855b96a8ca11a
|
||||
timeCreated: 1554538573
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,184 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
|
||||
public class LoopGridViewItem : MonoBehaviour
|
||||
{
|
||||
// indicates the item’s index in the list the mItemIndex can only be from 0 to itemTotalCount -1.
|
||||
int mItemIndex = -1;
|
||||
// the row index, the item is in. starting from 0.
|
||||
int mRow = -1;
|
||||
// the column index, the item is in. starting from 0.
|
||||
int mColumn = -1;
|
||||
//indicates the item’s id.
|
||||
//This property is set when the item is created or fetched from pool,
|
||||
//and will no longer change until the item is recycled back to pool.
|
||||
int mItemId = -1;
|
||||
|
||||
private int _goId = 0;
|
||||
|
||||
public int GoId
|
||||
{
|
||||
set => _goId = value;
|
||||
get => _goId;
|
||||
}
|
||||
|
||||
LoopGridView mParentGridView = null;
|
||||
bool mIsInitHandlerCalled = false;
|
||||
string mItemPrefabName;
|
||||
RectTransform mCachedRectTransform;
|
||||
int mItemCreatedCheckFrameCount = 0;
|
||||
|
||||
object mUserObjectData = null;
|
||||
int mUserIntData1 = 0;
|
||||
int mUserIntData2 = 0;
|
||||
string mUserStringData1 = null;
|
||||
string mUserStringData2 = null;
|
||||
|
||||
LoopGridViewItem mPrevItem;
|
||||
LoopGridViewItem mNextItem;
|
||||
|
||||
public object UserObjectData
|
||||
{
|
||||
get { return mUserObjectData; }
|
||||
set { mUserObjectData = value; }
|
||||
}
|
||||
public int UserIntData1
|
||||
{
|
||||
get { return mUserIntData1; }
|
||||
set { mUserIntData1 = value; }
|
||||
}
|
||||
public int UserIntData2
|
||||
{
|
||||
get { return mUserIntData2; }
|
||||
set { mUserIntData2 = value; }
|
||||
}
|
||||
public string UserStringData1
|
||||
{
|
||||
get { return mUserStringData1; }
|
||||
set { mUserStringData1 = value; }
|
||||
}
|
||||
public string UserStringData2
|
||||
{
|
||||
get { return mUserStringData2; }
|
||||
set { mUserStringData2 = value; }
|
||||
}
|
||||
|
||||
public int ItemCreatedCheckFrameCount
|
||||
{
|
||||
get { return mItemCreatedCheckFrameCount; }
|
||||
set { mItemCreatedCheckFrameCount = value; }
|
||||
}
|
||||
|
||||
|
||||
public RectTransform CachedRectTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mCachedRectTransform == null)
|
||||
{
|
||||
mCachedRectTransform = gameObject.GetComponent<RectTransform>();
|
||||
}
|
||||
return mCachedRectTransform;
|
||||
}
|
||||
}
|
||||
|
||||
public string ItemPrefabName
|
||||
{
|
||||
get
|
||||
{
|
||||
return mItemPrefabName;
|
||||
}
|
||||
set
|
||||
{
|
||||
mItemPrefabName = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Row
|
||||
{
|
||||
get
|
||||
{
|
||||
return mRow;
|
||||
}
|
||||
set
|
||||
{
|
||||
mRow = value;
|
||||
}
|
||||
}
|
||||
public int Column
|
||||
{
|
||||
get
|
||||
{
|
||||
return mColumn;
|
||||
}
|
||||
set
|
||||
{
|
||||
mColumn = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int ItemIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return mItemIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
mItemIndex = value;
|
||||
}
|
||||
}
|
||||
public int ItemId
|
||||
{
|
||||
get
|
||||
{
|
||||
return mItemId;
|
||||
}
|
||||
set
|
||||
{
|
||||
mItemId = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool IsInitHandlerCalled
|
||||
{
|
||||
get
|
||||
{
|
||||
return mIsInitHandlerCalled;
|
||||
}
|
||||
set
|
||||
{
|
||||
mIsInitHandlerCalled = value;
|
||||
}
|
||||
}
|
||||
|
||||
public LoopGridView ParentGridView
|
||||
{
|
||||
get
|
||||
{
|
||||
return mParentGridView;
|
||||
}
|
||||
set
|
||||
{
|
||||
mParentGridView = value;
|
||||
}
|
||||
}
|
||||
|
||||
public LoopGridViewItem PrevItem
|
||||
{
|
||||
get { return mPrevItem; }
|
||||
set { mPrevItem = value; }
|
||||
}
|
||||
public LoopGridViewItem NextItem
|
||||
{
|
||||
get { return mNextItem; }
|
||||
set { mNextItem = value; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec0432517adfcb84bb6163d7a44ab8c1
|
||||
timeCreated: 1554538573
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9bbd48a4abc45c46a92b92d0df3ae07
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -8,23 +8,6 @@ using Object = UnityEngine.Object;
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
public enum ItemCornerEnum
|
||||
{
|
||||
LeftBottom = 0,
|
||||
LeftTop,
|
||||
RightTop,
|
||||
RightBottom,
|
||||
}
|
||||
|
||||
|
||||
public enum ListItemArrangeType
|
||||
{
|
||||
TopToBottom,
|
||||
BottomToTop,
|
||||
LeftToRight,
|
||||
RightToLeft,
|
||||
}
|
||||
|
||||
public class ItemPool
|
||||
{
|
||||
private GameObject _prefabObj;
|
||||
@@ -171,13 +154,6 @@ namespace GameLogic
|
||||
public delegate LoopListViewItem
|
||||
OnGetItemByIndex(LoopListView listView, int index); // System.Func<LoopListView, int, LoopListViewItem>
|
||||
|
||||
public enum SnapStatus
|
||||
{
|
||||
NoTargetSet = 0,
|
||||
TargetHasSet = 1,
|
||||
SnapMoving = 2,
|
||||
SnapMoveFinish = 3
|
||||
}
|
||||
|
||||
public class LoopListView : MonoBehaviour, IBeginDragHandler, IEndDragHandler, IDragHandler
|
||||
{
|
@@ -112,8 +112,8 @@ public static class UIExtension
|
||||
|
||||
return hadMouseDown;
|
||||
}
|
||||
|
||||
public static void SetSprite(this Image image, string spriteName, UIBase uiBase, bool isSetNativeSize = false)
|
||||
|
||||
public static void SetSprite(this Image image, string spriteName, bool isSetNativeSize = false,bool isAsync = false)
|
||||
{
|
||||
if (image == null)
|
||||
{
|
||||
@@ -126,31 +126,30 @@ public static class UIExtension
|
||||
}
|
||||
else
|
||||
{
|
||||
image.sprite = uiBase.LoadAsset<Sprite>(spriteName);
|
||||
if (isSetNativeSize)
|
||||
if (!isAsync)
|
||||
{
|
||||
image.SetNativeSize();
|
||||
image.sprite = GameModule.Resource.LoadAsset<Sprite>(spriteName);
|
||||
if (isSetNativeSize)
|
||||
{
|
||||
image.SetNativeSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetSprite(this UIBase uiBase, string spriteName, Image image, bool isSetNativeSize = false)
|
||||
{
|
||||
if (image == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(spriteName))
|
||||
{
|
||||
image.sprite = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
image.sprite = uiBase.LoadAsset<Sprite>(spriteName);
|
||||
if (isSetNativeSize)
|
||||
else
|
||||
{
|
||||
image.SetNativeSize();
|
||||
GameModule.Resource.LoadAssetAsync<Sprite>(spriteName, operation =>
|
||||
{
|
||||
if (image == null)
|
||||
{
|
||||
goto Dispose;
|
||||
}
|
||||
image.sprite = operation.AssetObject as Sprite;
|
||||
if (isSetNativeSize)
|
||||
{
|
||||
image.SetNativeSize();
|
||||
}
|
||||
Dispose:
|
||||
operation.Dispose();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,14 @@
|
||||
namespace GameLogic
|
||||
{
|
||||
public class UILoopGridItemWidget: SelectItemBase
|
||||
{
|
||||
public LoopGridViewItem LoopItem { set; get; }
|
||||
|
||||
public int Index { private set; get; }
|
||||
|
||||
public virtual void UpdateItem(int index)
|
||||
{
|
||||
Index = index;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47ee457a0d7549b3a3b5d23f4ac048cd
|
||||
timeCreated: 1692346002
|
@@ -0,0 +1,171 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// UI列表。
|
||||
/// </summary>
|
||||
public class UILoopGridWidget<TItem, TData> : UIListBase<TItem, TData> where TItem : UILoopGridItemWidget, new()
|
||||
{
|
||||
/// <summary>
|
||||
/// LoopRectView
|
||||
/// </summary>
|
||||
public LoopGridView LoopRectView { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// Item字典
|
||||
/// </summary>
|
||||
private Dictionary<int, TItem> m_itemCache = new Dictionary<int, TItem>();
|
||||
|
||||
/// <summary>
|
||||
/// 计算偏差后的ItemList
|
||||
/// </summary>
|
||||
private List<TItem> m_items = new List<TItem>();
|
||||
|
||||
/// <summary>
|
||||
/// 计算偏差后的ItemList
|
||||
/// </summary>
|
||||
public List<TItem> items => m_items;
|
||||
|
||||
public override void BindMemberProperty()
|
||||
{
|
||||
base.BindMemberProperty();
|
||||
LoopRectView = rectTransform.GetComponent<LoopGridView>();
|
||||
}
|
||||
|
||||
public override void OnCreate()
|
||||
{
|
||||
base.OnCreate();
|
||||
LoopRectView.InitGridView(0, OnGetItemByIndex);
|
||||
}
|
||||
|
||||
public override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
m_itemCache.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Item回调函数
|
||||
/// </summary>
|
||||
protected Action<TItem, int> m_tpFuncItem;
|
||||
|
||||
/// <summary>
|
||||
/// 设置显示数据
|
||||
/// </summary>
|
||||
/// <param name="n"></param>
|
||||
/// <param name="datas"></param>
|
||||
/// <param name="funcItem"></param>
|
||||
protected override void AdjustItemNum(int n, List<TData> datas = null, Action<TItem, int> funcItem = null)
|
||||
{
|
||||
base.AdjustItemNum(n, datas, funcItem);
|
||||
m_tpFuncItem = funcItem;
|
||||
LoopRectView.SetListItemCount(n);
|
||||
LoopRectView.RefreshAllShownItem();
|
||||
m_tpFuncItem = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取Item
|
||||
/// </summary>
|
||||
/// <param name="listView"></param>
|
||||
/// <param name="itemIndex"></param>
|
||||
/// <param name="row"></param>
|
||||
/// <param name="column"></param>
|
||||
/// <returns></returns>
|
||||
protected LoopGridViewItem OnGetItemByIndex(LoopGridView listView, int itemIndex,int row,int column)
|
||||
{
|
||||
if (itemIndex < 0 || itemIndex >= num) return null;
|
||||
var item = itemBase == null ? CreateItem() : CreateItem(itemBase);
|
||||
if (item == null) return null;
|
||||
item.SetItemIndex(itemIndex);
|
||||
UpdateListItem(item, itemIndex, m_tpFuncItem);
|
||||
return item.LoopItem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建Item
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public TItem CreateItem()
|
||||
{
|
||||
return CreateItem(typeof(TItem).Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建Item
|
||||
/// </summary>
|
||||
/// <param name="itemName"></param>
|
||||
/// <returns></returns>
|
||||
public TItem CreateItem(string itemName)
|
||||
{
|
||||
TItem widget = null;
|
||||
LoopGridViewItem item = LoopRectView.AllocOrNewListViewItem(itemName);
|
||||
if (item != null)
|
||||
{
|
||||
widget = CreateItem(item);
|
||||
}
|
||||
return widget;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建Item
|
||||
/// </summary>
|
||||
/// <param name="prefab"></param>
|
||||
/// <returns></returns>
|
||||
public TItem CreateItem(GameObject prefab)
|
||||
{
|
||||
TItem widget = null;
|
||||
LoopGridViewItem item = LoopRectView.AllocOrNewListViewItem(prefab);
|
||||
if (item != null)
|
||||
{
|
||||
widget = CreateItem(item);
|
||||
}
|
||||
return widget;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建Item
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
private TItem CreateItem(LoopGridViewItem item)
|
||||
{
|
||||
TItem widget;
|
||||
if (!m_itemCache.TryGetValue(item.GoId, out widget))
|
||||
{
|
||||
widget = CreateWidget<TItem>(item.gameObject);
|
||||
widget.LoopItem = item;
|
||||
m_itemCache.Add(item.GoId, widget);
|
||||
}
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取item
|
||||
/// </summary>
|
||||
/// <param name="i"></param>
|
||||
/// <returns></returns>
|
||||
public override TItem GetItem(int i)
|
||||
{
|
||||
return i >= 0 && i < m_items.Count ? m_items[i] : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取itemList
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<TItem> GetItemList()
|
||||
{
|
||||
m_items.Clear();
|
||||
for (int i = 0; i < m_itemCache.Count; i++)
|
||||
{
|
||||
m_items.Add(m_itemCache[i]);
|
||||
}
|
||||
return m_items;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0930448d067145dfb0428b248f1086ae
|
||||
timeCreated: 1692346037
|
@@ -7,7 +7,7 @@ namespace GameLogic
|
||||
/// <summary>
|
||||
/// UI列表。
|
||||
/// </summary>
|
||||
public class UILoopListWidget<ItemT, DataT> : UIListBase<ItemT, DataT> where ItemT : UILoopItemWidget, new()
|
||||
public class UILoopListWidget<TItem, TData> : UIListBase<TItem, TData> where TItem : UILoopItemWidget, new()
|
||||
{
|
||||
/// <summary>
|
||||
/// LoopRectView
|
||||
@@ -17,17 +17,17 @@ namespace GameLogic
|
||||
/// <summary>
|
||||
/// Item字典
|
||||
/// </summary>
|
||||
private Dictionary<int, ItemT> m_itemCache = new Dictionary<int, ItemT>();
|
||||
private Dictionary<int, TItem> m_itemCache = new Dictionary<int, TItem>();
|
||||
|
||||
/// <summary>
|
||||
/// 计算偏差后的ItemList
|
||||
/// </summary>
|
||||
private List<ItemT> m_items = new List<ItemT>();
|
||||
private List<TItem> m_items = new List<TItem>();
|
||||
|
||||
/// <summary>
|
||||
/// 计算偏差后的ItemList
|
||||
/// </summary>
|
||||
public List<ItemT> items => m_items;
|
||||
public List<TItem> items => m_items;
|
||||
|
||||
public override void BindMemberProperty()
|
||||
{
|
||||
@@ -50,7 +50,7 @@ namespace GameLogic
|
||||
/// <summary>
|
||||
/// Item回调函数
|
||||
/// </summary>
|
||||
protected Action<ItemT, int> m_tpFuncItem;
|
||||
protected Action<TItem, int> m_tpFuncItem;
|
||||
|
||||
/// <summary>
|
||||
/// 设置显示数据
|
||||
@@ -58,7 +58,7 @@ namespace GameLogic
|
||||
/// <param name="n"></param>
|
||||
/// <param name="datas"></param>
|
||||
/// <param name="funcItem"></param>
|
||||
protected override void AdjustItemNum(int n, List<DataT> datas = null, Action<ItemT, int> funcItem = null)
|
||||
protected override void AdjustItemNum(int n, List<TData> datas = null, Action<TItem, int> funcItem = null)
|
||||
{
|
||||
base.AdjustItemNum(n, datas, funcItem);
|
||||
m_tpFuncItem = funcItem;
|
||||
@@ -87,9 +87,9 @@ namespace GameLogic
|
||||
/// 创建Item
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ItemT CreateItem()
|
||||
public TItem CreateItem()
|
||||
{
|
||||
return CreateItem(typeof(ItemT).Name);
|
||||
return CreateItem(typeof(TItem).Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -97,9 +97,9 @@ namespace GameLogic
|
||||
/// </summary>
|
||||
/// <param name="itemName"></param>
|
||||
/// <returns></returns>
|
||||
public ItemT CreateItem(string itemName)
|
||||
public TItem CreateItem(string itemName)
|
||||
{
|
||||
ItemT widget = null;
|
||||
TItem widget = null;
|
||||
LoopListViewItem item = LoopRectView.AllocOrNewListViewItem(itemName);
|
||||
if (item != null)
|
||||
{
|
||||
@@ -113,9 +113,9 @@ namespace GameLogic
|
||||
/// </summary>
|
||||
/// <param name="prefab"></param>
|
||||
/// <returns></returns>
|
||||
public ItemT CreateItem(GameObject prefab)
|
||||
public TItem CreateItem(GameObject prefab)
|
||||
{
|
||||
ItemT widget = null;
|
||||
TItem widget = null;
|
||||
LoopListViewItem item = LoopRectView.AllocOrNewListViewItem(prefab);
|
||||
if (item != null)
|
||||
{
|
||||
@@ -129,12 +129,12 @@ namespace GameLogic
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
private ItemT CreateItem(LoopListViewItem item)
|
||||
private TItem CreateItem(LoopListViewItem item)
|
||||
{
|
||||
ItemT widget;
|
||||
TItem widget;
|
||||
if (!m_itemCache.TryGetValue(item.GoId, out widget))
|
||||
{
|
||||
widget = CreateWidget<ItemT>(item.gameObject);
|
||||
widget = CreateWidget<TItem>(item.gameObject);
|
||||
widget.LoopItem = item;
|
||||
m_itemCache.Add(item.GoId, widget);
|
||||
}
|
||||
@@ -147,7 +147,7 @@ namespace GameLogic
|
||||
/// </summary>
|
||||
/// <param name="i"></param>
|
||||
/// <returns></returns>
|
||||
public override ItemT GetItem(int i)
|
||||
public override TItem GetItem(int i)
|
||||
{
|
||||
return i >= 0 && i < m_items.Count ? m_items[i] : null;
|
||||
}
|
||||
@@ -156,7 +156,7 @@ namespace GameLogic
|
||||
/// 获取itemList
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<ItemT> GetItemList()
|
||||
public List<TItem> GetItemList()
|
||||
{
|
||||
m_items.Clear();
|
||||
for (int i = 0; i < m_itemCache.Count; i++)
|
||||
|
@@ -1,60 +1,38 @@
|
||||
using Bright.Serialization;
|
||||
using System.IO;
|
||||
using GameBase;
|
||||
using GameConfig;
|
||||
using SimpleJSON;
|
||||
using TEngine;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 配置加载器
|
||||
/// 配置加载器。
|
||||
/// </summary>
|
||||
public class ConfigLoader:Singleton<ConfigLoader>
|
||||
public class ConfigLoader : Singleton<ConfigLoader>
|
||||
{
|
||||
private bool _init = false;
|
||||
|
||||
|
||||
private Tables _tables;
|
||||
|
||||
|
||||
public Tables Tables
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_init)
|
||||
{
|
||||
_init = true;
|
||||
Load();
|
||||
}
|
||||
|
||||
return _tables;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载配置
|
||||
/// 加载配置。
|
||||
/// </summary>
|
||||
public void Load()
|
||||
{
|
||||
var tablesCtor = typeof(Tables).GetConstructors()[0];
|
||||
var loaderReturnType = tablesCtor.GetParameters()[0].ParameterType.GetGenericArguments()[1];
|
||||
|
||||
System.Delegate loader = loaderReturnType == typeof(ByteBuf)
|
||||
? new System.Func<string, ByteBuf>(LoadByteBuf)
|
||||
: (System.Delegate)new System.Func<string, JSONNode>(LoadJson);
|
||||
_tables = (Tables)tablesCtor.Invoke(new object[] { loader });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载Json配置。
|
||||
/// </summary>
|
||||
/// <param name="file">FileName</param>
|
||||
/// <returns>JSONNode</returns>
|
||||
private JSONNode LoadJson(string file)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
var ret = File.ReadAllText($"{Application.dataPath}/../GenerateDatas/json/{file}.json", System.Text.Encoding.UTF8);
|
||||
#else
|
||||
var textAssets = GameModule.Resource.LoadAsset<TextAsset>(file);
|
||||
var ret = textAssets.text;
|
||||
#endif
|
||||
return JSON.Parse(ret);
|
||||
_tables = new Tables(LoadIdxByteBuf, LoadByteBuf);
|
||||
_init = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -64,13 +42,30 @@ public class ConfigLoader:Singleton<ConfigLoader>
|
||||
/// <returns>ByteBuf</returns>
|
||||
private ByteBuf LoadByteBuf(string file)
|
||||
{
|
||||
byte[] ret = null;
|
||||
#if UNITY_EDITOR
|
||||
ret = File.ReadAllBytes($"{Application.dataPath}/../GenerateDatas/bytes/{file}.bytes");
|
||||
#else
|
||||
var textAssets = GameModule.Resource.LoadAsset<TextAsset>(file);
|
||||
ret = textAssets.bytes;
|
||||
#endif
|
||||
byte[] ret = textAssets.bytes;
|
||||
return new ByteBuf(ret);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载懒加载Index。
|
||||
/// </summary>
|
||||
/// <param name="file"></param>
|
||||
/// <returns></returns>
|
||||
private ByteBuf LoadIdxByteBuf(string file)
|
||||
{
|
||||
var textAssets = GameModule.Resource.LoadAsset<TextAsset>($"Idx_{file}");
|
||||
byte[] ret = textAssets.bytes;
|
||||
return new ByteBuf(ret);
|
||||
}
|
||||
}
|
||||
|
||||
public class ConfigSystem : BaseLogicSys<ConfigSystem>
|
||||
{
|
||||
public Tables Tables => ConfigLoader.Instance.Tables;
|
||||
|
||||
public override bool OnInit()
|
||||
{
|
||||
return base.OnInit();
|
||||
}
|
||||
}
|
@@ -7,57 +7,120 @@
|
||||
//------------------------------------------------------------------------------
|
||||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Linq;
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
|
||||
public partial class TbBuff
|
||||
{
|
||||
private readonly Dictionary<int, Battle.BuffConfig> _dataMap;
|
||||
private readonly List<Battle.BuffConfig> _dataList;
|
||||
|
||||
public TbBuff(ByteBuf _buf)
|
||||
public partial class TbBuff
|
||||
{
|
||||
_dataMap = new Dictionary<int, Battle.BuffConfig>();
|
||||
_dataList = new List<Battle.BuffConfig>();
|
||||
|
||||
for(int n = _buf.ReadSize() ; n > 0 ; --n)
|
||||
public static TbBuff Instance { get; private set; }
|
||||
private bool _readAll = false;
|
||||
private Dictionary<int, Battle.BuffConfig> _dataMap;
|
||||
private List<Battle.BuffConfig> _dataList;
|
||||
public Dictionary<int, Battle.BuffConfig> DataMap
|
||||
{
|
||||
get
|
||||
{
|
||||
if(!_readAll)
|
||||
{
|
||||
ReadAll();
|
||||
_readAll = true;
|
||||
}
|
||||
return _dataMap;
|
||||
}
|
||||
}
|
||||
public List<Battle.BuffConfig> DataList
|
||||
{
|
||||
get
|
||||
{
|
||||
if(!_readAll)
|
||||
{
|
||||
ReadAll();
|
||||
_readAll = true;
|
||||
}
|
||||
return _dataList;
|
||||
}
|
||||
}
|
||||
private Dictionary<int,int> _indexMap;
|
||||
public List<int> Indexes;
|
||||
private System.Func<ByteBuf> _dataLoader;
|
||||
|
||||
private void ReadAll()
|
||||
{
|
||||
_dataList.Clear();
|
||||
foreach(var index in Indexes)
|
||||
{
|
||||
var v = Get(index);
|
||||
_dataMap[index] = v;
|
||||
_dataList.Add(v);
|
||||
}
|
||||
}
|
||||
|
||||
public TbBuff(ByteBuf _buf, string _tbName, System.Func<string, ByteBuf> _loader)
|
||||
{
|
||||
Instance = this;
|
||||
_dataMap = new Dictionary<int, Battle.BuffConfig>();
|
||||
_dataList = new List<Battle.BuffConfig>();
|
||||
_indexMap = new Dictionary<int, int>();
|
||||
_dataLoader = new System.Func<ByteBuf>(() => _loader(_tbName));
|
||||
|
||||
for (int n = _buf.ReadSize(); n > 0; --n)
|
||||
{
|
||||
int key;
|
||||
key = _buf.ReadInt();
|
||||
int index = _buf.ReadInt();
|
||||
_indexMap[key] = index;
|
||||
}
|
||||
Indexes = _indexMap.Keys.ToList();
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public Battle.BuffConfig this[int key] => Get(key);
|
||||
public Battle.BuffConfig Get(int key)
|
||||
{
|
||||
Battle.BuffConfig _v;
|
||||
if(_dataMap.TryGetValue(key, out _v))
|
||||
{
|
||||
return _v;
|
||||
}
|
||||
ResetByteBuf(_indexMap[key]);
|
||||
_v = Battle.BuffConfig.DeserializeBuffConfig(_buf);
|
||||
_dataList.Add(_v);
|
||||
_dataMap.Add(_v.BuffID, _v);
|
||||
_dataMap[_v.BuffID] = _v;
|
||||
_v.Resolve(tables);
|
||||
if(_indexMap.Count == _dataMap.Count)
|
||||
{
|
||||
_buf = null;
|
||||
}
|
||||
return _v;
|
||||
}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public Dictionary<int, Battle.BuffConfig> DataMap => _dataMap;
|
||||
public List<Battle.BuffConfig> DataList => _dataList;
|
||||
|
||||
public Battle.BuffConfig GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : null;
|
||||
public Battle.BuffConfig Get(int key) => _dataMap[key];
|
||||
public Battle.BuffConfig this[int key] => _dataMap[key];
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
public Battle.BuffConfig GetOrDefault(int key)
|
||||
{
|
||||
v.Resolve(_tables);
|
||||
if(_indexMap.TryGetValue(key,out var _))
|
||||
{
|
||||
return Get(key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
|
||||
private void ResetByteBuf(int readerInex = 0)
|
||||
{
|
||||
v.TranslateText(translator);
|
||||
if( _buf == null)
|
||||
{
|
||||
if (_buf == null)
|
||||
{
|
||||
_buf = _dataLoader();
|
||||
}
|
||||
}
|
||||
_buf.ReaderIndex = readerInex;
|
||||
}
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
}
|
||||
private ByteBuf _buf = null;
|
||||
private Dictionary<string, object> tables;
|
||||
public void CacheTables(Dictionary<string, object> _tables)
|
||||
{
|
||||
tables = _tables;
|
||||
}
|
||||
partial void PostInit();
|
||||
}
|
||||
}
|
@@ -7,57 +7,120 @@
|
||||
//------------------------------------------------------------------------------
|
||||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Linq;
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
|
||||
public partial class TbBuffAttr
|
||||
{
|
||||
private readonly Dictionary<int, Battle.BuffAttrConfig> _dataMap;
|
||||
private readonly List<Battle.BuffAttrConfig> _dataList;
|
||||
|
||||
public TbBuffAttr(ByteBuf _buf)
|
||||
public partial class TbBuffAttr
|
||||
{
|
||||
_dataMap = new Dictionary<int, Battle.BuffAttrConfig>();
|
||||
_dataList = new List<Battle.BuffAttrConfig>();
|
||||
|
||||
for(int n = _buf.ReadSize() ; n > 0 ; --n)
|
||||
public static TbBuffAttr Instance { get; private set; }
|
||||
private bool _readAll = false;
|
||||
private Dictionary<int, Battle.BuffAttrConfig> _dataMap;
|
||||
private List<Battle.BuffAttrConfig> _dataList;
|
||||
public Dictionary<int, Battle.BuffAttrConfig> DataMap
|
||||
{
|
||||
get
|
||||
{
|
||||
if(!_readAll)
|
||||
{
|
||||
ReadAll();
|
||||
_readAll = true;
|
||||
}
|
||||
return _dataMap;
|
||||
}
|
||||
}
|
||||
public List<Battle.BuffAttrConfig> DataList
|
||||
{
|
||||
get
|
||||
{
|
||||
if(!_readAll)
|
||||
{
|
||||
ReadAll();
|
||||
_readAll = true;
|
||||
}
|
||||
return _dataList;
|
||||
}
|
||||
}
|
||||
private Dictionary<int,int> _indexMap;
|
||||
public List<int> Indexes;
|
||||
private System.Func<ByteBuf> _dataLoader;
|
||||
|
||||
private void ReadAll()
|
||||
{
|
||||
_dataList.Clear();
|
||||
foreach(var index in Indexes)
|
||||
{
|
||||
var v = Get(index);
|
||||
_dataMap[index] = v;
|
||||
_dataList.Add(v);
|
||||
}
|
||||
}
|
||||
|
||||
public TbBuffAttr(ByteBuf _buf, string _tbName, System.Func<string, ByteBuf> _loader)
|
||||
{
|
||||
Instance = this;
|
||||
_dataMap = new Dictionary<int, Battle.BuffAttrConfig>();
|
||||
_dataList = new List<Battle.BuffAttrConfig>();
|
||||
_indexMap = new Dictionary<int, int>();
|
||||
_dataLoader = new System.Func<ByteBuf>(() => _loader(_tbName));
|
||||
|
||||
for (int n = _buf.ReadSize(); n > 0; --n)
|
||||
{
|
||||
int key;
|
||||
key = _buf.ReadInt();
|
||||
int index = _buf.ReadInt();
|
||||
_indexMap[key] = index;
|
||||
}
|
||||
Indexes = _indexMap.Keys.ToList();
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public Battle.BuffAttrConfig this[int key] => Get(key);
|
||||
public Battle.BuffAttrConfig Get(int key)
|
||||
{
|
||||
Battle.BuffAttrConfig _v;
|
||||
if(_dataMap.TryGetValue(key, out _v))
|
||||
{
|
||||
return _v;
|
||||
}
|
||||
ResetByteBuf(_indexMap[key]);
|
||||
_v = Battle.BuffAttrConfig.DeserializeBuffAttrConfig(_buf);
|
||||
_dataList.Add(_v);
|
||||
_dataMap.Add(_v.BuffID, _v);
|
||||
_dataMap[_v.BuffID] = _v;
|
||||
_v.Resolve(tables);
|
||||
if(_indexMap.Count == _dataMap.Count)
|
||||
{
|
||||
_buf = null;
|
||||
}
|
||||
return _v;
|
||||
}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public Dictionary<int, Battle.BuffAttrConfig> DataMap => _dataMap;
|
||||
public List<Battle.BuffAttrConfig> DataList => _dataList;
|
||||
|
||||
public Battle.BuffAttrConfig GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : null;
|
||||
public Battle.BuffAttrConfig Get(int key) => _dataMap[key];
|
||||
public Battle.BuffAttrConfig this[int key] => _dataMap[key];
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
public Battle.BuffAttrConfig GetOrDefault(int key)
|
||||
{
|
||||
v.Resolve(_tables);
|
||||
if(_indexMap.TryGetValue(key,out var _))
|
||||
{
|
||||
return Get(key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
|
||||
private void ResetByteBuf(int readerInex = 0)
|
||||
{
|
||||
v.TranslateText(translator);
|
||||
if( _buf == null)
|
||||
{
|
||||
if (_buf == null)
|
||||
{
|
||||
_buf = _dataLoader();
|
||||
}
|
||||
}
|
||||
_buf.ReaderIndex = readerInex;
|
||||
}
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
}
|
||||
private ByteBuf _buf = null;
|
||||
private Dictionary<string, object> tables;
|
||||
public void CacheTables(Dictionary<string, object> _tables)
|
||||
{
|
||||
tables = _tables;
|
||||
}
|
||||
partial void PostInit();
|
||||
}
|
||||
}
|
@@ -7,57 +7,120 @@
|
||||
//------------------------------------------------------------------------------
|
||||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Linq;
|
||||
|
||||
namespace GameConfig.Battle
|
||||
{
|
||||
|
||||
public partial class TbSkill
|
||||
{
|
||||
private readonly Dictionary<int, Battle.SkillBaseConfig> _dataMap;
|
||||
private readonly List<Battle.SkillBaseConfig> _dataList;
|
||||
|
||||
public TbSkill(ByteBuf _buf)
|
||||
public partial class TbSkill
|
||||
{
|
||||
_dataMap = new Dictionary<int, Battle.SkillBaseConfig>();
|
||||
_dataList = new List<Battle.SkillBaseConfig>();
|
||||
|
||||
for(int n = _buf.ReadSize() ; n > 0 ; --n)
|
||||
public static TbSkill Instance { get; private set; }
|
||||
private bool _readAll = false;
|
||||
private Dictionary<int, Battle.SkillBaseConfig> _dataMap;
|
||||
private List<Battle.SkillBaseConfig> _dataList;
|
||||
public Dictionary<int, Battle.SkillBaseConfig> DataMap
|
||||
{
|
||||
get
|
||||
{
|
||||
if(!_readAll)
|
||||
{
|
||||
ReadAll();
|
||||
_readAll = true;
|
||||
}
|
||||
return _dataMap;
|
||||
}
|
||||
}
|
||||
public List<Battle.SkillBaseConfig> DataList
|
||||
{
|
||||
get
|
||||
{
|
||||
if(!_readAll)
|
||||
{
|
||||
ReadAll();
|
||||
_readAll = true;
|
||||
}
|
||||
return _dataList;
|
||||
}
|
||||
}
|
||||
private Dictionary<int,int> _indexMap;
|
||||
public List<int> Indexes;
|
||||
private System.Func<ByteBuf> _dataLoader;
|
||||
|
||||
private void ReadAll()
|
||||
{
|
||||
_dataList.Clear();
|
||||
foreach(var index in Indexes)
|
||||
{
|
||||
var v = Get(index);
|
||||
_dataMap[index] = v;
|
||||
_dataList.Add(v);
|
||||
}
|
||||
}
|
||||
|
||||
public TbSkill(ByteBuf _buf, string _tbName, System.Func<string, ByteBuf> _loader)
|
||||
{
|
||||
Instance = this;
|
||||
_dataMap = new Dictionary<int, Battle.SkillBaseConfig>();
|
||||
_dataList = new List<Battle.SkillBaseConfig>();
|
||||
_indexMap = new Dictionary<int, int>();
|
||||
_dataLoader = new System.Func<ByteBuf>(() => _loader(_tbName));
|
||||
|
||||
for (int n = _buf.ReadSize(); n > 0; --n)
|
||||
{
|
||||
int key;
|
||||
key = _buf.ReadInt();
|
||||
int index = _buf.ReadInt();
|
||||
_indexMap[key] = index;
|
||||
}
|
||||
Indexes = _indexMap.Keys.ToList();
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public Battle.SkillBaseConfig this[int key] => Get(key);
|
||||
public Battle.SkillBaseConfig Get(int key)
|
||||
{
|
||||
Battle.SkillBaseConfig _v;
|
||||
if(_dataMap.TryGetValue(key, out _v))
|
||||
{
|
||||
return _v;
|
||||
}
|
||||
ResetByteBuf(_indexMap[key]);
|
||||
_v = Battle.SkillBaseConfig.DeserializeSkillBaseConfig(_buf);
|
||||
_dataList.Add(_v);
|
||||
_dataMap.Add(_v.Id, _v);
|
||||
_dataMap[_v.Id] = _v;
|
||||
_v.Resolve(tables);
|
||||
if(_indexMap.Count == _dataMap.Count)
|
||||
{
|
||||
_buf = null;
|
||||
}
|
||||
return _v;
|
||||
}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public Dictionary<int, Battle.SkillBaseConfig> DataMap => _dataMap;
|
||||
public List<Battle.SkillBaseConfig> DataList => _dataList;
|
||||
|
||||
public Battle.SkillBaseConfig GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : null;
|
||||
public Battle.SkillBaseConfig Get(int key) => _dataMap[key];
|
||||
public Battle.SkillBaseConfig this[int key] => _dataMap[key];
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
public Battle.SkillBaseConfig GetOrDefault(int key)
|
||||
{
|
||||
v.Resolve(_tables);
|
||||
if(_indexMap.TryGetValue(key,out var _))
|
||||
{
|
||||
return Get(key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
|
||||
private void ResetByteBuf(int readerInex = 0)
|
||||
{
|
||||
v.TranslateText(translator);
|
||||
if( _buf == null)
|
||||
{
|
||||
if (_buf == null)
|
||||
{
|
||||
_buf = _dataLoader();
|
||||
}
|
||||
}
|
||||
_buf.ReaderIndex = readerInex;
|
||||
}
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
}
|
||||
private ByteBuf _buf = null;
|
||||
private Dictionary<string, object> tables;
|
||||
public void CacheTables(Dictionary<string, object> _tables)
|
||||
{
|
||||
tables = _tables;
|
||||
}
|
||||
partial void PostInit();
|
||||
}
|
||||
}
|
@@ -8,9 +8,9 @@
|
||||
using Bright.Serialization;
|
||||
|
||||
|
||||
|
||||
namespace GameConfig
|
||||
{
|
||||
{
|
||||
|
||||
public partial class Tables
|
||||
{
|
||||
public item.TbItem TbItem {get; }
|
||||
@@ -18,36 +18,26 @@ public partial class Tables
|
||||
public Battle.TbBuff TbBuff {get; }
|
||||
public Battle.TbBuffAttr TbBuffAttr {get; }
|
||||
|
||||
public Tables(System.Func<string, ByteBuf> loader)
|
||||
public Tables(System.Func<string, ByteBuf> idxLoader,System.Func<string, ByteBuf> dataLoader)
|
||||
{
|
||||
var tables = new System.Collections.Generic.Dictionary<string, object>();
|
||||
TbItem = new item.TbItem(loader("item_tbitem"));
|
||||
TbItem = new item.TbItem(idxLoader("item_tbitem"),"item_tbitem",dataLoader);
|
||||
tables.Add("item.TbItem", TbItem);
|
||||
TbSkill = new Battle.TbSkill(loader("battle_tbskill"));
|
||||
TbSkill = new Battle.TbSkill(idxLoader("battle_tbskill"),"battle_tbskill",dataLoader);
|
||||
tables.Add("Battle.TbSkill", TbSkill);
|
||||
TbBuff = new Battle.TbBuff(loader("battle_tbbuff"));
|
||||
TbBuff = new Battle.TbBuff(idxLoader("battle_tbbuff"),"battle_tbbuff",dataLoader);
|
||||
tables.Add("Battle.TbBuff", TbBuff);
|
||||
TbBuffAttr = new Battle.TbBuffAttr(loader("battle_tbbuffattr"));
|
||||
TbBuffAttr = new Battle.TbBuffAttr(idxLoader("battle_tbbuffattr"),"battle_tbbuffattr",dataLoader);
|
||||
tables.Add("Battle.TbBuffAttr", TbBuffAttr);
|
||||
|
||||
PostInit();
|
||||
TbItem.Resolve(tables);
|
||||
TbSkill.Resolve(tables);
|
||||
TbBuff.Resolve(tables);
|
||||
TbBuffAttr.Resolve(tables);
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
TbItem.TranslateText(translator);
|
||||
TbSkill.TranslateText(translator);
|
||||
TbBuff.TranslateText(translator);
|
||||
TbBuffAttr.TranslateText(translator);
|
||||
TbItem.CacheTables(tables);
|
||||
TbSkill.CacheTables(tables);
|
||||
TbBuff.CacheTables(tables);
|
||||
TbBuffAttr.CacheTables(tables);
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
}
|
@@ -7,57 +7,120 @@
|
||||
//------------------------------------------------------------------------------
|
||||
using Bright.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Linq;
|
||||
|
||||
namespace GameConfig.item
|
||||
{
|
||||
|
||||
public partial class TbItem
|
||||
{
|
||||
private readonly Dictionary<int, item.Item> _dataMap;
|
||||
private readonly List<item.Item> _dataList;
|
||||
|
||||
public TbItem(ByteBuf _buf)
|
||||
public partial class TbItem
|
||||
{
|
||||
_dataMap = new Dictionary<int, item.Item>();
|
||||
_dataList = new List<item.Item>();
|
||||
|
||||
for(int n = _buf.ReadSize() ; n > 0 ; --n)
|
||||
public static TbItem Instance { get; private set; }
|
||||
private bool _readAll = false;
|
||||
private Dictionary<int, item.Item> _dataMap;
|
||||
private List<item.Item> _dataList;
|
||||
public Dictionary<int, item.Item> DataMap
|
||||
{
|
||||
get
|
||||
{
|
||||
if(!_readAll)
|
||||
{
|
||||
ReadAll();
|
||||
_readAll = true;
|
||||
}
|
||||
return _dataMap;
|
||||
}
|
||||
}
|
||||
public List<item.Item> DataList
|
||||
{
|
||||
get
|
||||
{
|
||||
if(!_readAll)
|
||||
{
|
||||
ReadAll();
|
||||
_readAll = true;
|
||||
}
|
||||
return _dataList;
|
||||
}
|
||||
}
|
||||
private Dictionary<int,int> _indexMap;
|
||||
public List<int> Indexes;
|
||||
private System.Func<ByteBuf> _dataLoader;
|
||||
|
||||
private void ReadAll()
|
||||
{
|
||||
_dataList.Clear();
|
||||
foreach(var index in Indexes)
|
||||
{
|
||||
var v = Get(index);
|
||||
_dataMap[index] = v;
|
||||
_dataList.Add(v);
|
||||
}
|
||||
}
|
||||
|
||||
public TbItem(ByteBuf _buf, string _tbName, System.Func<string, ByteBuf> _loader)
|
||||
{
|
||||
Instance = this;
|
||||
_dataMap = new Dictionary<int, item.Item>();
|
||||
_dataList = new List<item.Item>();
|
||||
_indexMap = new Dictionary<int, int>();
|
||||
_dataLoader = new System.Func<ByteBuf>(() => _loader(_tbName));
|
||||
|
||||
for (int n = _buf.ReadSize(); n > 0; --n)
|
||||
{
|
||||
int key;
|
||||
key = _buf.ReadInt();
|
||||
int index = _buf.ReadInt();
|
||||
_indexMap[key] = index;
|
||||
}
|
||||
Indexes = _indexMap.Keys.ToList();
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public item.Item this[int key] => Get(key);
|
||||
public item.Item Get(int key)
|
||||
{
|
||||
item.Item _v;
|
||||
if(_dataMap.TryGetValue(key, out _v))
|
||||
{
|
||||
return _v;
|
||||
}
|
||||
ResetByteBuf(_indexMap[key]);
|
||||
_v = item.Item.DeserializeItem(_buf);
|
||||
_dataList.Add(_v);
|
||||
_dataMap.Add(_v.Id, _v);
|
||||
_dataMap[_v.Id] = _v;
|
||||
_v.Resolve(tables);
|
||||
if(_indexMap.Count == _dataMap.Count)
|
||||
{
|
||||
_buf = null;
|
||||
}
|
||||
return _v;
|
||||
}
|
||||
PostInit();
|
||||
}
|
||||
|
||||
public Dictionary<int, item.Item> DataMap => _dataMap;
|
||||
public List<item.Item> DataList => _dataList;
|
||||
|
||||
public item.Item GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : null;
|
||||
public item.Item Get(int key) => _dataMap[key];
|
||||
public item.Item this[int key] => _dataMap[key];
|
||||
|
||||
public void Resolve(Dictionary<string, object> _tables)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
public item.Item GetOrDefault(int key)
|
||||
{
|
||||
v.Resolve(_tables);
|
||||
if(_indexMap.TryGetValue(key,out var _))
|
||||
{
|
||||
return Get(key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
PostResolve();
|
||||
}
|
||||
|
||||
public void TranslateText(System.Func<string, string, string> translator)
|
||||
{
|
||||
foreach(var v in _dataList)
|
||||
|
||||
private void ResetByteBuf(int readerInex = 0)
|
||||
{
|
||||
v.TranslateText(translator);
|
||||
if( _buf == null)
|
||||
{
|
||||
if (_buf == null)
|
||||
{
|
||||
_buf = _dataLoader();
|
||||
}
|
||||
}
|
||||
_buf.ReaderIndex = readerInex;
|
||||
}
|
||||
}
|
||||
|
||||
partial void PostInit();
|
||||
partial void PostResolve();
|
||||
}
|
||||
|
||||
}
|
||||
private ByteBuf _buf = null;
|
||||
private Dictionary<string, object> tables;
|
||||
public void CacheTables(Dictionary<string, object> _tables)
|
||||
{
|
||||
tables = _tables;
|
||||
}
|
||||
partial void PostInit();
|
||||
}
|
||||
}
|
@@ -77,11 +77,11 @@ namespace GameMain
|
||||
|
||||
private void InitSoundSettings()
|
||||
{
|
||||
GameModule.Audio.MusicEnable = GameModule.Setting.GetBool(Constant.Setting.MusicMuted, false);
|
||||
GameModule.Audio.MusicVolume = GameModule.Setting.GetFloat(Constant.Setting.MusicVolume, 0.3f);
|
||||
GameModule.Audio.SoundEnable = GameModule.Setting.GetBool(Constant.Setting.SoundMuted, false);
|
||||
GameModule.Audio.MusicEnable = !GameModule.Setting.GetBool(Constant.Setting.MusicMuted, false);
|
||||
GameModule.Audio.MusicVolume = GameModule.Setting.GetFloat(Constant.Setting.MusicVolume, 1f);
|
||||
GameModule.Audio.SoundEnable = !GameModule.Setting.GetBool(Constant.Setting.SoundMuted, false);
|
||||
GameModule.Audio.SoundVolume = GameModule.Setting.GetFloat(Constant.Setting.SoundVolume, 1f);
|
||||
GameModule.Audio.UISoundEnable = GameModule.Setting.GetBool(Constant.Setting.UISoundMuted, false);
|
||||
GameModule.Audio.UISoundEnable = !GameModule.Setting.GetBool(Constant.Setting.UISoundMuted, false);
|
||||
GameModule.Audio.UISoundVolume = GameModule.Setting.GetFloat(Constant.Setting.UISoundVolume, 1f);
|
||||
Log.Info("Init sound settings complete.");
|
||||
}
|
||||
|
15
Assets/TEngine/Editor/GameSettings/SynAssemblysContent.cs
Normal file
15
Assets/TEngine/Editor/GameSettings/SynAssemblysContent.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public static class SyncAssemblyContent
|
||||
{
|
||||
public static void RefreshAssembly()
|
||||
{
|
||||
SettingsUtils.SetHybridCLRHotUpdateAssemblies(HybridCLR.Editor.SettingsUtil.HotUpdateAssemblyFilesIncludePreserved);
|
||||
SettingsUtils.SetHybridCLRAOTMetaAssemblies(HybridCLR.Editor.SettingsUtil.AOTAssemblyNames);
|
||||
SettingsUtils.HybridCLRCustomGlobalSettings.Enable = HybridCLR.Editor.SettingsUtil.Enable;
|
||||
AssetDatabase.Refresh();
|
||||
AssetDatabase.SaveAssets();
|
||||
Debug.Log("同步AOT和HotUpdate程序集 HybridCLR到TEngineSettings成功。");
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04407344026702f4ebd61f63c8a35c69
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -2,6 +2,7 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine.UIElements;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class TEngineSettingsProvider : SettingsProvider
|
||||
{
|
||||
@@ -30,6 +31,14 @@ public class TEngineSettingsProvider : SettingsProvider
|
||||
base.OnGUI(searchContext);
|
||||
using var changeCheckScope = new EditorGUI.ChangeCheckScope();
|
||||
EditorGUILayout.PropertyField(m_CustomSettings.FindProperty("m_FrameworkGlobalSettings"));
|
||||
|
||||
if ( GUILayout.Button( "Refresh HotUpdateAssemblies" ) )
|
||||
{
|
||||
SyncAssemblyContent.RefreshAssembly();
|
||||
m_CustomSettings.ApplyModifiedPropertiesWithoutUndo();
|
||||
m_CustomSettings = null;
|
||||
m_CustomSettings = GetSerializedSettings();
|
||||
}
|
||||
EditorGUILayout.PropertyField(m_CustomSettings.FindProperty("m_BybridCLRCustomGlobalSettings"));
|
||||
EditorGUILayout.Space(20);
|
||||
if (!changeCheckScope.changed) return;
|
||||
@@ -51,7 +60,7 @@ public class TEngineSettingsProvider : SettingsProvider
|
||||
}
|
||||
else
|
||||
{
|
||||
UnityEngine.Debug.LogError($"Open GameFramework Settings error,Please Create Game Framework/GameFrameworkSettings.assets File in Path GameMain/Resources/Settings");
|
||||
UnityEngine.Debug.LogError($"Open TEngine Settings error,Please Create TEngine TEngineGlobalSettings.assets File in Path TEngine/ResRaw/Resources/");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user