mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
GameScripts
GameScripts
This commit is contained in:
8
Assets/GameScripts.meta
Normal file
8
Assets/GameScripts.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e350730b37a348a4ab35189c9739c329
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/GameScripts/HotFix.meta
Normal file
8
Assets/GameScripts/HotFix.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 44b1c38e059de6542b6cd33d7258f415
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/GameScripts/HotFix/BattleCore.meta
Normal file
8
Assets/GameScripts/HotFix/BattleCore.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b6b7bfca93e005f45999c16054d999e7
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"name": "BattleCore.Runtime",
|
||||||
|
"rootNamespace": "BattleCore.Runtime",
|
||||||
|
"references": [
|
||||||
|
"GUID:b48be955427611241bcb6f2a07949c5b",
|
||||||
|
"GUID:aa06d4cc755c979489c256c1bcca1dfb"
|
||||||
|
],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 641632c4f8079b94f963b5284d859a12
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/GameScripts/HotFix/GameBase.meta
Normal file
8
Assets/GameScripts/HotFix/GameBase.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 26079995c20c1b144a1c086bf2869375
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
16
Assets/GameScripts/HotFix/GameBase/BaseClsTemplate.cs
Normal file
16
Assets/GameScripts/HotFix/GameBase/BaseClsTemplate.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
namespace GameBase
|
||||||
|
{
|
||||||
|
public class BaseClsTemplate<T>
|
||||||
|
{
|
||||||
|
protected static T Imp;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unity工程,注册处理函数。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="imp">实现类。</param>
|
||||||
|
public static void RegisterImp(T imp)
|
||||||
|
{
|
||||||
|
Imp = imp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/GameScripts/HotFix/GameBase/BaseClsTemplate.cs.meta
Normal file
11
Assets/GameScripts/HotFix/GameBase/BaseClsTemplate.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bb7ef2f42b33ada47b3543dc7723fcb5
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
16
Assets/GameScripts/HotFix/GameBase/GameBase.asmdef
Normal file
16
Assets/GameScripts/HotFix/GameBase/GameBase.asmdef
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"name": "GameBase",
|
||||||
|
"rootNamespace": "GameBase",
|
||||||
|
"references": [
|
||||||
|
"GUID:aa06d4cc755c979489c256c1bcca1dfb"
|
||||||
|
],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
7
Assets/GameScripts/HotFix/GameBase/GameBase.asmdef.meta
Normal file
7
Assets/GameScripts/HotFix/GameBase/GameBase.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 08c3762f54316454ca6b6fbcb22b40e5
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
52
Assets/GameScripts/HotFix/GameBase/ILogicSys.cs
Normal file
52
Assets/GameScripts/HotFix/GameBase/ILogicSys.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/// <summary>
|
||||||
|
/// 定义通用的逻辑接口,统一生命期调用
|
||||||
|
/// </summary>
|
||||||
|
public interface ILogicSys
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化接口
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool OnInit();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 销毁系统
|
||||||
|
/// </summary>
|
||||||
|
void OnDestroy();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化后,第一帧统一调用
|
||||||
|
/// </summary>
|
||||||
|
void OnStart();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新接口
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
void OnUpdate();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 渲染后调用
|
||||||
|
/// </summary>
|
||||||
|
void OnLateUpdate();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物理帧更新
|
||||||
|
/// </summary>
|
||||||
|
void OnFixedUpdate();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理数据接口,切换账号/角色时调用
|
||||||
|
/// </summary>
|
||||||
|
void OnRoleLogout();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// OnDrawGizmos
|
||||||
|
/// </summary>
|
||||||
|
void OnDrawGizmos();
|
||||||
|
/// <summary>
|
||||||
|
/// 暂停游戏
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pause"></param>
|
||||||
|
void OnApplicationPause(bool pause);
|
||||||
|
}
|
3
Assets/GameScripts/HotFix/GameBase/ILogicSys.cs.meta
Normal file
3
Assets/GameScripts/HotFix/GameBase/ILogicSys.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 63ff6535a43f41d7ac793b8a153a37b6
|
||||||
|
timeCreated: 1681213932
|
23
Assets/GameScripts/HotFix/GameBase/Singleton.cs
Normal file
23
Assets/GameScripts/HotFix/GameBase/Singleton.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using TEngine;
|
||||||
|
|
||||||
|
namespace GameBase
|
||||||
|
{
|
||||||
|
public class Singleton<T> where T:new()
|
||||||
|
{
|
||||||
|
private static T _instance;
|
||||||
|
public static T Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (null == _instance)
|
||||||
|
{
|
||||||
|
_instance = new T();
|
||||||
|
Log.Assert(_instance != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
3
Assets/GameScripts/HotFix/GameBase/Singleton.cs.meta
Normal file
3
Assets/GameScripts/HotFix/GameBase/Singleton.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b68a449df312429cbb27873984ec238e
|
||||||
|
timeCreated: 1681214042
|
8
Assets/GameScripts/HotFix/GameLogic.meta
Normal file
8
Assets/GameScripts/HotFix/GameLogic.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f8ea72f19248ebd4e817160319583cac
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
120
Assets/GameScripts/HotFix/GameLogic/GameApp.cs
Normal file
120
Assets/GameScripts/HotFix/GameLogic/GameApp.cs
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
using GameBase;
|
||||||
|
using TEngine;
|
||||||
|
|
||||||
|
public partial class GameApp:Singleton<GameApp>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 热更域App主入口。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="objects"></param>
|
||||||
|
public static void Entrance(object[] objects)
|
||||||
|
{
|
||||||
|
Log.Warning("======= 看到此条日志代表你成功运行了热更新代码 =======");
|
||||||
|
Log.Warning("======= Entrance GameApp =======");
|
||||||
|
Instance.Init();
|
||||||
|
Instance.Start();
|
||||||
|
Utility.Unity.AddUpdateListener(Instance.Update);
|
||||||
|
Utility.Unity.AddFixedUpdateListener(Instance.FixedUpdate);
|
||||||
|
Utility.Unity.AddLateUpdateListener(Instance.LateUpdate);
|
||||||
|
Utility.Unity.AddDestroyListener(Instance.OnDestroy);
|
||||||
|
Utility.Unity.AddOnDrawGizmosListener(Instance.OnDrawGizmos);
|
||||||
|
Utility.Unity.AddOnApplicationPauseListener(Instance.OnApplicationPause);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
GameTime.StartFrame();
|
||||||
|
var listLogic = m_listLogicMgr;
|
||||||
|
var logicCnt = listLogic.Count;
|
||||||
|
for (int i = 0; i < logicCnt; i++)
|
||||||
|
{
|
||||||
|
var logic = listLogic[i];
|
||||||
|
logic.OnStart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
GameTime.StartFrame();
|
||||||
|
TProfiler.BeginFirstSample("Update");
|
||||||
|
var listLogic = m_listLogicMgr;
|
||||||
|
var logicCnt = listLogic.Count;
|
||||||
|
for (int i = 0; i < logicCnt; i++)
|
||||||
|
{
|
||||||
|
var logic = listLogic[i];
|
||||||
|
TProfiler.BeginSample(logic.GetType().FullName);
|
||||||
|
logic.OnUpdate();
|
||||||
|
TProfiler.EndSample();
|
||||||
|
}
|
||||||
|
TProfiler.EndFirstSample();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FixedUpdate()
|
||||||
|
{
|
||||||
|
GameTime.StartFrame();
|
||||||
|
TProfiler.BeginFirstSample("FixedUpdate");
|
||||||
|
var listLogic = m_listLogicMgr;
|
||||||
|
var logicCnt = listLogic.Count;
|
||||||
|
for (int i = 0; i < logicCnt; i++)
|
||||||
|
{
|
||||||
|
var logic = listLogic[i];
|
||||||
|
TProfiler.BeginSample(logic.GetType().FullName);
|
||||||
|
logic.OnFixedUpdate();
|
||||||
|
TProfiler.EndSample();
|
||||||
|
}
|
||||||
|
TProfiler.EndFirstSample();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LateUpdate()
|
||||||
|
{
|
||||||
|
GameTime.StartFrame();
|
||||||
|
TProfiler.BeginFirstSample("LateUpdate");
|
||||||
|
var listLogic = m_listLogicMgr;
|
||||||
|
var logicCnt = listLogic.Count;
|
||||||
|
for (int i = 0; i < logicCnt; i++)
|
||||||
|
{
|
||||||
|
var logic = listLogic[i];
|
||||||
|
TProfiler.BeginSample(logic.GetType().FullName);
|
||||||
|
logic.OnLateUpdate();
|
||||||
|
TProfiler.EndSample();
|
||||||
|
}
|
||||||
|
TProfiler.EndFirstSample();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
GameTime.StartFrame();
|
||||||
|
var listLogic = m_listLogicMgr;
|
||||||
|
var logicCnt = listLogic.Count;
|
||||||
|
for (int i = 0; i < logicCnt; i++)
|
||||||
|
{
|
||||||
|
var logic = listLogic[i];
|
||||||
|
logic.OnDestroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDrawGizmos()
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
GameTime.StartFrame();
|
||||||
|
var listLogic = m_listLogicMgr;
|
||||||
|
var logicCnt = listLogic.Count;
|
||||||
|
for (int i = 0; i < logicCnt; i++)
|
||||||
|
{
|
||||||
|
var logic = listLogic[i];
|
||||||
|
logic.OnDrawGizmos();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnApplicationPause(bool isPause)
|
||||||
|
{
|
||||||
|
var listLogic = m_listLogicMgr;
|
||||||
|
var logicCnt = listLogic.Count;
|
||||||
|
for (int i = 0; i < logicCnt; i++)
|
||||||
|
{
|
||||||
|
var logic = listLogic[i];
|
||||||
|
logic.OnApplicationPause(isPause);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/GameScripts/HotFix/GameLogic/GameApp.cs.meta
Normal file
11
Assets/GameScripts/HotFix/GameLogic/GameApp.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b5fabb458720ae14bbdb4d781d4ef34e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@@ -0,0 +1,55 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using TEngine;
|
||||||
|
|
||||||
|
public partial class GameApp
|
||||||
|
{
|
||||||
|
private List<ILogicSys> m_listLogicMgr;
|
||||||
|
|
||||||
|
private void Init()
|
||||||
|
{
|
||||||
|
m_listLogicMgr = new List<ILogicSys>();
|
||||||
|
RegisterAllSystem();
|
||||||
|
InitSystemSetting();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置一些通用的系统属性。
|
||||||
|
/// </summary>
|
||||||
|
private void InitSystemSetting()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 注册所有逻辑系统
|
||||||
|
/// </summary>
|
||||||
|
private void RegisterAllSystem()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 注册逻辑系统。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="logicSys">ILogicSys</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
protected bool AddLogicSys(ILogicSys logicSys)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (m_listLogicMgr.Contains(logicSys))
|
||||||
|
{
|
||||||
|
Log.Fatal("Repeat add logic system: {0}", logicSys.GetType().Name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!logicSys.OnInit())
|
||||||
|
{
|
||||||
|
Log.Fatal("{0} Init failed", logicSys.GetType().Name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_listLogicMgr.Add(logicSys);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4703541a565f5ec4bb35edd81c28958c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
19
Assets/GameScripts/HotFix/GameLogic/GameLogic.asmdef
Normal file
19
Assets/GameScripts/HotFix/GameLogic/GameLogic.asmdef
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "GameLogic",
|
||||||
|
"rootNamespace": "GameLogic",
|
||||||
|
"references": [
|
||||||
|
"GUID:b48be955427611241bcb6f2a07949c5b",
|
||||||
|
"GUID:08c3762f54316454ca6b6fbcb22b40e5",
|
||||||
|
"GUID:a90b2d3377c5e4a4db95cc44fb82045e",
|
||||||
|
"GUID:aa06d4cc755c979489c256c1bcca1dfb"
|
||||||
|
],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: acd6baa97ba40d3478c29cd9c76ff9e3
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/GameScripts/HotFix/GameProto.meta
Normal file
8
Assets/GameScripts/HotFix/GameProto.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9e6aea5b9046c6648b43fd31121b422f
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
17
Assets/GameScripts/HotFix/GameProto/GameProto.asmdef
Normal file
17
Assets/GameScripts/HotFix/GameProto/GameProto.asmdef
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"name": "GameProto",
|
||||||
|
"rootNamespace": "",
|
||||||
|
"references": [
|
||||||
|
"GUID:b48be955427611241bcb6f2a07949c5b",
|
||||||
|
"GUID:aa06d4cc755c979489c256c1bcca1dfb"
|
||||||
|
],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": true,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a90b2d3377c5e4a4db95cc44fb82045e
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/GameScripts/Main.meta
Normal file
8
Assets/GameScripts/Main.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ce8311fb28eecaf42ad9113e9e4a5912
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Reference in New Issue
Block a user