Compare commits

...

9 Commits

Author SHA1 Message Date
ALEXTANGXIAO
1e195ed3b4 TE6 打飞机Demo
TE6 打飞机Demo
2025-04-26 23:23:39 +08:00
ALEX
aaf7ddbee8 Update README.md 2025-01-16 09:23:51 +08:00
ALEXTANG
32d4e47184 提交Odin,防止报错 2024-05-10 17:05:19 +08:00
ALEXTANG
a2255b80cd 更新demo
更新demo
2024-03-18 15:35:15 +08:00
ALEXTANG
17a5d7425c 更新Demo
更新Demo
2023-12-20 12:14:27 +08:00
ALEXTANG
f64bb37706 更新Demo
更新Demo
2023-12-20 12:08:25 +08:00
ALEXTANG
5cf6b8c034 Update main.unity 2023-07-07 23:01:33 +08:00
ALEXTANG
0397d0f01e Update
Update
2023-05-13 20:31:11 +08:00
ALEXTANG
7bf081269c Demo
Demo
2023-05-13 11:57:11 +08:00
4266 changed files with 251398 additions and 129440 deletions

121
.gitignore vendored
View File

@@ -1,118 +1,15 @@
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Mm]emoryCaptures/
/EditorBuild/
# /[Aa]ssets/TResources/DLL/
/[Aa]ssets/StreamingAssets
/BuildBundleInfo/
[Aa]ssets/AATest/
[Aa]ssets/AATest.meta
# Asset meta data should only be ignored when the corresponding asset is also ignored
!/[Aa]ssets/**/*.meta
# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*
# Autogenerated Jetbrains Rider plugin
[Aa]ssets/Plugins/Editor/JetBrains*
# Visual Studio cache directory
.vs/
# Gradle cache directory
.gradle/
# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db
# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta
# Unity3D generated file on crash reports
sysinfo.txt
# Builds
*.apk
# Crashlytics generated file
crashlytics-build.properties
# TEnginePersistentDataPath
TEnginePersistentDataPath/
# Hotfix
TEngineHotUpdate/bin
TEngineHotUpdate/obj
#HybirdCLR(HuaTuo)
/HybirdCLRData/
[Hh]ybridCLRData/
#AATemp
[Aa]ssets/AATemp/
[Aa]ssets/AATemp.meta
#Rider
/.idea/
# ABConfig
[Aa]ssets/BuildConfig/
[Aa]ssets/BuildConfig.meta
[Aa]ssets/StreamingAssets/
[Aa]ssets/StreamingAssets.meta
Assets/HybridCLRBuildCache/AssetBundleOutput.meta
Assets/HybridCLRBuildCache/AssetBundleOutput/StandaloneWindows.meta
Assets/HybridCLRBuildCache.meta
Assets/HybridCLRBuildCache/AssetBundleSourceData.meta
Assets/HybridCLRBuildCache/AssetBundleSourceData/StandaloneWindows.meta
#Bundles
Bundles/
#Sandbox
Sandbox/
UnityProject/UserSettings/Layouts/default-2021.dwlt
UnityProject/UserSettings/Search.settings
#Luban
Luban/.cache.meta
Tools/Luban/
Tools/Luban.ClientServer/
Configs/.cache.meta
GenerateDatas/
#HybridCLR
Assets/HybridCLRData.meta
UserSettings/Search.settings
#Unity UserSettings
UserSettings/Search.index
UserSettings/Layouts/default-2021.dwlt
#UnityOnlineServiceData
Assets/UnityOnlineServiceData.meta
Assets/UnityOnlineServiceData
#FileServer
Tools/FileServer/AssetRoot
UnityProject/ProjectSettings/CommonBurstAotSettings.json
UnityProject/ProjectSettings/BurstAotSettings_StandaloneWindows.json

View File

@@ -1,69 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!687078895 &4343727234628468602
SpriteAtlas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: UIRaw_Atlas_Common
serializedVersion: 2
m_EditorData:
serializedVersion: 2
textureSettings:
serializedVersion: 2
anisoLevel: 0
compressionQuality: 0
maxTextureSize: 0
textureCompression: 0
filterMode: 1
generateMipMaps: 0
readable: 0
crunchedCompression: 0
sRGB: 1
platformSettings:
- serializedVersion: 3
m_BuildTarget: iPhone
m_MaxTextureSize: 2048
m_ResizeAlgorithm: 0
m_TextureFormat: 49
m_TextureCompression: 1
m_CompressionQuality: 100
m_CrunchedCompression: 0
m_AllowsAlphaSplitting: 0
m_Overridden: 1
m_AndroidETC2FallbackOverride: 0
m_ForceMaximumCompressionQuality_BC6H_BC7: 0
packingSettings:
serializedVersion: 2
padding: 2
blockOffset: 1
allowAlphaSplitting: 0
enableRotation: 1
enableTightPacking: 0
enableAlphaDilation: 0
secondaryTextureSettings: {}
variantMultiplier: 1
packables:
- {fileID: 21300000, guid: f9a06e163014f4f46b14f4499d3e7240, type: 3}
- {fileID: 21300000, guid: 2761fc23b4aa7e34187ac5ffbc3fad9b, type: 3}
- {fileID: 21300000, guid: d623a2b7e069a4c4592d3da48f476189, type: 3}
- {fileID: 21300000, guid: 57e4117f4cd6ae54284898652e70d553, type: 3}
bindAsDefault: 1
isAtlasV2: 0
cachedData: {fileID: 0}
m_MasterAtlas: {fileID: 0}
m_PackedSprites:
- {fileID: 21300000, guid: 2761fc23b4aa7e34187ac5ffbc3fad9b, type: 3}
- {fileID: 21300000, guid: f9a06e163014f4f46b14f4499d3e7240, type: 3}
- {fileID: 21300000, guid: d623a2b7e069a4c4592d3da48f476189, type: 3}
- {fileID: 21300000, guid: 57e4117f4cd6ae54284898652e70d553, type: 3}
m_PackedSpriteNamesToIndex:
- red_button
- blue_button
- white_background
- white_button
m_RenderDataMap: {}
m_Tag: UIRaw_Atlas_Common
m_IsVariant: 0
m_IsPlaceholder: 0

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 1a8431d2a64361c4d821790ed88aeb3d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 4343727234628468602
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: f69993ae3e14f924aa33b8747244c587
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,489 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEditor.U2D;
using UnityEngine;
using UnityEngine.U2D;
using Object = UnityEngine.Object;
/// <summary>
/// 图集导入管线。
/// </summary>
public class SpritePostprocessor : AssetPostprocessor
{
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
foreach (var s in importedAssets)
{
EditorSpriteSaveInfo.OnImportSprite(s);
}
foreach (var s in deletedAssets)
{
EditorSpriteSaveInfo.OnDeleteSprite(s);
}
foreach (var s in movedFromAssetPaths)
{
EditorSpriteSaveInfo.OnDeleteSprite(s);
}
foreach (var s in movedAssets)
{
EditorSpriteSaveInfo.OnImportSprite(s);
}
}
}
public static class EditorSpriteSaveInfo
{
private const string NormalAtlasDir = "Assets/Atlas";
private const string UISpritePath = "Assets/AssetRaw/UIRaw";
private const string UIAtlasPath = "Assets/AssetRaw/UIRaw/Atlas";
private const string UIRawPath = "Assets/AssetRaw/UIRaw/UIRaw";
private static List<string> m_dirtyAtlasList = new List<string>();
private static Dictionary<string, List<string>> m_allASprites = new Dictionary<string, List<string>>();
private static Dictionary<string, string> m_uiAtlasMap = new Dictionary<string, string>();
private static bool m_inited = false;
private static bool m_dirty = false;
public static void Init()
{
if (m_inited)
{
return;
}
EditorApplication.update += CheckDirty;
}
public static void CheckDirty()
{
if (m_dirty)
{
m_dirty = false;
AssetDatabase.Refresh();
float lastProgress = -1;
for (int i = 0; i < m_dirtyAtlasList.Count; i++)
{
string atlasName = m_dirtyAtlasList[i];
Debug.Log("更新图集 : " + atlasName);
var curProgress = (float)i / m_dirtyAtlasList.Count;
if (curProgress > lastProgress + 0.01f)
{
lastProgress = curProgress;
var progressText = $"当前进度:{i}/{m_dirtyAtlasList.Count} {atlasName}";
bool cancel = EditorUtility.DisplayCancelableProgressBar("刷新图集" + atlasName, progressText, curProgress);
if (cancel)
{
break;
}
}
bool isUI = atlasName.StartsWith("UIRaw");
SaveAtlas(atlasName, isUI);
}
EditorUtility.ClearProgressBar();
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
m_dirtyAtlasList.Clear();
}
}
public static void OnImportSprite(string assetPath)
{
if (!assetPath.StartsWith(UISpritePath))
{
return;
}
TextureImporter ti = AssetImporter.GetAtPath(assetPath) as TextureImporter;
if (ti != null)
{
var modify = false;
if (assetPath.StartsWith(UISpritePath))
{
if (ti.textureType != TextureImporterType.Sprite)
{
ti.textureType = TextureImporterType.Sprite;
modify = true;
}
if (!string.IsNullOrEmpty(ti.spritePackingTag))
{
ti.spritePackingTag = string.Empty;
modify = true;
}
var setting = new TextureImporterSettings();
ti.ReadTextureSettings(setting);
if (setting.spriteGenerateFallbackPhysicsShape)
{
setting.spriteGenerateFallbackPhysicsShape = false;
ti.SetTextureSettings(setting);
modify = true;
}
if (IsKeepRawImage(assetPath))
{
//调整android格式
var andPlatformSettings = ti.GetPlatformTextureSettings("Android");
if (!andPlatformSettings.overridden)
{
andPlatformSettings.overridden = true;
modify = true;
}
if (andPlatformSettings.format != TextureImporterFormat.ASTC_6x6)
{
andPlatformSettings.format = TextureImporterFormat.ASTC_6x6;
ti.SetPlatformTextureSettings(andPlatformSettings);
modify = true;
}
//调整ios格式
var iosPlatformSettings = ti.GetPlatformTextureSettings("iPhone");
if (!iosPlatformSettings.overridden)
{
iosPlatformSettings.overridden = true;
modify = true;
}
if (iosPlatformSettings.format != TextureImporterFormat.ASTC_5x5)
{
iosPlatformSettings.format = TextureImporterFormat.ASTC_5x5;
iosPlatformSettings.compressionQuality = 50;
ti.SetPlatformTextureSettings(iosPlatformSettings);
modify = true;
}
}
}
if (modify)
{
ti.SaveAndReimport();
}
if (ti.textureType == TextureImporterType.Sprite)
{
OnProcessSprite(assetPath);
}
}
}
/// <summary>
/// 是否保持散图(不打图集)
/// </summary>
/// <param name="dirPath"></param>
/// <returns></returns>
public static bool IsKeepRawImage(string dirPath)
{
return dirPath.Contains("UIRaw/Raw/") || dirPath.Contains("UIRaw_Raw_");
}
public static string GetSpritePath(string assetPath)
{
string path = assetPath.Substring(0, assetPath.LastIndexOf("."));
path = path.Replace("Assets/AssetRaw/", "");
return path;
}
/// <summary>
/// 根据文件路径,返回图集名称
/// </summary>
/// <param name="fullName"></param>
/// <returns></returns>
public static string GetPackageTag(string fullName)
{
fullName = fullName.Replace("\\", "/");
int idx = fullName.LastIndexOf("UIRaw", StringComparison.Ordinal);
if (idx == -1)
{
return "";
}
if (IsKeepRawImage(fullName))
{
return "";
}
var atlasPath = fullName.Substring(idx);
string str = atlasPath;
str = str.Substring(0, str.LastIndexOf("/", StringComparison.Ordinal)).Replace("/", "_");
return str;
}
public static void OnProcessSprite(string assetPath)
{
if (!assetPath.StartsWith("Assets"))
{
return;
}
if (assetPath.StartsWith("Assets/UIRaw_Delete"))
{
return;
}
Init();
var spriteName = Path.GetFileNameWithoutExtension(assetPath);
var spritePath = GetSpritePath(assetPath);
if (!m_uiAtlasMap.TryGetValue(spriteName, out string oldAssetPath) || spritePath == oldAssetPath)
{
m_uiAtlasMap[spriteName] = spritePath;
m_dirty = true;
}
else
{
Debug.LogError($"有重名的图片:{spriteName}\n旧图集{oldAssetPath}\n新图集{spritePath} ");
m_uiAtlasMap[spriteName] = spritePath;
m_dirty = true;
}
string atlasName = GetPackageTag(assetPath);
if (string.IsNullOrEmpty(atlasName))
{
bool keepRaw = IsKeepRawImage(assetPath);
if (!keepRaw)
{
Debug.LogError($"empty packingTag of asset :{assetPath} !!!");
}
return;
}
else
{
List<string> ret;
if (!m_allASprites.TryGetValue(atlasName, out ret))
{
ret = new List<string>();
m_allASprites.Add(atlasName, ret);
}
if (!ret.Contains(assetPath))
{
ret.Add(assetPath);
m_dirty = true;
if (!m_dirtyAtlasList.Contains(atlasName))
{
m_dirtyAtlasList.Add(atlasName);
}
}
}
}
public static void OnDeleteSprite(string assetPath)
{
if (assetPath.StartsWith("Assets/UIRaw_Delete"))
{
return;
}
if (!assetPath.StartsWith(UISpritePath))
{
return;
}
Init();
string atlasName = GetPackageTag(assetPath);
if (!m_allASprites.TryGetValue(atlasName, out var ret))
{
return;
}
//改成文件名的匹配
if (!ret.Exists(s => Path.GetFileName(s) == Path.GetFileName(assetPath)))
{
return;
}
if (assetPath.StartsWith(UISpritePath))
{
var spriteName = Path.GetFileNameWithoutExtension(assetPath);
if (m_uiAtlasMap.ContainsKey(spriteName))
{
m_uiAtlasMap.Remove(spriteName);
m_dirty = true;
}
}
ret.Remove(assetPath);
m_dirty = true;
if (!m_dirtyAtlasList.Contains(atlasName))
{
m_dirtyAtlasList.Add(atlasName);
}
}
#region
public static void SaveAtlas(string atlasName, bool isUI)
{
List<Object> spriteList = new List<Object>();
if (m_allASprites.ContainsKey(atlasName))
{
var list = m_allASprites[atlasName];
list.Sort(StringComparer.Ordinal);
foreach (var s in list)
{
var sprite = AssetDatabase.LoadAssetAtPath<Sprite>(s);
if (sprite != null)
{
spriteList.Add(sprite);
}
}
}
var path = $"{NormalAtlasDir}/{atlasName}.spriteatlas";
if (spriteList.Count == 0)
{
if (File.Exists(path))
{
AssetDatabase.DeleteAsset(path);
}
return;
}
var atlas = new SpriteAtlas();
var setting = new SpriteAtlasPackingSettings
{
blockOffset = 1,
padding = 2,
enableRotation = true
};
bool isOpaque = atlasName.Contains("Opaque");
var textureSetting = new SpriteAtlasTextureSettings
{
generateMipMaps = false,
sRGB = true,
filterMode = FilterMode.Bilinear
};
atlas.SetTextureSettings(textureSetting);
var iphonePlatformSetting = atlas.GetPlatformSettings("iPhone");
if (!iphonePlatformSetting.overridden)
{
iphonePlatformSetting.overridden = true;
iphonePlatformSetting.format = isOpaque ? TextureImporterFormat.ASTC_5x5 : TextureImporterFormat.ASTC_5x5;
iphonePlatformSetting.compressionQuality = 100;
atlas.SetPlatformSettings(iphonePlatformSetting);
}
var androidPlatformSetting = atlas.GetPlatformSettings("Android");
if (isOpaque && !androidPlatformSetting.overridden)
{
androidPlatformSetting.overridden = true;
androidPlatformSetting.format = TextureImporterFormat.ETC_RGB4;
androidPlatformSetting.compressionQuality = 100;
atlas.SetPlatformSettings(androidPlatformSetting);
}
atlas.SetPackingSettings(setting);
atlas.Add(spriteList.ToArray());
AssetDatabase.CreateAsset(atlas, path);
}
#endregion
#region
private static Dictionary<string, List<string>> m_tempAllASprites = new Dictionary<string, List<string>>();
[MenuItem("TEngine/图集/重新生成UI图集")]
static void ForceGenAtlas()
{
Init();
List<string> needSaveAtlas = new List<string>();
m_tempAllASprites.Clear();
var findAssets = AssetDatabase.FindAssets("t:sprite", new[] { UIAtlasPath });
foreach (var findAsset in findAssets)
{
var path = AssetDatabase.GUIDToAssetPath(findAsset);
var atlasName = GetPackageTag(path);
if (!m_tempAllASprites.TryGetValue(atlasName, out var spriteList))
{
spriteList = new List<string>();
m_tempAllASprites[atlasName] = spriteList;
}
if (!spriteList.Contains(path))
{
spriteList.Add(path);
}
}
//有变化的才刷
var iter = m_tempAllASprites.GetEnumerator();
while (iter.MoveNext())
{
bool needSave = false;
var atlasName = iter.Current.Key;
var newSpritesList = iter.Current.Value;
List<string> existSprites;
if (m_allASprites.TryGetValue(atlasName, out existSprites))
{
if (existSprites.Count != newSpritesList.Count)
{
needSave = true;
existSprites.Clear();
existSprites.AddRange(newSpritesList);
}
else
{
for (int i = 0; i < newSpritesList.Count; i++)
{
if (!existSprites.Contains(newSpritesList[i]))
{
needSave = true;
break;
}
}
if (needSave)
{
existSprites.Clear();
existSprites.AddRange(newSpritesList);
}
}
}
else
{
needSave = true;
m_allASprites.Add(atlasName, new List<string>(newSpritesList));
}
if (needSave && !needSaveAtlas.Contains(atlasName))
{
needSaveAtlas.Add(atlasName);
}
}
iter.Dispose();
foreach (var atlas in needSaveAtlas)
{
Debug.LogFormat("Gen atlas:{0}", atlas);
SaveAtlas(atlas, true);
}
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
SpriteAtlasUtility.PackAllAtlases(EditorUserBuildSettings.activeBuildTarget);
Debug.Log("Gen end");
}
#endregion
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 9e87a460a53ec5546a19e31705d13664
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: b6b7bfca93e005f45999c16054d999e7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,18 +0,0 @@
{
"name": "BattleCore.Runtime",
"rootNamespace": "BattleCore.Runtime",
"references": [
"GUID:aa06d4cc755c979489c256c1bcca1dfb",
"GUID:d8b63aba1907145bea998dd612889d6b",
"GUID:a90b2d3377c5e4a4db95cc44fb82045e"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 641632c4f8079b94f963b5284d859a12
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 890abd3a957e406ab422fc468ba6c169
timeCreated: 1682353243

View File

@@ -1,6 +0,0 @@
namespace BattleCore.Runtime
{
public static class EntityExtension
{
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: b4ef2dfa5ceac99458eb1745131a9c83
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,27 +0,0 @@
using UnityEngine;
using Unity.Mathematics;
namespace BattleCore.Runtime
{
public static class MathematicsExt
{
public static int2 ToInt2(this Vector2Int vec) => new int2(vec.x, vec.y);
public static int3 ToInt3(this Vector3Int vec) => new int3(vec.x, vec.y, vec.z);
public static float2 ToFloat2(this Vector2 vec) => new float2(vec.x, vec.y);
public static float3 ToFloat3(this Vector3 vec) => new float3(vec.x, vec.y, vec.z);
public static bool IsEquals(this int2 a, int2 b) => math.all(a == b);
public static bool IsEquals(this int3 a, int3 b) => math.all(a == b);
public static Vector2Int ToVec2(this int2 vec) => new Vector2Int(vec.x, vec.y);
public static Vector3Int ToVec3(this int2 vec) => new Vector3Int(vec.x, vec.y, 0);
public static Vector3Int ToVec3(this int3 vec) => new Vector3Int(vec.x, vec.y, vec.z);
public static Vector2 ToVec2(this float2 vec) => new Vector2(vec.x, vec.y);
public static Vector3 ToVec3(this float3 vec) => new Vector3(vec.x, vec.y, vec.z);
public static int ManhattanDist(this int2 vec) => vec.x + vec.y;
public static int ManhattanDist(this int3 vec) => vec.x + vec.y + vec.z;
public static float ManhattanDist(this float2 vec) => vec.x + vec.y;
public static float ManhattanDist(this float3 vec) => vec.x + vec.y + vec.z;
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 2b0e288b918a41698571ec3d36059851
timeCreated: 1682353251

View File

@@ -1,21 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BattleCore.Runtime
{
public class Empty : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 1fc394f8c6ad5304a82ff84b4263756f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 26079995c20c1b144a1c086bf2869375
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,16 +0,0 @@
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;
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: bb7ef2f42b33ada47b3543dc7723fcb5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,75 +0,0 @@
namespace TEngine
{
/// <summary>
/// 基础LogicSys,生命周期由TEngine实现推荐给系统实现
/// 减少多余的Mono保持系统层面只有一个Update。
/// 用主Mono来驱动LogicSys的生命周期。
/// </summary>
/// <typeparam name="T">逻辑系统类型。</typeparam>
public abstract class BaseLogicSys<T> : ILogicSys where T : new()
{
private static T _instance;
public static bool HasInstance => _instance != null;
public static T Instance
{
get
{
if (null == _instance)
{
_instance = new T();
}
return _instance;
}
}
#region virtual function
public virtual bool OnInit()
{
if (null == _instance)
{
_instance = new T();
}
return true;
}
public virtual void OnStart()
{
}
public virtual void OnUpdate()
{
}
public virtual void OnLateUpdate()
{
}
public virtual void OnFixedUpdate()
{
}
public virtual void OnRoleLogout()
{
}
public virtual void OnDestroy()
{
}
public virtual void OnDrawGizmos()
{
}
public virtual void OnApplicationPause(bool pause)
{
}
public virtual void OnMapChanged()
{
}
#endregion
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: fc4ce19b17fd4277951d189b66f503e2
timeCreated: 1683120353

View File

@@ -1,212 +0,0 @@
using System.Collections.Generic;
namespace TEngine
{
/// <summary>
/// 通过LogicSys来驱动且具备Unity完整生命周期的单例不继承MonoBehaviour
/// </summary>
/// <typeparam name="T"></typeparam>
public abstract class BehaviourSingleton<T> : BaseBehaviourSingleton where T : BaseBehaviourSingleton, new()
{
private static T _instance;
public static T Instance
{
get
{
if (null == _instance)
{
_instance = new T();
Log.Assert(_instance != null);
_instance.Awake();
RegSingleton(_instance);
}
return _instance;
}
}
private static void RegSingleton(BaseBehaviourSingleton inst)
{
BehaviourSingleSystem.Instance.RegSingleton(inst);
}
}
public class BaseBehaviourSingleton
{
public bool IsStart = false;
public virtual void Active()
{
}
public virtual void Awake()
{
}
public virtual bool IsHaveLateUpdate()
{
return false;
}
public virtual void Start()
{
}
public virtual void Update()
{
}
public virtual void LateUpdate()
{
}
public virtual void Destroy()
{
}
public virtual void OnPause()
{
}
public virtual void OnResume()
{
}
public virtual void OnDrawGizmos()
{
}
}
public class BehaviourSingleSystem : BaseLogicSys<BehaviourSingleSystem>
{
private readonly List<BaseBehaviourSingleton> _listInst = new List<BaseBehaviourSingleton>();
private readonly List<BaseBehaviourSingleton> _listStart = new List<BaseBehaviourSingleton>();
private readonly List<BaseBehaviourSingleton> _listUpdate = new List<BaseBehaviourSingleton>();
private readonly List<BaseBehaviourSingleton> _listLateUpdate = new List<BaseBehaviourSingleton>();
public void RegSingleton(BaseBehaviourSingleton inst)
{
Log.Assert(!_listInst.Contains(inst));
_listInst.Add(inst);
_listStart.Add(inst);
}
public void UnRegSingleton(BaseBehaviourSingleton inst)
{
if (inst == null)
{
Log.Error($"BaseBehaviourSingleton Is Null");
return;
}
Log.Assert(_listInst.Contains(inst));
if (_listInst.Contains(inst))
{
_listInst.Remove(inst);
}
if (_listStart.Contains(inst))
{
_listStart.Remove(inst);
}
if (_listUpdate.Contains(inst))
{
_listUpdate.Remove(inst);
}
if (_listLateUpdate.Contains(inst))
{
_listLateUpdate.Remove(inst);
}
inst.Destroy();
inst = null;
}
public override void OnUpdate()
{
var listStart = _listStart;
var listToUpdate = _listUpdate;
var listToLateUpdate = _listLateUpdate;
if (listStart.Count > 0)
{
for (int i = 0; i < listStart.Count; i++)
{
var inst = listStart[i];
Log.Assert(!inst.IsStart);
inst.IsStart = true;
inst.Start();
listToUpdate.Add(inst);
if (inst.IsHaveLateUpdate())
{
listToLateUpdate.Add(inst);
}
}
listStart.Clear();
}
var listUpdateCnt = listToUpdate.Count;
for (int i = 0; i < listUpdateCnt; i++)
{
var inst = listToUpdate[i];
TProfiler.BeginFirstSample(inst.GetType().FullName);
inst.Update();
TProfiler.EndFirstSample();
}
}
public override void OnLateUpdate()
{
var listLateUpdate = _listLateUpdate;
var listLateUpdateCnt = listLateUpdate.Count;
for (int i = 0; i < listLateUpdateCnt; i++)
{
var inst = listLateUpdate[i];
TProfiler.BeginFirstSample(inst.GetType().FullName);
inst.LateUpdate();
TProfiler.EndFirstSample();
}
}
public override void OnDestroy()
{
for (int i = 0; i < _listInst.Count; i++)
{
var inst = _listInst[i];
inst.Destroy();
}
}
public override void OnApplicationPause(bool pause)
{
for (int i = 0; i < _listInst.Count; i++)
{
var inst = _listInst[i];
if (pause)
{
inst.OnPause();
}
else
{
inst.OnResume();
}
}
}
public override void OnDrawGizmos()
{
for (int i = 0; i < _listInst.Count; i++)
{
var inst = _listInst[i];
inst.OnDrawGizmos();
}
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 5c0e9c1c8c9d4ce99a1c991fb62a0256
timeCreated: 1683120460

View File

@@ -1,16 +0,0 @@
{
"name": "GameBase",
"rootNamespace": "GameBase",
"references": [
"GUID:aa06d4cc755c979489c256c1bcca1dfb"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 08c3762f54316454ca6b6fbcb22b40e5
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: b062b3e32edd4536a4308a3d180842e0
timeCreated: 1681989133

View File

@@ -1,40 +0,0 @@
using TEngine;
namespace GameBase
{
/// <summary>
/// 用来在多线程下检测耗时。
/// </summary>
public class GameTickWatcher
{
private long _startTick;
public GameTickWatcher()
{
Refresh();
}
public void Refresh()
{
_startTick = System.DateTime.Now.Ticks;
}
/// <summary>
/// 获取用时。
/// </summary>
/// <returns></returns>
public float ElapseTime()
{
long endTick = System.DateTime.Now.Ticks;
return (float)((endTick - _startTick) / 10000) / 1000.0f;
}
/// <summary>
/// 输出用时。
/// </summary>
public void LogUsedTime()
{
Log.Info($"Used Time: {this.ElapseTime()}");
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 7320165f7aa147a998a30fe2f7a5a5c2
timeCreated: 1681989139

View File

@@ -1,52 +0,0 @@
/// <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);
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 63ff6535a43f41d7ac793b8a153a37b6
timeCreated: 1681213932

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: dab5f3e08b4367d41b801af29d381ca8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,190 +0,0 @@
using UnityEngine;
using System.Collections.Generic;
using System;
using System.Threading;
using System.Linq;
/*******************************************************************************
//开启一个Loom进程
Loom.RunAsync(() =>
{
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>
/// </summary>
public class Loom : MonoBehaviour
{
public Dictionary<string, CancellationTokenSource> TokenSourcesDictionary = new Dictionary<string, CancellationTokenSource>();
private static readonly int MaxThreads = 8;
private static int _numThreads;
private static Loom _current;
public static Loom Current
{
get
{
Initialize();
return _current;
}
}
public void Awake()
{
_current = this;
_initialized = true;
}
protected void OnDestroy()
{
}
private static bool _initialized;
private static void Initialize()
{
if (!_initialized)
{
if (!Application.isPlaying)
{
return;
}
_initialized = true;
var obj = new GameObject("[Loom]");
_current = obj.AddComponent<Loom>();
DontDestroyOnLoad(obj);
}
}
public struct NoDelayedQueueItem
{
public Action<object> Action;
public object Param;
}
private readonly List<NoDelayedQueueItem> _actions = new List<NoDelayedQueueItem>();
public struct DelayedQueueItem
{
public float Time;
public Action<object> Action;
public object Param;
}
private readonly List<DelayedQueueItem> _delayed = new List<DelayedQueueItem>();
private readonly List<DelayedQueueItem> _currentDelayed = new List<DelayedQueueItem>();
public static void QueueOnMainThread(Action<object> taction, object param, float time = 0f)
{
if (time != 0f)
{
lock (Current._delayed)
{
Current._delayed.Add(new DelayedQueueItem { Time = Time.time + time, Action = taction, Param = param });
}
}
else
{
lock (Current._actions)
{
Current._actions.Add(new NoDelayedQueueItem { Action = taction, Param = param });
}
}
}
public static Thread RunAsync(Action action)
{
Initialize();
while (_numThreads >= MaxThreads)
{
Thread.Sleep(100);
}
Interlocked.Increment(ref _numThreads);
ThreadPool.QueueUserWorkItem(RunAction, action);
return null;
}
private static void RunAction(object action)
{
try
{
((Action)action)();
}
catch
{
// ignored
}
finally
{
Interlocked.Decrement(ref _numThreads);
}
}
void OnDisable()
{
if (_current == this)
{
_current = null;
}
}
private readonly List<NoDelayedQueueItem> _currentActions = new List<NoDelayedQueueItem>();
void Update()
{
if (_actions.Count > 0)
{
lock (_actions)
{
_currentActions.Clear();
_currentActions.AddRange(_actions);
_actions.Clear();
}
for (int i = 0; i < _currentActions.Count; i++)
{
_currentActions[i].Action(_currentActions[i].Param);
}
}
if (_delayed.Count > 0)
{
lock (_delayed)
{
_currentDelayed.Clear();
_currentDelayed.AddRange(_delayed.Where(d => d.Time <= Time.time));
for (int i = 0; i < _currentDelayed.Count; i++)
{
_delayed.Remove(_currentDelayed[i]);
}
}
for (int i = 0; i < _currentDelayed.Count; i++)
{
_currentDelayed[i].Action(_currentDelayed[i].Param);
}
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: eea4adc555e37f842abf5dd24c191d93
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 00565f0d362f4c36836804455e19c3df
timeCreated: 1681990210

View File

@@ -1,27 +0,0 @@
using TEngine;
namespace GameBase
{
/// <summary>
/// 通用单例。
/// </summary>
/// <typeparam name="T">泛型T。</typeparam>
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;
}
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: b68a449df312429cbb27873984ec238e
timeCreated: 1681214042

View File

@@ -1,214 +0,0 @@
using System.Collections.Generic;
using TEngine;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace GameBase
{
/// <summary>
/// 单例接口。
/// </summary>
public interface ISingleton
{
void Active();
void Release();
}
/// <summary>
/// 单例管理器(统一化持久和释放)。
/// </summary>
public static class SingletonMgr
{
private static List<ISingleton> _singletonList;
private static Dictionary<string, GameObject> _gameObjects;
private static GameObject _root;
public static GameObject Root
{
get
{
if (_root == null)
{
_root = GameObject.Find("[SingletonMgr]");
if (_root == null)
{
_root = new GameObject("[SingletonMgr]")
{
transform =
{
position = Vector3.zero
}
};
}
UnityEngine.Object.DontDestroyOnLoad(_root);
}
return _root;
}
}
public static void Retain(ISingleton go)
{
if (_singletonList == null)
{
_singletonList = new List<ISingleton>();
}
_singletonList.Add(go);
}
public static void Retain(GameObject go)
{
if (_gameObjects == null)
{
_gameObjects = new Dictionary<string, GameObject>();
}
if (!_gameObjects.ContainsKey(go.name))
{
_gameObjects.Add(go.name, go);
if (Application.isPlaying)
{
UnityEngine.Object.DontDestroyOnLoad(go);
}
}
}
public static void Release(GameObject go)
{
if (_gameObjects != null && _gameObjects.ContainsKey(go.name))
{
_gameObjects.Remove(go.name);
UnityEngine.Object.Destroy(go);
}
}
public static void Release(ISingleton go)
{
if (_singletonList != null && _singletonList.Contains(go))
{
_singletonList.Remove(go);
}
}
public static void Release()
{
if (_gameObjects != null)
{
foreach (var item in _gameObjects)
{
UnityEngine.Object.Destroy(item.Value);
}
_gameObjects.Clear();
}
if (_singletonList != null)
{
for (int i = 0; i < _singletonList.Count; ++i)
{
_singletonList[i].Release();
}
_singletonList.Clear();
}
Resources.UnloadUnusedAssets();
}
public static GameObject GetGameObject(string name)
{
GameObject go = null;
if (_gameObjects != null)
{
_gameObjects.TryGetValue(name, out go);
}
return go;
}
internal static bool ContainsKey(string name)
{
if (_gameObjects != null)
{
return _gameObjects.ContainsKey(name);
}
return false;
}
internal static ISingleton GetSingleton(string name)
{
for (int i = 0; i < _singletonList.Count; ++i)
{
if (_singletonList[i].ToString() == name)
{
return _singletonList[i];
}
}
return null;
}
/// <summary>
/// 释放所有单例。
/// </summary>
public static void ReStart()
{
Release();
SceneManager.LoadScene(0);
}
}
/// <summary>
/// 全局单例对象(非线程安全)。
/// </summary>
/// <typeparam name="T">泛型T。</typeparam>
public abstract class TSingleton<T> : ISingleton where T : TSingleton<T>, new()
{
private static T _instance;
public static T Instance
{
get
{
if (null == _instance)
{
_instance = new T();
_instance.Init();
#if UNITY_EDITOR
Log.Info($"TSingleton Instance:{typeof(T).Name}");
#endif
SingletonMgr.Retain(_instance);
}
return _instance;
}
}
public static bool IsValid => _instance != null;
protected TSingleton()
{
}
protected virtual void Init()
{
}
public virtual void Active()
{
}
public virtual void Release()
{
if (_instance != null)
{
SingletonMgr.Release(_instance);
_instance = null;
}
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: aa2cb5bb622045d7a6f2a4c4faea3ca6
timeCreated: 1681989590

View File

@@ -1,111 +0,0 @@
using TEngine;
using UnityEngine;
namespace GameBase
{
/// <summary>
/// 具备Unity完整生命周期的单例。
/// </summary>
/// <typeparam name="T"></typeparam>
public abstract class UnitySingleton<T> : MonoBehaviour where T : MonoBehaviour
{
private static T _instance;
public static T Instance
{
get
{
if (_instance == null)
{
var ins = UnityEngine.Object.FindObjectOfType<T>();
if (ins != null)
{
var obj = ins.gameObject;
obj.name = typeof(T).Name;
_instance = ins;
SingletonMgr.Retain(obj);
return Instance;
}
System.Type thisType = typeof(T);
string instName = thisType.Name;
GameObject go = SingletonMgr.GetGameObject(instName);
if (go == null)
{
go = GameObject.Find($"{instName}");
if (go == null)
{
go = new GameObject(instName);
go.transform.position = Vector3.zero;
}
}
_instance = go.GetComponent<T>();
if (_instance == null)
{
_instance = go.AddComponent<T>();
}
if (_instance == null)
{
Log.Error($"Can't create UnitySingleton<{typeof(T)}>");
}
}
return _instance;
}
}
public static T Active()
{
return Instance;
}
public static bool IsValid => _instance != null;
private bool CheckInstance()
{
if (this == Instance)
{
return true;
}
GameObject.Destroy(gameObject);
return false;
}
protected virtual void OnLoad()
{
}
public virtual void Awake()
{
if (CheckInstance())
{
OnLoad();
}
#if UNITY_EDITOR
Log.Debug($"UnitySingleton Instance:{typeof(T).Name}");
#endif
GameObject tEngine = SingletonMgr.Root;
if (tEngine != null)
{
this.gameObject.transform.SetParent(tEngine.transform);
}
}
protected virtual void OnDestroy()
{
Release();
}
public static void Release()
{
if (_instance != null)
{
SingletonMgr.Release(_instance.gameObject);
_instance = null;
}
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 25c99243aa534df5870e36fdf9d36afd
timeCreated: 1681990223

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 1d862c80fdc1e684e8ff3b6ae7707b79
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,24 +0,0 @@
using TEngine;
using UnityEngine;
#if ENABLE_URP
using UnityEngine.Rendering.Universal;
#endif
namespace GameLogic
{
public class CameraUtils
{
public static void AddCameraStack(Camera camera,Camera mainCamera)
{
#if ENABLE_URP
if (mainCamera != null)
{
// 通过脚本的方式,只要能找到 camera 不轮是否跨 base 相机的场景,都可以 Add 进 Stack
mainCamera.GetComponent<UniversalAdditionalCameraData>().cameraStack.Add(GameModule.UI.UICamera);
}
#else
Log.Fatal("Could not add camera stack because had no URP-Render-Pip");
#endif
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 6375b5490bbdcc145a24706a6c4e9cb7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,162 +0,0 @@
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);
Instance.StartGameLogic();
}
/// <summary>
/// 开始游戏业务层逻辑。
/// <remarks>显示UI、加载场景等。</remarks>
/// </summary>
private void StartGameLogic()
{
}
/// <summary>
/// 关闭游戏。
/// </summary>
/// <param name="shutdownType">关闭游戏框架类型。</param>
public static void Shutdown(ShutdownType shutdownType)
{
if (shutdownType == ShutdownType.None)
{
return;
}
if (shutdownType == ShutdownType.Restart)
{
Utility.Unity.RemoveUpdateListener(Instance.Update);
Utility.Unity.RemoveFixedUpdateListener(Instance.FixedUpdate);
Utility.Unity.RemoveLateUpdateListener(Instance.LateUpdate);
Utility.Unity.RemoveDestroyListener(Instance.OnDestroy);
Utility.Unity.RemoveOnDrawGizmosListener(Instance.OnDrawGizmos);
Utility.Unity.RemoveOnApplicationPauseListener(Instance.OnApplicationPause);
return;
}
if (shutdownType == ShutdownType.Quit)
{
UnityEngine.Application.Quit();
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#endif
}
}
private void Start()
{
GameTime.StartFrame();
var listLogic = _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 = _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 = _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 = _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 = _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 = _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 = _listLogicMgr;
var logicCnt = listLogic.Count;
for (int i = 0; i < logicCnt; i++)
{
var logic = listLogic[i];
logic.OnApplicationPause(isPause);
}
}
}

View File

@@ -1,54 +0,0 @@
using System.Collections.Generic;
using TEngine;
public partial class GameApp
{
private List<ILogicSys> _listLogicMgr;
private void Init()
{
_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 (_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;
}
_listLogicMgr.Add(logicSys);
return true;
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 4703541a565f5ec4bb35edd81c28958c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,27 +0,0 @@
{
"name": "GameLogic",
"rootNamespace": "GameLogic",
"references": [
"GUID:08c3762f54316454ca6b6fbcb22b40e5",
"GUID:a90b2d3377c5e4a4db95cc44fb82045e",
"GUID:aa06d4cc755c979489c256c1bcca1dfb",
"GUID:641632c4f8079b94f963b5284d859a12",
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:15fc0a57446b3144c949da3e2b9737a9"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [
{
"name": "com.unity.render-pipelines.universal",
"expression": "",
"define": "ENABLE_URP"
}
],
"noEngineReferences": false
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 145b951be40d41dea06e76bd967a5d15
timeCreated: 1682045847

View File

@@ -1,19 +0,0 @@
using System;
using ProtoBuf;
namespace GameLogic
{
[Serializable, ProtoContract(Name = @"HeartBeat")]
public class HeartBeat : PacketBase
{
public HeartBeat()
{
}
public override int Id => 1;
public override void Clear()
{
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: d8b9b60d2abf409ca9dd2ce00506ac79
timeCreated: 1682046644

View File

@@ -1,254 +0,0 @@
using ProtoBuf;
using ProtoBuf.Meta;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Sockets;
using System.Reflection;
using TEngine;
namespace GameLogic
{
public class NetworkChannelHelper : INetworkChannelHelper, IMemory
{
private readonly Dictionary<int, Type> _serverToClientPacketTypes = new Dictionary<int, Type>();
private readonly MemoryStream _cachedStream = new MemoryStream(1024 * 8);
private INetworkChannel _networkChannel = null;
/// <summary>
/// 获取消息包头长度。
/// <remarks>4。</remarks>
/// </summary>
public int PacketHeaderLength => sizeof(int);
/// <summary>
/// 初始化网络频道辅助器。
/// </summary>
/// <param name="networkChannel">网络频道。</param>
public void Initialize(INetworkChannel networkChannel)
{
_networkChannel = networkChannel;
// 反射注册包和包处理函数。
Type packetBaseType = typeof(ProtoPacket);
Assembly assembly = Assembly.GetExecutingAssembly();
Type[] types = assembly.GetTypes();
for (int i = 0; i < types.Length; i++)
{
if (!types[i].IsClass || types[i].IsAbstract)
{
continue;
}
if (types[i].BaseType == packetBaseType)
{
PacketBase packetBase = (PacketBase)Activator.CreateInstance(types[i]);
Type packetType = GetServerToClientPacketType(packetBase.Id);
if (packetType != null)
{
Log.Warning("Already exist packet type '{0}', check '{1}' or '{2}'?.", packetBase.Id.ToString(), packetType.Name, packetBase.GetType().Name);
continue;
}
_serverToClientPacketTypes.Add(packetBase.Id, types[i]);
}
}
GameEvent.AddEventListener<INetworkChannel, object>(NetworkEvent.NetworkConnectedEvent, OnNetworkConnected);
GameEvent.AddEventListener<INetworkChannel>(NetworkEvent.NetworkClosedEvent, OnNetworkClosed);
GameEvent.AddEventListener<INetworkChannel, int>(NetworkEvent.NetworkMissHeartBeatEvent, OnNetworkMissHeartBeat);
GameEvent.AddEventListener<INetworkChannel, NetworkErrorCode, SocketError, string>(NetworkEvent.NetworkErrorEvent, OnNetworkError);
GameEvent.AddEventListener<INetworkChannel, object>(NetworkEvent.NetworkCustomErrorEvent, OnNetworkCustomError);
}
/// <summary>
/// 关闭并清理网络频道辅助器。
/// </summary>
public void Shutdown()
{
GameEvent.RemoveEventListener<INetworkChannel, object>(NetworkEvent.NetworkConnectedEvent, OnNetworkConnected);
GameEvent.RemoveEventListener<INetworkChannel>(NetworkEvent.NetworkClosedEvent, OnNetworkClosed);
GameEvent.RemoveEventListener<INetworkChannel, int>(NetworkEvent.NetworkMissHeartBeatEvent, OnNetworkMissHeartBeat);
GameEvent.RemoveEventListener<INetworkChannel, NetworkErrorCode, SocketError, string>(NetworkEvent.NetworkErrorEvent, OnNetworkError);
GameEvent.RemoveEventListener<INetworkChannel, object>(NetworkEvent.NetworkCustomErrorEvent, OnNetworkCustomError);
_networkChannel = null;
}
/// <summary>
/// 准备进行连接。
/// </summary>
public void PrepareForConnecting()
{
_networkChannel.Socket.ReceiveBufferSize = 1024 * 64;
_networkChannel.Socket.SendBufferSize = 1024 * 64;
}
/// <summary>
/// 发送心跳消息包。
/// </summary>
/// <returns>是否发送心跳消息包成功。</returns>
public bool SendHeartBeat()
{
_networkChannel.Send(MemoryPool.Acquire<HeartBeat>());
return true;
}
/// <summary>
/// 序列化消息包。
/// </summary>
/// <typeparam name="T">消息包类型。</typeparam>
/// <param name="packet">要序列化的消息包。</param>
/// <param name="destination">要序列化的目标流。</param>
/// <returns>是否序列化成功。</returns>
public bool Serialize<T>(T packet, Stream destination) where T : Packet
{
PacketBase packetImpl = packet as PacketBase;
if (packetImpl == null)
{
Log.Warning("Packet is invalid.");
return false;
}
_cachedStream.SetLength(_cachedStream.Capacity); // 此行防止 Array.Copy 的数据无法写入
_cachedStream.Position = 0L;
PacketHeader packetHeader = MemoryPool.Acquire<PacketHeader>();
Serializer.Serialize(_cachedStream, packetHeader);
MemoryPool.Release(packetHeader);
Serializer.SerializeWithLengthPrefix(_cachedStream, packet, PrefixStyle.Fixed32);
MemoryPool.Release((IMemory)packet);
_cachedStream.WriteTo(destination);
return true;
}
/// <summary>
/// 反序列化消息包头。
/// </summary>
/// <param name="source">要反序列化的来源流。</param>
/// <param name="customErrorData">用户自定义错误数据。</param>
/// <returns>反序列化后的消息包头。</returns>
public IPacketHeader DeserializePacketHeader(Stream source, out object customErrorData)
{
// 注意:此函数并不在主线程调用!
customErrorData = null;
return (IPacketHeader)RuntimeTypeModel.Default.Deserialize(source, MemoryPool.Acquire<PacketHeader>(), typeof(PacketHeader));
}
/// <summary>
/// 反序列化消息包。
/// </summary>
/// <param name="packetHeader">消息包头。</param>
/// <param name="source">要反序列化的来源流。</param>
/// <param name="customErrorData">用户自定义错误数据。</param>
/// <returns>反序列化后的消息包。</returns>
public Packet DeserializePacket(IPacketHeader packetHeader, Stream source, out object customErrorData)
{
// 注意:此函数并不在主线程调用!
customErrorData = null;
PacketHeader scPacketHeader = packetHeader as PacketHeader;
if (scPacketHeader == null)
{
Log.Warning("Packet header is invalid.");
return null;
}
Packet packet = null;
if (scPacketHeader.IsValid)
{
Type packetType = GetServerToClientPacketType(scPacketHeader.Id);
if (packetType != null)
{
packet = (Packet)RuntimeTypeModel.Default.DeserializeWithLengthPrefix(source, MemoryPool.Acquire(packetType), packetType, PrefixStyle.Fixed32, 0);
}
else
{
Log.Warning("Can not deserialize packet for packet id '{0}'.", scPacketHeader.Id.ToString());
}
}
else
{
Log.Warning("Packet header is invalid.");
}
MemoryPool.Release(scPacketHeader);
return packet;
}
private Type GetServerToClientPacketType(int id)
{
if (_serverToClientPacketTypes.TryGetValue(id, out var type))
{
return type;
}
return null;
}
private void OnNetworkConnected(INetworkChannel channel, object userdata)
{
if (channel != _networkChannel)
{
return;
}
Log.Info("Network channel '{0}' connected, local address '{1}', remote address '{2}'.",
channel.Name, channel.Socket.LocalEndPoint.ToString(),
channel.Socket.RemoteEndPoint.ToString());
}
private void OnNetworkClosed(INetworkChannel channel)
{
if (channel != _networkChannel)
{
return;
}
Log.Info("Network channel '{0}' closed.", channel.Name);
}
private void OnNetworkMissHeartBeat(INetworkChannel channel, int missCount)
{
if (channel != _networkChannel)
{
return;
}
Log.Fatal("Network channel '{0}' miss heart beat '{1}' times.", channel.Name, missCount.ToString());
if (missCount < 2)
{
return;
}
channel.Close();
}
private void OnNetworkError(INetworkChannel channel, NetworkErrorCode networkErrorCode, SocketError socketError, string errorMessage)
{
if (channel != _networkChannel)
{
return;
}
Log.Fatal("Network channel '{0}' error, error code is '{1}', error message is '{2}'.", channel.Name, networkErrorCode.ToString(), errorMessage);
channel.Close();
}
private void OnNetworkCustomError(INetworkChannel channel, object userData)
{
if (channel != _networkChannel)
{
return;
}
}
public void Clear()
{
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: bf86ce2ddfb5429abecfb06257c86acd
timeCreated: 1682045961

View File

@@ -1,24 +0,0 @@
using TEngine;
namespace GameLogic
{
/// <summary>
/// 网络消息包基类。
/// </summary>
public abstract class PacketBase : Packet
{
/// <summary>
/// 网络消息包Id。
/// </summary>
public int ProtoId;
/// <summary>
/// 网络消息包包体。
/// </summary>
public byte[] ProtoBody;
public void Close()
{
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: acea4283f57644b6b4452354d23f2803
timeCreated: 1682045887

View File

@@ -1,47 +0,0 @@
using TEngine;
namespace GameLogic
{
/// <summary>
/// 网络消息包头。
/// </summary>
public class PacketHeader : IPacketHeader, IMemory
{
/// <summary>
/// 网络消息包Id。
/// </summary>
public short Id
{
get;
set;
}
/// <summary>
/// 网络消息包长度。
/// </summary>
public int PacketLength
{
get;
set;
}
/// <summary>
/// 网络消息包是否合法。
/// </summary>
public bool IsValid
{
get
{
return PacketLength >= 0;
}
}
/// <summary>
/// 清除网络消息包头。
/// </summary>
public void Clear()
{
PacketLength = 0;
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 30edc133b73141598b5351d4afc2ad93
timeCreated: 1682046771

View File

@@ -1,15 +0,0 @@
namespace GameLogic
{
/// <summary>
/// 网络消息包。
/// </summary>
public partial class ProtoPacket : PacketBase
{
public override int Id => 1;
public override void Clear()
{
Close();
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: da70995486db4799baba570b1767ab86
timeCreated: 1682045865

View File

@@ -1,138 +0,0 @@
// using System;
// using System.ComponentModel;
// using System.IO;
// using ProtoBuf;
// using ProtoBuf.Meta;
//
// /// <summary>
// /// ProtoBuf工具
// /// </summary>
// public class ProtobufUtils
// {
// /// <summary>
// /// 消息压入内存流。
// /// </summary>
// /// <param name="message"></param>
// /// <param name="stream"></param>
// public static void ToStream(object message, MemoryStream stream)
// {
// ((IMessage)message).WriteTo(stream);
// }
//
// /// <summary>
// /// 比特流解析。
// /// </summary>
// /// <param name="type"></param>
// /// <param name="bytes"></param>
// /// <param name="index"></param>
// /// <param name="count"></param>
// /// <returns></returns>
// public static object FromBytes(Type type, byte[] bytes, int index, int count)
// {
// object message = Activator.CreateInstance(type);
// ((IMessage)message).MergeFrom(bytes, index, count);
// ISupportInitialize iSupportInitialize = message as ISupportInitialize;
// if (iSupportInitialize == null)
// {
// return message;
// }
//
// iSupportInitialize.EndInit();
// return message;
// }
//
// /// <summary>
// /// 比特流解析。
// /// </summary>
// /// <param name="instance"></param>
// /// <param name="bytes"></param>
// /// <param name="index"></param>
// /// <param name="count"></param>
// /// <returns></returns>
// public static object FromBytes(object instance, byte[] bytes, int index, int count)
// {
// object message = instance;
// ((IMessage)message).MergeFrom(bytes, index, count);
// ISupportInitialize iSupportInitialize = message as ISupportInitialize;
// if (iSupportInitialize == null)
// {
// return message;
// }
//
// iSupportInitialize.EndInit();
// return message;
// }
//
// /// <summary>
// /// 从内存流取出。
// /// </summary>
// /// <param name="type"></param>
// /// <param name="stream"></param>
// /// <returns></returns>
// public static object FromStream(Type type, MemoryStream stream)
// {
// object message = Activator.CreateInstance(type);
// ((IMessage)message).MergeFrom(stream.GetBuffer(), (int)stream.Position, (int)stream.Length);
// ISupportInitialize iSupportInitialize = message as ISupportInitialize;
// if (iSupportInitialize == null)
// {
// return message;
// }
//
// iSupportInitialize.EndInit();
// return message;
// }
//
// /// <summary>
// /// 从内存流取出。
// /// </summary>
// /// <param name="message"></param>
// /// <param name="stream"></param>
// /// <returns></returns>
// public static object FromStream(object message, MemoryStream stream)
// {
// // TODO 这个message最好从池中获取减少gc
// ((IMessage)message).MergeFrom(stream.GetBuffer(), (int)stream.Position, (int)stream.Length);
// ISupportInitialize iSupportInitialize = message as ISupportInitialize;
// if (iSupportInitialize == null)
// {
// return message;
// }
//
// iSupportInitialize.EndInit();
// return message;
// }
//
// /// <summary>
// /// 序列化protobuf
// /// </summary>
// /// <param name="message"></param>
// /// <returns></returns>
// public static byte[] Serialize(object message)
// {
// return ((IMessage)message).ToByteArray();
// }
//
// /// <summary>
// /// 反序列化protobuf
// /// </summary>
// /// <typeparam name="T"></typeparam>
// /// <param name="dataBytes"></param>
// /// <returns></returns>
// public static T Deserialize<T>(byte[] dataBytes) where T : IMessage, new()
// {
// T msg = new T();
// msg = (T)msg.Descriptor.Parser.ParseFrom(dataBytes);
// return msg;
// }
//
// public static int GetHighOrder(int cmdMerge)
// {
// return cmdMerge >> 16;
// }
//
// public static int GetLowOrder(int cmdMerge)
// {
// return cmdMerge & 65535;
// }
// }

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 972ca4545003463d8710de956f0fde66
timeCreated: 1682047511

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 12517ef95f49a9144b18989aa8097420
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 0468386ed52c42b46a0b6df1601bc5e1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,113 +0,0 @@
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using TEngine;
public static class UIExtension
{
#region SetActive
public static void SetActive(this GameObject go, bool value, ref bool cacheValue)
{
if (go != null && value != cacheValue)
{
cacheValue = value;
go.SetActive(value);
}
}
#endregion
public static IEnumerator FadeToAlpha(this CanvasGroup canvasGroup, float alpha, float duration,
Action callback = null)
{
float time = 0f;
float originalAlpha = canvasGroup.alpha;
while (time < duration)
{
time += Time.deltaTime;
canvasGroup.alpha = Mathf.Lerp(originalAlpha, alpha, time / duration);
yield return new WaitForEndOfFrame();
}
canvasGroup.alpha = alpha;
callback?.Invoke();
}
public static IEnumerator SmoothValue(this Slider slider, float value, float duration, Action callback = null)
{
float time = 0f;
float originalValue = slider.value;
while (time < duration)
{
time += Time.deltaTime;
slider.value = Mathf.Lerp(originalValue, value, time / duration);
yield return new WaitForEndOfFrame();
}
slider.value = value;
callback?.Invoke();
}
public static IEnumerator SmoothValue(this Scrollbar slider, float value, float duration, Action callback = null)
{
float time = 0f;
float originalValue = slider.size;
while (time < duration)
{
time += Time.deltaTime;
slider.size = Mathf.Lerp(originalValue, value, time / duration);
yield return new WaitForEndOfFrame();
}
slider.size = value;
callback?.Invoke();
}
public static IEnumerator SmoothValue(this Image image, float value, float duration, Action callback = null)
{
float time = 0f;
float originalValue = image.fillAmount;
while (time < duration)
{
time += Time.deltaTime;
image.fillAmount = Mathf.Lerp(originalValue, value, time / duration);
yield return new WaitForEndOfFrame();
}
image.fillAmount = value;
callback?.Invoke();
}
public static bool GetMouseDownUiPos(this UIModule uiModule, out Vector3 screenPos)
{
bool hadMouseDown = false;
Vector3 mousePos = Vector3.zero;
#if UNITY_EDITOR || PLATFORM_STANDALONE_WIN
mousePos = Input.mousePosition;
hadMouseDown = Input.GetMouseButton(0);
#else
if (Input.touchCount > 0)
{
mousePos = Input.GetTouch(0).position;
hadMouseDown = true;
}
else
{
hadMouseDown = false;
}
#endif
RectTransformUtility.ScreenPointToLocalPointInRectangle(
uiModule.UIRoot as RectTransform,
mousePos,
uiModule.UICamera, out var pos);
screenPos = uiModule.UIRoot.TransformPoint(pos);
return hadMouseDown;
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: d376f2d7d7324712998e19cfa2e03039
timeCreated: 1680161323

View File

@@ -1,76 +0,0 @@
using Bright.Serialization;
using System.IO;
using GameBase;
using GameConfig;
using SimpleJSON;
using UnityEngine;
/// <summary>
/// 配置加载器
/// </summary>
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>($"{SettingsUtils.FrameworkGlobalSettings.ConfigFolderName}{file}.json");
var ret = textAssets.text;
#endif
return JSON.Parse(ret);
}
/// <summary>
/// 加载二进制配置。
/// </summary>
/// <param name="file">FileName</param>
/// <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>($"{SettingsUtils.FrameworkGlobalSettings.ConfigFolderName}{file}.bytes");
ret = textAssets.bytes;
#endif
return new ByteBuf(ret);
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: abc35c855bfb323429a1d72066c8489c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,65 +0,0 @@
using System;
using System.Collections.Generic;
using TEngine;
namespace GameProto
{
/// <summary>
/// 指定Key委托。
/// </summary>
/// <typeparam name="TKey">键。</typeparam>
/// <typeparam name="TValue">值。</typeparam>
public delegate TKey ConvertDictionaryKey<out TKey, in TValue>(TValue val);
/// <summary>
/// 配置表辅助工具。
/// </summary>
public static class ConfigUtility
{
/// <summary>
/// 生成64long的主键。
/// </summary>
/// <param name="key1">键1。</param>
/// <param name="key2">键2。</param>
/// <returns>64long的主键。</returns>
public static UInt64 Make64Key(uint key1, uint key2)
{
return ((UInt64)key1 << 32) | key2;
}
/// <summary>
/// 拷贝配置表字典。
/// </summary>
/// <param name="dict">拷贝地址。</param>
/// <param name="source">拷贝源。</param>
/// <param name="convKey">指定主键。</param>
/// <typeparam name="TKey">键。</typeparam>
/// <typeparam name="TValue">值。</typeparam>
/// <returns>是否拷贝成功。</returns>
public static bool CopyConfigDict<TKey, TValue>(ref Dictionary<TKey, TValue> dict,List<TValue> source, ConvertDictionaryKey<TKey, TValue> convKey)
{
if (source == null)
{
return false;
}
dict.Clear();
bool failed = false;
for (int i = 0; i < source.Count; i++)
{
var data = source[i];
TKey key = convKey(data);
if (dict.ContainsKey(key))
{
Log.Fatal("Copy Config Failed: {0} IndexOf {1} Had Repeated Key: {2} ", typeof(TValue).Name, i + 1, key);
failed = true;
break;
}
dict.Add(key, data);
}
return !failed;
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: e278e636820842f293e2a765962ad4f8
timeCreated: 1683300170

View File

@@ -1,32 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace GameConfig.Battle
{
public enum ActorAttrAddType
{
/// <summary>
/// 无效数据
/// </summary>
NONE = 0,
/// <summary>
/// 加法计算
/// </summary>
ABSOLUTE_VAL = 1,
/// <summary>
/// 多个项结果累加,然后对加法做乘法
/// </summary>
SUM_PERCENT_VAL = 2,
/// <summary>
/// 每一项都是对最终结果做乘法
/// </summary>
MUL_PERCENT_VAL = 3,
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 073f19ae3fef26f43b193ff35a27eb9c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,88 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace GameConfig.Battle
{
public enum ActorAttrDataType
{
/// <summary>
/// 无效数据
/// </summary>
None = 0,
/// <summary>
/// 最大血量
/// </summary>
MaxHp = 1,
/// <summary>
/// 攻击力
/// </summary>
Attack = 2,
/// <summary>
/// 物理伤害
/// </summary>
PhyDamage = 3,
/// <summary>
/// 物理防御
/// </summary>
PhyDef = 4,
/// <summary>
/// 法术伤害
/// </summary>
MagicDamage = 5,
/// <summary>
/// 法术防御
/// </summary>
MagicDef = 6,
/// <summary>
/// 移动速度
/// </summary>
MoveSpeed = 7,
/// <summary>
/// 攻击速度
/// </summary>
AttackSpeed = 8,
/// <summary>
/// 命中率
/// </summary>
Hit = 9,
/// <summary>
/// 闪避率
/// </summary>
Dodge = 10,
/// <summary>
/// 暴击率
/// </summary>
CriticalAtkRatio = 11,
/// <summary>
/// San值(疯狂值)
/// </summary>
SanValue = 12,
/// <summary>
/// 最大MP
/// </summary>
MaxMp = 13,
/// <summary>
/// 物理伤害倍率
/// </summary>
PhyDamageRatio = 14,
/// <summary>
/// 魔法伤害倍率
/// </summary>
MagicDamageRatio = 15,
/// <summary>
/// 暴击倍率
/// </summary>
CriticalRatio = 16,
/// <summary>
/// 暴击减免
/// </summary>
CriticalReduce = 17,
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 89dbbbd30b2f8c74f86ede4e27591ba7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,116 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.Battle
{
public sealed partial class BuffAttrConfig : Bright.Config.BeanBase
{
public BuffAttrConfig(JSONNode _json)
{
{ if(!_json["BuffID"].IsNumber) { throw new SerializationException(); } BuffID = _json["BuffID"]; }
{ if(!_json["name"].IsString) { throw new SerializationException(); } Name = _json["name"]; }
{ if(!_json["StackNum"].IsNumber) { throw new SerializationException(); } StackNum = _json["StackNum"]; }
{ if(!_json["DurTime"].IsNumber) { throw new SerializationException(); } DurTime = _json["DurTime"]; }
{ if(!_json["ResultType"].IsNumber) { throw new SerializationException(); } ResultType = (Battle.BuffResultType)_json["ResultType"].AsInt; }
{ if(!_json["RemoveWhenDie"].IsNumber) { throw new SerializationException(); } RemoveWhenDie = _json["RemoveWhenDie"]; }
{ if(!_json["DotDamageData"].IsObject) { throw new SerializationException(); } DotDamageData = Battle.SkillAttrDamageData.DeserializeSkillAttrDamageData(_json["DotDamageData"]); }
{ if(!_json["DotTickConfig"].IsObject) { throw new SerializationException(); } DotTickConfig = Battle.BuffDotTickConfig.DeserializeBuffDotTickConfig(_json["DotTickConfig"]); }
{ var __json0 = _json["AttrData"]; if(!__json0.IsArray) { throw new SerializationException(); } AttrData = new System.Collections.Generic.List<Battle.ResAttrImpactData>(__json0.Count); foreach(JSONNode __e0 in __json0.Children) { Battle.ResAttrImpactData __v0; { if(!__e0.IsObject) { throw new SerializationException(); } __v0 = Battle.ResAttrImpactData.DeserializeResAttrImpactData(__e0); } AttrData.Add(__v0); } }
PostInit();
}
public BuffAttrConfig(int BuffID, string name, int StackNum, float DurTime, Battle.BuffResultType ResultType, int RemoveWhenDie, Battle.SkillAttrDamageData DotDamageData, Battle.BuffDotTickConfig DotTickConfig, System.Collections.Generic.List<Battle.ResAttrImpactData> AttrData )
{
this.BuffID = BuffID;
this.Name = name;
this.StackNum = StackNum;
this.DurTime = DurTime;
this.ResultType = ResultType;
this.RemoveWhenDie = RemoveWhenDie;
this.DotDamageData = DotDamageData;
this.DotTickConfig = DotTickConfig;
this.AttrData = AttrData;
PostInit();
}
public static BuffAttrConfig DeserializeBuffAttrConfig(JSONNode _json)
{
return new Battle.BuffAttrConfig(_json);
}
/// <summary>
/// BuffID
/// </summary>
public int BuffID { get; private set; }
/// <summary>
/// 名字
/// </summary>
public string Name { get; private set; }
/// <summary>
/// 叠加次数
/// </summary>
public int StackNum { get; private set; }
/// <summary>
/// 持续时间
/// </summary>
public float DurTime { get; private set; }
/// <summary>
/// 数值效果类型
/// </summary>
public Battle.BuffResultType ResultType { get; private set; }
/// <summary>
/// 死亡消失
/// </summary>
public int RemoveWhenDie { get; private set; }
public Battle.SkillAttrDamageData DotDamageData { get; private set; }
public Battle.BuffDotTickConfig DotTickConfig { get; private set; }
public System.Collections.Generic.List<Battle.ResAttrImpactData> AttrData { get; private set; }
public const int __ID__ = 1652935996;
public override int GetTypeId() => __ID__;
public void Resolve(Dictionary<string, object> _tables)
{
DotDamageData?.Resolve(_tables);
DotTickConfig?.Resolve(_tables);
foreach(var _e in AttrData) { _e?.Resolve(_tables); }
PostResolve();
}
public void TranslateText(System.Func<string, string, string> translator)
{
DotDamageData?.TranslateText(translator);
DotTickConfig?.TranslateText(translator);
foreach(var _e in AttrData) { _e?.TranslateText(translator); }
}
public override string ToString()
{
return "{ "
+ "BuffID:" + BuffID + ","
+ "Name:" + Name + ","
+ "StackNum:" + StackNum + ","
+ "DurTime:" + DurTime + ","
+ "ResultType:" + ResultType + ","
+ "RemoveWhenDie:" + RemoveWhenDie + ","
+ "DotDamageData:" + DotDamageData + ","
+ "DotTickConfig:" + DotTickConfig + ","
+ "AttrData:" + Bright.Common.StringUtil.CollectionToString(AttrData) + ","
+ "}";
}
partial void PostInit();
partial void PostResolve();
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 5224da34dfb42c141b22335957c1b784
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,111 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.Battle
{
public sealed partial class BuffConfig : Bright.Config.BeanBase
{
public BuffConfig(JSONNode _json)
{
{ if(!_json["BuffID"].IsNumber) { throw new SerializationException(); } BuffID = _json["BuffID"]; }
{ if(!_json["name"].IsString) { throw new SerializationException(); } Name = _json["name"]; }
{ if(!_json["prefId"].IsNumber) { throw new SerializationException(); } PrefId = _json["prefId"]; }
{ if(!_json["desc"].IsString) { throw new SerializationException(); } Desc = _json["desc"]; }
{ if(!_json["icon"].IsString) { throw new SerializationException(); } Icon = _json["icon"]; }
{ if(!_json["TimeType"].IsNumber) { throw new SerializationException(); } TimeType = (Battle.BuffTimeType)_json["TimeType"].AsInt; }
{ if(!_json["ReplaceType"].IsNumber) { throw new SerializationException(); } ReplaceType = (Battle.BuffReplaceType)_json["ReplaceType"].AsInt; }
{ if(!_json["State"].IsObject) { throw new SerializationException(); } State = Battle.BuffTriggleState.DeserializeBuffTriggleState(_json["State"]); }
PostInit();
}
public BuffConfig(int BuffID, string name, int prefId, string desc, string icon, Battle.BuffTimeType TimeType, Battle.BuffReplaceType ReplaceType, Battle.BuffTriggleState State )
{
this.BuffID = BuffID;
this.Name = name;
this.PrefId = prefId;
this.Desc = desc;
this.Icon = icon;
this.TimeType = TimeType;
this.ReplaceType = ReplaceType;
this.State = State;
PostInit();
}
public static BuffConfig DeserializeBuffConfig(JSONNode _json)
{
return new Battle.BuffConfig(_json);
}
/// <summary>
/// BuffID
/// </summary>
public int BuffID { get; private set; }
/// <summary>
/// 名字
/// </summary>
public string Name { get; private set; }
/// <summary>
/// 表现ID
/// </summary>
public int PrefId { get; private set; }
/// <summary>
/// 描述
/// </summary>
public string Desc { get; private set; }
/// <summary>
/// 图标
/// </summary>
public string Icon { get; private set; }
/// <summary>
/// 持续类型
/// </summary>
public Battle.BuffTimeType TimeType { get; private set; }
/// <summary>
/// 叠加类型
/// </summary>
public Battle.BuffReplaceType ReplaceType { get; private set; }
public Battle.BuffTriggleState State { get; private set; }
public const int __ID__ = 1807662187;
public override int GetTypeId() => __ID__;
public void Resolve(Dictionary<string, object> _tables)
{
State?.Resolve(_tables);
PostResolve();
}
public void TranslateText(System.Func<string, string, string> translator)
{
State?.TranslateText(translator);
}
public override string ToString()
{
return "{ "
+ "BuffID:" + BuffID + ","
+ "Name:" + Name + ","
+ "PrefId:" + PrefId + ","
+ "Desc:" + Desc + ","
+ "Icon:" + Icon + ","
+ "TimeType:" + TimeType + ","
+ "ReplaceType:" + ReplaceType + ","
+ "State:" + State + ","
+ "}";
}
partial void PostInit();
partial void PostResolve();
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 6b4f7b8798a4dca4ca075552d618f24d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,64 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.Battle
{
public sealed partial class BuffDotTickConfig : Bright.Config.BeanBase
{
public BuffDotTickConfig(JSONNode _json)
{
{ if(!_json["TickTime"].IsNumber) { throw new SerializationException(); } TickTime = _json["TickTime"]; }
{ if(!_json["TickWhenAdd"].IsNumber) { throw new SerializationException(); } TickWhenAdd = _json["TickWhenAdd"]; }
PostInit();
}
public BuffDotTickConfig(float TickTime, int TickWhenAdd )
{
this.TickTime = TickTime;
this.TickWhenAdd = TickWhenAdd;
PostInit();
}
public static BuffDotTickConfig DeserializeBuffDotTickConfig(JSONNode _json)
{
return new Battle.BuffDotTickConfig(_json);
}
public float TickTime { get; private set; }
public int TickWhenAdd { get; private set; }
public const int __ID__ = 2124630047;
public override int GetTypeId() => __ID__;
public void Resolve(Dictionary<string, object> _tables)
{
PostResolve();
}
public void TranslateText(System.Func<string, string, string> translator)
{
}
public override string ToString()
{
return "{ "
+ "TickTime:" + TickTime + ","
+ "TickWhenAdd:" + TickWhenAdd + ","
+ "}";
}
partial void PostInit();
partial void PostResolve();
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 3b87372c0c0ce0547bc2221f8f8cc7dc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,36 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace GameConfig.Battle
{
public enum BuffReplaceType
{
/// <summary>
/// 更新时间范围
/// </summary>
BUFF_REPLACE_INSTEAD = 0,
/// <summary>
/// 不允许叠加
/// </summary>
BUFF_REPLACE_FORBIT = 1,
/// <summary>
/// 累加时间范围
/// </summary>
BUFF_REPLACE_ADD_TIME = 2,
/// <summary>
/// 叠加数值
/// </summary>
BUFF_REPLACE_ADD_ATTR = 3,
/// <summary>
/// 叠加种类
/// </summary>
BUFF_REPLACE_TYPE_COUNT = 4,
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 6141f2c1272ed3848baf1f8d3341fc79
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,100 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace GameConfig.Battle
{
public enum BuffResultType
{
/// <summary>
/// 无
/// </summary>
BUFF_RESULT_NONE = 0,
/// <summary>
/// 物理攻击提升
/// </summary>
BUFF_RESULT_PHY_ATK_UP = 1,
/// <summary>
/// 物理攻击降低
/// </summary>
BUFF_RESULT_PHY_ATK_DOWN = 2,
/// <summary>
/// 物理防御提升
/// </summary>
BUFF_RESULT_PHY_DEF_UP = 3,
/// <summary>
/// 物理防御降低
/// </summary>
BUFF_RESULT_PHY_DEF_DOWN = 4,
/// <summary>
/// 物理命中提升
/// </summary>
BUFF_RESULT_PHY_HIT_UP = 5,
/// <summary>
/// 物理命中降低
/// </summary>
BUFF_RESULT_PHY_HIT_DOWN = 6,
/// <summary>
/// 物理持续掉血
/// </summary>
BUFF_RESULT_PHY_LOSE_HP = 7,
/// <summary>
/// 法术攻击提升
/// </summary>
BUFF_RESULT_MAG_ATK_UP = 8,
/// <summary>
/// 法术攻击降低
/// </summary>
BUFF_RESULT_MAG_ATK_DOWN = 9,
/// <summary>
/// 法术防御提升
/// </summary>
BUFF_RESULT_MAG_DEF_UP = 10,
/// <summary>
/// 法术防御降低
/// </summary>
BUFF_RESULT_MAG_DEF_DOWN = 11,
/// <summary>
/// 法术命中提升
/// </summary>
BUFF_RESULT_MAG_HIT_UP = 12,
/// <summary>
/// 法术命中降低
/// </summary>
BUFF_RESULT_MAG_HIT_DOWN = 13,
/// <summary>
/// 法术持续掉血
/// </summary>
BUFF_RESULT_MAG_LOSE_HP = 14,
/// <summary>
/// 暴击率提升
/// </summary>
BUFF_RESULT_CIRT_UP = 15,
/// <summary>
/// 暴击率降低
/// </summary>
BUFF_RESULT_CIRT_DOWN = 16,
/// <summary>
/// 暴击倍率提升
/// </summary>
BUFF_RESULT_CIRT_VALUE_UP = 17,
/// <summary>
/// 暴击倍率降低
/// </summary>
BUFF_RESULT_CIRT_VALUE_DOWN = 18,
/// <summary>
/// 移速提升
/// </summary>
BUFF_RESULT_MOVE_SPEED_UP = 19,
/// <summary>
/// 移速降低
/// </summary>
BUFF_RESULT_MOVE_SPEED_DOWN = 20,
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 2e26edcf2629cd142b51031f7b81f679
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,60 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace GameConfig.Battle
{
public enum BuffStateID
{
/// <summary>
/// 无状态
/// </summary>
BUFF_STATE_NONE = 0,
/// <summary>
/// 眩晕状态
/// </summary>
BUFF_STATE_STUN = 1,
/// <summary>
/// 无敌状态
/// </summary>
BUFF_STATE_UNDEAD = 2,
/// <summary>
/// 隐身状态
/// </summary>
BUFF_STATE_INVISIBLE = 3,
/// <summary>
/// 体形变大
/// </summary>
BUFF_STATE_BIGGER = 4,
/// <summary>
/// 定身,不能移动
/// </summary>
BUFF_STATE_NO_MOVE = 5,
/// <summary>
/// 沉默,不能放技能
/// </summary>
BUFF_STATE_NO_SKILL = 6,
/// <summary>
/// 昏睡
/// </summary>
BUFF_STATE_SLEEP = 7,
/// <summary>
/// 强制开启阻挡
/// </summary>
BUFF_STATE_FORCE_COLLIDER = 8,
/// <summary>
/// 无视阻挡
/// </summary>
BUFF_STATE_IGNORE_COLLIDER = 9,
/// <summary>
/// 最大状态
/// </summary>
BUFF_STATE_MAX = 10,
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 24a5cdf7ed62f5945aba3814ebf02ae8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,24 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace GameConfig.Battle
{
public enum BuffTimeType
{
/// <summary>
/// 指定持续时间
/// </summary>
BUFF_TIME_DURING = 0,
/// <summary>
/// 无尽时间
/// </summary>
BUFF_TIME_INFINIT = 1,
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: dff2bf6f031b38d4c8574d94e75d28d1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,64 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.Battle
{
public sealed partial class BuffTriggleState : Bright.Config.BeanBase
{
public BuffTriggleState(JSONNode _json)
{
{ if(!_json["StateID"].IsNumber) { throw new SerializationException(); } StateID = (Battle.BuffStateID)_json["StateID"].AsInt; }
{ if(!_json["StateParam"].IsNumber) { throw new SerializationException(); } StateParam = _json["StateParam"]; }
PostInit();
}
public BuffTriggleState(Battle.BuffStateID StateID, float StateParam )
{
this.StateID = StateID;
this.StateParam = StateParam;
PostInit();
}
public static BuffTriggleState DeserializeBuffTriggleState(JSONNode _json)
{
return new Battle.BuffTriggleState(_json);
}
public Battle.BuffStateID StateID { get; private set; }
public float StateParam { get; private set; }
public const int __ID__ = 1328146134;
public override int GetTypeId() => __ID__;
public void Resolve(Dictionary<string, object> _tables)
{
PostResolve();
}
public void TranslateText(System.Func<string, string, string> translator)
{
}
public override string ToString()
{
return "{ "
+ "StateID:" + StateID + ","
+ "StateParam:" + StateParam + ","
+ "}";
}
partial void PostInit();
partial void PostResolve();
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 03926dd0c4ff9dd479230386fd1e9190
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,68 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.Battle
{
public sealed partial class ResAttrImpactData : Bright.Config.BeanBase
{
public ResAttrImpactData(JSONNode _json)
{
{ if(!_json["DataType"].IsNumber) { throw new SerializationException(); } DataType = (Battle.ActorAttrDataType)_json["DataType"].AsInt; }
{ if(!_json["AddType"].IsNumber) { throw new SerializationException(); } AddType = (Battle.ActorAttrAddType)_json["AddType"].AsInt; }
{ if(!_json["Value"].IsNumber) { throw new SerializationException(); } Value = _json["Value"]; }
PostInit();
}
public ResAttrImpactData(Battle.ActorAttrDataType DataType, Battle.ActorAttrAddType AddType, float Value )
{
this.DataType = DataType;
this.AddType = AddType;
this.Value = Value;
PostInit();
}
public static ResAttrImpactData DeserializeResAttrImpactData(JSONNode _json)
{
return new Battle.ResAttrImpactData(_json);
}
public Battle.ActorAttrDataType DataType { get; private set; }
public Battle.ActorAttrAddType AddType { get; private set; }
public float Value { get; private set; }
public const int __ID__ = 1319292907;
public override int GetTypeId() => __ID__;
public void Resolve(Dictionary<string, object> _tables)
{
PostResolve();
}
public void TranslateText(System.Func<string, string, string> translator)
{
}
public override string ToString()
{
return "{ "
+ "DataType:" + DataType + ","
+ "AddType:" + AddType + ","
+ "Value:" + Value + ","
+ "}";
}
partial void PostInit();
partial void PostResolve();
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 9d3720a9d26e66047ad302fd1dc92da5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,80 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.Battle
{
public sealed partial class SkillAttrDamageData : Bright.Config.BeanBase
{
public SkillAttrDamageData(JSONNode _json)
{
{ if(!_json["MagicType"].IsNumber) { throw new SerializationException(); } MagicType = (Battle.SkillMagicType)_json["MagicType"].AsInt; }
{ if(!_json["AttrType"].IsNumber) { throw new SerializationException(); } AttrType = (Battle.SkillAttrDamageType)_json["AttrType"].AsInt; }
{ if(!_json["Param1"].IsNumber) { throw new SerializationException(); } Param1 = _json["Param1"]; }
{ if(!_json["Param2"].IsNumber) { throw new SerializationException(); } Param2 = _json["Param2"]; }
{ if(!_json["Param3"].IsNumber) { throw new SerializationException(); } Param3 = _json["Param3"]; }
{ if(!_json["MaxLimit"].IsNumber) { throw new SerializationException(); } MaxLimit = _json["MaxLimit"]; }
PostInit();
}
public SkillAttrDamageData(Battle.SkillMagicType MagicType, Battle.SkillAttrDamageType AttrType, float Param1, float Param2, float Param3, float MaxLimit )
{
this.MagicType = MagicType;
this.AttrType = AttrType;
this.Param1 = Param1;
this.Param2 = Param2;
this.Param3 = Param3;
this.MaxLimit = MaxLimit;
PostInit();
}
public static SkillAttrDamageData DeserializeSkillAttrDamageData(JSONNode _json)
{
return new Battle.SkillAttrDamageData(_json);
}
public Battle.SkillMagicType MagicType { get; private set; }
public Battle.SkillAttrDamageType AttrType { get; private set; }
public float Param1 { get; private set; }
public float Param2 { get; private set; }
public float Param3 { get; private set; }
public float MaxLimit { get; private set; }
public const int __ID__ = -94519547;
public override int GetTypeId() => __ID__;
public void Resolve(Dictionary<string, object> _tables)
{
PostResolve();
}
public void TranslateText(System.Func<string, string, string> translator)
{
}
public override string ToString()
{
return "{ "
+ "MagicType:" + MagicType + ","
+ "AttrType:" + AttrType + ","
+ "Param1:" + Param1 + ","
+ "Param2:" + Param2 + ","
+ "Param3:" + Param3 + ","
+ "MaxLimit:" + MaxLimit + ","
+ "}";
}
partial void PostInit();
partial void PostResolve();
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 485330d35ed83074e98aee4f9afebff7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,40 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace GameConfig.Battle
{
public enum SkillAttrDamageType
{
/// <summary>
/// 无数值
/// </summary>
ATTR_TYPE_NONE = 0,
/// <summary>
/// 按释放者的伤害类型*X%+固定值计算,目标有防御计算
/// </summary>
ATTR_TYPE_DMG_WEAPON = 1,
/// <summary>
/// 按释放者的伤害类型*X%+固定值计算(无视目标的防御)
/// </summary>
ATTR_TYPE_DMG_NO_DEFEND = 2,
/// <summary>
/// 按受击者的气血上限*X%+固定值计算(无视目标的防御)
/// </summary>
ATTR_TYPE_DMG_TARGET_HP_NO_DEFEND = 3,
/// <summary>
/// 按释放者的攻击类型*X%+固定值计算,恢复当前生命
/// </summary>
ATTR_TYPE_HP_AS_ATK = 4,
/// <summary>
/// 按受击者的HP上限*X%+固定值计算,恢复当前生命
/// </summary>
ATTR_TYPE_HP_RATIO = 5,
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: a875b3c697d164841b02d808b103a384
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,132 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.Battle
{
public sealed partial class SkillBaseConfig : Bright.Config.BeanBase
{
public SkillBaseConfig(JSONNode _json)
{
{ if(!_json["id"].IsNumber) { throw new SerializationException(); } Id = _json["id"]; }
{ if(!_json["name"].IsString) { throw new SerializationException(); } Name = _json["name"]; }
{ if(!_json["SkillDispID"].IsNumber) { throw new SerializationException(); } SkillDispID = _json["SkillDispID"]; }
{ if(!_json["SkillType"].IsNumber) { throw new SerializationException(); } SkillType = _json["SkillType"]; }
{ if(!_json["desc"].IsString) { throw new SerializationException(); } Desc = _json["desc"]; }
{ if(!_json["CostMP"].IsNumber) { throw new SerializationException(); } CostMP = _json["CostMP"]; }
{ if(!_json["GCDID"].IsNumber) { throw new SerializationException(); } GCDID = _json["GCDID"]; }
{ if(!_json["SkillCD"].IsNumber) { throw new SerializationException(); } SkillCD = _json["SkillCD"]; }
{ if(!_json["IsRepeatTrigger"].IsBoolean) { throw new SerializationException(); } IsRepeatTrigger = _json["IsRepeatTrigger"]; }
{ var __json0 = _json["BuffID"]; if(!__json0.IsArray) { throw new SerializationException(); } BuffID = new System.Collections.Generic.List<int>(__json0.Count); foreach(JSONNode __e0 in __json0.Children) { int __v0; { if(!__e0.IsNumber) { throw new SerializationException(); } __v0 = __e0; } BuffID.Add(__v0); } }
{ var __json0 = _json["AttrDamageData"]; if(!__json0.IsArray) { throw new SerializationException(); } AttrDamageData = new System.Collections.Generic.List<Battle.SkillAttrDamageData>(__json0.Count); foreach(JSONNode __e0 in __json0.Children) { Battle.SkillAttrDamageData __v0; { if(!__e0.IsObject) { throw new SerializationException(); } __v0 = Battle.SkillAttrDamageData.DeserializeSkillAttrDamageData(__e0); } AttrDamageData.Add(__v0); } }
PostInit();
}
public SkillBaseConfig(int id, string name, int SkillDispID, int SkillType, string desc, int CostMP, int GCDID, float SkillCD, bool IsRepeatTrigger, System.Collections.Generic.List<int> BuffID, System.Collections.Generic.List<Battle.SkillAttrDamageData> AttrDamageData )
{
this.Id = id;
this.Name = name;
this.SkillDispID = SkillDispID;
this.SkillType = SkillType;
this.Desc = desc;
this.CostMP = CostMP;
this.GCDID = GCDID;
this.SkillCD = SkillCD;
this.IsRepeatTrigger = IsRepeatTrigger;
this.BuffID = BuffID;
this.AttrDamageData = AttrDamageData;
PostInit();
}
public static SkillBaseConfig DeserializeSkillBaseConfig(JSONNode _json)
{
return new Battle.SkillBaseConfig(_json);
}
/// <summary>
/// 技能ID
/// </summary>
public int Id { get; private set; }
/// <summary>
/// 名字
/// </summary>
public string Name { get; private set; }
/// <summary>
/// 表现ID
/// </summary>
public int SkillDispID { get; private set; }
/// <summary>
/// 技能类型SkillType
/// </summary>
public int SkillType { get; private set; }
/// <summary>
/// 描述
/// </summary>
public string Desc { get; private set; }
/// <summary>
/// 消耗MP
/// </summary>
public int CostMP { get; private set; }
/// <summary>
/// 所属公CD组ID
/// </summary>
public int GCDID { get; private set; }
/// <summary>
/// 技能CD
/// </summary>
public float SkillCD { get; private set; }
/// <summary>
/// 是否重复触发
/// </summary>
public bool IsRepeatTrigger { get; private set; }
/// <summary>
/// BuffIDList
/// </summary>
public System.Collections.Generic.List<int> BuffID { get; private set; }
public System.Collections.Generic.List<Battle.SkillAttrDamageData> AttrDamageData { get; private set; }
public const int __ID__ = 2067672430;
public override int GetTypeId() => __ID__;
public void Resolve(Dictionary<string, object> _tables)
{
foreach(var _e in AttrDamageData) { _e?.Resolve(_tables); }
PostResolve();
}
public void TranslateText(System.Func<string, string, string> translator)
{
foreach(var _e in AttrDamageData) { _e?.TranslateText(translator); }
}
public override string ToString()
{
return "{ "
+ "Id:" + Id + ","
+ "Name:" + Name + ","
+ "SkillDispID:" + SkillDispID + ","
+ "SkillType:" + SkillType + ","
+ "Desc:" + Desc + ","
+ "CostMP:" + CostMP + ","
+ "GCDID:" + GCDID + ","
+ "SkillCD:" + SkillCD + ","
+ "IsRepeatTrigger:" + IsRepeatTrigger + ","
+ "BuffID:" + Bright.Common.StringUtil.CollectionToString(BuffID) + ","
+ "AttrDamageData:" + Bright.Common.StringUtil.CollectionToString(AttrDamageData) + ","
+ "}";
}
partial void PostInit();
partial void PostResolve();
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: b651cf87b4372cf4a8894a9421a6dcff
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,28 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace GameConfig.Battle
{
public enum SkillMagicType
{
/// <summary>
/// 无类型
/// </summary>
SKILL_TYPE_NONE = 0,
/// <summary>
/// 物理伤害属性
/// </summary>
SKILL_TYPE_DMG_PHY = 1,
/// <summary>
/// 魔法伤害属性
/// </summary>
SKILL_TYPE_DMG_MAGIC = 2,
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 050deaa6f717a36428b057b5c1f889b2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,65 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
using SimpleJSON;
namespace GameConfig.Battle
{
public sealed partial class TbBuff
{
private readonly Dictionary<int, Battle.BuffConfig> _dataMap;
private readonly List<Battle.BuffConfig> _dataList;
public TbBuff(JSONNode _json)
{
_dataMap = new Dictionary<int, Battle.BuffConfig>();
_dataList = new List<Battle.BuffConfig>();
foreach(JSONNode _row in _json.Children)
{
var _v = Battle.BuffConfig.DeserializeBuffConfig(_row);
_dataList.Add(_v);
_dataMap.Add(_v.BuffID, _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)
{
v.Resolve(_tables);
}
PostResolve();
}
public void TranslateText(System.Func<string, string, string> translator)
{
foreach(var v in _dataList)
{
v.TranslateText(translator);
}
}
partial void PostInit();
partial void PostResolve();
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 4bae3a42b1e627f44b53f42fa8835064
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More