Эх сурвалжийг харах

1.新的导表跟配置加载,不用对每条记录做反序列化,一次性反序列化整个表
2.UIHelper辅助类,用来创建删除UI

tanghai 5 жил өмнө
parent
commit
937a2539c3
34 өөрчлөгдсөн 142 нэмэгдсэн , 66 устгасан
  1. BIN
      Config/BuffConfig.txt
  2. 0 1
      Config/StartConfig/AllServer.txt
  3. 3 1
      Config/StartMachineConfig.txt
  4. 4 2
      Config/StartProcessConfig.txt
  5. 7 5
      Config/StartSceneConfig.txt
  6. 4 2
      Config/StartZoneConfig.txt
  7. 3 1
      Config/UnitConfig.txt
  8. BIN
      Config/graph.bytes
  9. 3 0
      Server/Model/Config/StartMachineConfig.cs
  10. 3 0
      Server/Model/Config/StartProcessConfig.cs
  11. 3 0
      Server/Model/Config/StartSceneConfig.cs
  12. 3 0
      Server/Model/Config/StartZoneConfig.cs
  13. 3 0
      Server/Model/Config/UnitConfig.cs
  14. 3 1
      Unity/Assets/Bundles/Config/StartMachineConfig.txt
  15. 4 2
      Unity/Assets/Bundles/Config/StartProcessConfig.txt
  16. 7 5
      Unity/Assets/Bundles/Config/StartSceneConfig.txt
  17. 4 2
      Unity/Assets/Bundles/Config/StartZoneConfig.txt
  18. 3 1
      Unity/Assets/Bundles/Config/UnitConfig.txt
  19. 0 10
      Unity/Assets/Editor/AstarPathfindingProject.meta
  20. 7 4
      Unity/Assets/Editor/ExcelExporterEditor/ExcelExporterEditor.cs
  21. 17 0
      Unity/Assets/HotfixView/UI/UIHelper.cs
  22. 11 0
      Unity/Assets/HotfixView/UI/UIHelper.cs.meta
  23. 12 0
      Unity/Assets/HotfixView/UI/UILogin/AfterCreateZoneScene_CreateLoginUI.cs
  24. 11 0
      Unity/Assets/HotfixView/UI/UILogin/AfterCreateZoneScene_CreateLoginUI.cs.meta
  25. 1 2
      Unity/Assets/HotfixView/UI/UILogin/LoginFinish_RemoveLoginUI.cs
  26. 3 0
      Unity/Assets/Model/Config/StartMachineConfig.cs
  27. 3 0
      Unity/Assets/Model/Config/StartProcessConfig.cs
  28. 3 0
      Unity/Assets/Model/Config/StartSceneConfig.cs
  29. 3 0
      Unity/Assets/Model/Config/StartZoneConfig.cs
  30. 3 0
      Unity/Assets/Model/Config/UnitConfig.cs
  31. 1 0
      Unity/Assets/Model/EventType.cs
  32. 8 19
      Unity/Assets/Model/Module/Config/ACategory.cs
  33. 0 8
      Unity/Assets/Model/Module/Pathfinding.meta
  34. 2 0
      Unity/Unity.HotfixView.csproj

BIN
Config/BuffConfig.txt


+ 0 - 1
Config/StartConfig/AllServer.txt

@@ -1 +0,0 @@
-{ "_t" : "StartConfig", "_id" : NumberLong(1), "List" : [{ "_id" : NumberLong(1), "C" : [{ "_t" : "ProcessConfig", "_id" : NumberLong(1), "ServerIP" : "" }, { "_t" : "InnerConfig", "_id" : NumberLong("102613898756108"), "Address" : "127.0.0.1:20000" }, { "_t" : "OuterConfig", "_id" : NumberLong("102613898887181"), "Address" : "127.0.0.1:10001", "Address2" : "127.0.0.1:10001" }, { "_t" : "SceneConfig", "_id" : NumberLong("410473928327214"), "SceneType" : 0, "Name" : "Process" }, { "_t" : "DBConfig", "ConnectionString" : "mongodb://127.0.0.1:27017/", "DBName" : "ET" }], "List" : [{ "_id" : NumberLong(1), "C" : [{ "_t" : "SceneConfig", "_id" : NumberLong(1), "SceneType" : 2, "Name" : "Realm" }], "List" : [] }, { "_id" : NumberLong(2), "C" : [{ "_t" : "SceneConfig", "_id" : NumberLong(2), "SceneType" : 3, "Name" : "Gate" }], "List" : [] }, { "_id" : NumberLong(3), "C" : [{ "_t" : "SceneConfig", "_id" : NumberLong(3), "SceneType" : 5, "Name" : "Location" }], "List" : [] }, { "_id" : NumberLong(4), "C" : [{ "_t" : "SceneConfig", "_id" : NumberLong(1), "SceneType" : 6, "Name" : "Map1" }], "List" : [] }] }] }

+ 3 - 1
Config/StartMachineConfig.txt

@@ -1 +1,3 @@
-{"_id":1,"InnerIP":"127.0.0.1","OuterIP":"127.0.0.1"}
+[
+[1, {"_id":1,"InnerIP":"127.0.0.1","OuterIP":"127.0.0.1"}],
+]

+ 4 - 2
Config/StartProcessConfig.txt

@@ -1,2 +1,4 @@
-{"_id":1,"MachineId":1,"InnerPort":"20001"}
-{"_id":2,"MachineId":1,"InnerPort":"20002"}
+[
+[1, {"_id":1,"MachineId":1,"InnerPort":"20001"}],
+[2, {"_id":2,"MachineId":1,"InnerPort":"20002"}],
+]

+ 7 - 5
Config/StartSceneConfig.txt

@@ -1,5 +1,7 @@
-{"_id":1,"Process":1,"Zone":1,"SceneType":"Realm","Name":"Realm","OuterPort":10002}
-{"_id":2,"Process":1,"Zone":1,"SceneType":"Gate","Name":"Gate1","OuterPort":10003}
-{"_id":3,"Process":1,"Zone":1,"SceneType":"Gate","Name":"Gate2","OuterPort":10004}
-{"_id":4,"Process":1,"Zone":1,"SceneType":"Location","Name":"Location"}
-{"_id":5,"Process":1,"Zone":1,"SceneType":"Map","Name":"Map"}
+[
+[1, {"_id":1,"Process":1,"Zone":1,"SceneType":"Realm","Name":"Realm","OuterPort":10002}],
+[2, {"_id":2,"Process":1,"Zone":1,"SceneType":"Gate","Name":"Gate1","OuterPort":10003}],
+[3, {"_id":3,"Process":1,"Zone":1,"SceneType":"Gate","Name":"Gate2","OuterPort":10004}],
+[4, {"_id":4,"Process":1,"Zone":1,"SceneType":"Location","Name":"Location"}],
+[5, {"_id":5,"Process":1,"Zone":1,"SceneType":"Map","Name":"Map"}],
+]

+ 4 - 2
Config/StartZoneConfig.txt

@@ -1,2 +1,4 @@
-{"_id":1,"DBConnection":"mongdb://127.0.0.1","DBName":"ET1"}
-{"_id":2,"DBConnection":"mongdb://127.0.0.1","DBName":"ET2"}
+[
+[1, {"_id":1,"DBConnection":"mongdb://127.0.0.1","DBName":"ET1"}],
+[2, {"_id":2,"DBConnection":"mongdb://127.0.0.1","DBName":"ET2"}],
+]

+ 3 - 1
Config/UnitConfig.txt

@@ -1 +1,3 @@
-{"_id":1001,"Name":"米克尔","Desc":"带有强力攻击技能","Position":1,"Height":178,"Weight":68}
+[
+[1001, {"_id":1001,"Name":"米克尔","Desc":"带有强力攻击技能","Position":1,"Height":178,"Weight":68}],
+]

BIN
Config/graph.bytes


+ 3 - 0
Server/Model/Demo/Config/StartMachineConfig.cs → Server/Model/Config/StartMachineConfig.cs

@@ -1,3 +1,5 @@
+using MongoDB.Bson.Serialization.Attributes;
+
 namespace ET
 {
 	[Config]
@@ -12,6 +14,7 @@ namespace ET
 
 	public partial class StartMachineConfig: IConfig
 	{
+		[BsonId]
 		public long Id { get; set; }
 		public string InnerIP;
 		public string OuterIP;

+ 3 - 0
Server/Model/Demo/Config/StartProcessConfig.cs → Server/Model/Config/StartProcessConfig.cs

@@ -1,3 +1,5 @@
+using MongoDB.Bson.Serialization.Attributes;
+
 namespace ET
 {
 	[Config]
@@ -12,6 +14,7 @@ namespace ET
 
 	public partial class StartProcessConfig: IConfig
 	{
+		[BsonId]
 		public long Id { get; set; }
 		public int MachineId;
 		public string InnerPort;

+ 3 - 0
Server/Model/Demo/Config/StartSceneConfig.cs → Server/Model/Config/StartSceneConfig.cs

@@ -1,3 +1,5 @@
+using MongoDB.Bson.Serialization.Attributes;
+
 namespace ET
 {
 	[Config]
@@ -12,6 +14,7 @@ namespace ET
 
 	public partial class StartSceneConfig: IConfig
 	{
+		[BsonId]
 		public long Id { get; set; }
 		public int Process;
 		public int Zone;

+ 3 - 0
Server/Model/Demo/Config/StartZoneConfig.cs → Server/Model/Config/StartZoneConfig.cs

@@ -1,3 +1,5 @@
+using MongoDB.Bson.Serialization.Attributes;
+
 namespace ET
 {
 	[Config]
@@ -12,6 +14,7 @@ namespace ET
 
 	public partial class StartZoneConfig: IConfig
 	{
+		[BsonId]
 		public long Id { get; set; }
 		public string DBConnection;
 		public string DBName;

+ 3 - 0
Server/Model/Demo/Config/UnitConfig.cs → Server/Model/Config/UnitConfig.cs

@@ -1,3 +1,5 @@
+using MongoDB.Bson.Serialization.Attributes;
+
 namespace ET
 {
 	[Config]
@@ -12,6 +14,7 @@ namespace ET
 
 	public partial class UnitConfig: IConfig
 	{
+		[BsonId]
 		public long Id { get; set; }
 		public string Name;
 		public string Desc;

+ 3 - 1
Unity/Assets/Bundles/Config/StartMachineConfig.txt

@@ -1 +1,3 @@
-{"_id":1,"InnerIP":"127.0.0.1","OuterIP":"127.0.0.1"}
+[
+[1, {"_id":1,"InnerIP":"127.0.0.1","OuterIP":"127.0.0.1"}],
+]

+ 4 - 2
Unity/Assets/Bundles/Config/StartProcessConfig.txt

@@ -1,2 +1,4 @@
-{"_id":1,"MachineId":1,"InnerPort":"20001"}
-{"_id":2,"MachineId":1,"InnerPort":"20002"}
+[
+[1, {"_id":1,"MachineId":1,"InnerPort":"20001"}],
+[2, {"_id":2,"MachineId":1,"InnerPort":"20002"}],
+]

+ 7 - 5
Unity/Assets/Bundles/Config/StartSceneConfig.txt

@@ -1,5 +1,7 @@
-{"_id":1,"Process":1,"Zone":1,"SceneType":"Realm","Name":"Realm","OuterPort":10002}
-{"_id":2,"Process":1,"Zone":1,"SceneType":"Gate","Name":"Gate1","OuterPort":10003}
-{"_id":3,"Process":1,"Zone":1,"SceneType":"Gate","Name":"Gate2","OuterPort":10004}
-{"_id":4,"Process":1,"Zone":1,"SceneType":"Location","Name":"Location"}
-{"_id":5,"Process":1,"Zone":1,"SceneType":"Map","Name":"Map"}
+[
+[1, {"_id":1,"Process":1,"Zone":1,"SceneType":"Realm","Name":"Realm","OuterPort":10002}],
+[2, {"_id":2,"Process":1,"Zone":1,"SceneType":"Gate","Name":"Gate1","OuterPort":10003}],
+[3, {"_id":3,"Process":1,"Zone":1,"SceneType":"Gate","Name":"Gate2","OuterPort":10004}],
+[4, {"_id":4,"Process":1,"Zone":1,"SceneType":"Location","Name":"Location"}],
+[5, {"_id":5,"Process":1,"Zone":1,"SceneType":"Map","Name":"Map"}],
+]

+ 4 - 2
Unity/Assets/Bundles/Config/StartZoneConfig.txt

@@ -1,2 +1,4 @@
-{"_id":1,"DBConnection":"mongdb://127.0.0.1","DBName":"ET1"}
-{"_id":2,"DBConnection":"mongdb://127.0.0.1","DBName":"ET2"}
+[
+[1, {"_id":1,"DBConnection":"mongdb://127.0.0.1","DBName":"ET1"}],
+[2, {"_id":2,"DBConnection":"mongdb://127.0.0.1","DBName":"ET2"}],
+]

+ 3 - 1
Unity/Assets/Bundles/Config/UnitConfig.txt

@@ -1 +1,3 @@
-{"_id":1001,"Name":"米克尔","Desc":"带有强力攻击技能","Position":1,"Height":178,"Weight":68}
+[
+[1001, {"_id":1001,"Name":"米克尔","Desc":"带有强力攻击技能","Position":1,"Height":178,"Weight":68}],
+]

+ 0 - 10
Unity/Assets/Editor/AstarPathfindingProject.meta

@@ -1,10 +0,0 @@
-fileFormatVersion: 2
-guid: 58d8ce7e0909c6344be69282ddc9ddec
-folderAsset: yes
-timeCreated: 1536749367
-licenseType: Pro
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 7 - 4
Unity/Assets/Editor/ExcelExporterEditor/ExcelExporterEditor.cs

@@ -62,7 +62,7 @@ namespace ET
 
                     ExportAll(clientPath);
 
-                    ExportAllClass(@"./Assets/Model/Config", "namespace ET\n{\n");
+                    ExportAllClass(@"./Assets/Model/Config", "using MongoDB.Bson.Serialization.Attributes;\n\nnamespace ET\n{\n");
 
                     Log.Info($"导出客户端配置完成!");
                 }
@@ -73,7 +73,7 @@ namespace ET
 
                     ExportAll(ServerConfigPath);
 
-                    ExportAllClass(@"../Server/Model/Config", "namespace ET\n{\n");
+                    ExportAllClass(@"../Server/Model/Config", "using MongoDB.Bson.Serialization.Attributes;\n\nnamespace ET\n{\n");
 
                     Log.Info($"导出服务端配置完成!");
                 }
@@ -135,6 +135,7 @@ namespace ET
 
                 sb.Append($"\tpublic partial class {protoName}: IConfig\n");
                 sb.Append("\t{\n");
+                sb.Append("\t\t[BsonId]\n");
                 sb.Append("\t\tpublic long Id { get; set; }\n");
 
                 int cellCount = sheet.GetRow(3).LastCellNum;
@@ -233,11 +234,13 @@ namespace ET
             using (FileStream txt = new FileStream(exportPath, FileMode.Create))
             using (StreamWriter sw = new StreamWriter(txt))
             {
+                sw.WriteLine('[');
                 for (int i = 0; i < xssfWorkbook.NumberOfSheets; ++i)
                 {
                     ISheet sheet = xssfWorkbook.GetSheetAt(i);
                     ExportSheet(sheet, sw);
                 }
+                sw.WriteLine(']');
             }
 
             Log.Info($"{protoName}导表完成");
@@ -265,7 +268,6 @@ namespace ET
                 }
 
                 StringBuilder sb = new StringBuilder();
-                sb.Append("{");
                 IRow row = sheet.GetRow(i);
                 for (int j = 2; j < cellCount; ++j)
                 {
@@ -303,13 +305,14 @@ namespace ET
                     if (fieldName == "Id" || fieldName == "_id")
                     {
                         fieldName = "_id";
+                        sb.Append($"[{fieldValue}, {{");
                     }
 
                     string fieldType = cellInfos[j].Type;
                     sb.Append($"\"{fieldName}\":{Convert(fieldType, fieldValue)}");
                 }
 
-                sb.Append("}");
+                sb.Append("}],");
                 sw.WriteLine(sb.ToString());
             }
         }

+ 17 - 0
Unity/Assets/HotfixView/UI/UIHelper.cs

@@ -0,0 +1,17 @@
+namespace ET
+{
+    public static class UIHelper
+    {
+        public static async ETTask<UI> Create(Scene scene, string uiType)
+        {
+            UIComponent uiComponent = scene.GetComponent<UIComponent>();
+            return await UIEventComponent.Instance.OnCreate(uiComponent, uiType);
+        }
+        
+        public static async ETTask Remove(Scene scene, string uiType)
+        {
+            UIComponent uiComponent = scene.GetComponent<UIComponent>();
+            UIEventComponent.Instance.OnRemove(uiComponent, uiType);
+        }
+    }
+}

+ 11 - 0
Unity/Assets/HotfixView/UI/UIHelper.cs.meta

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

+ 12 - 0
Unity/Assets/HotfixView/UI/UILogin/AfterCreateZoneScene_CreateLoginUI.cs

@@ -0,0 +1,12 @@
+
+
+namespace ET
+{
+	public class AfterCreateZoneScene_RemoveLoginUI: AEvent<EventType.AfterCreateZoneScene>
+	{
+		public override async ETTask Run(EventType.AfterCreateZoneScene args)
+		{
+			await UIHelper.Create(args.ZoneScene, UIType.UILogin);
+		}
+	}
+}

+ 11 - 0
Unity/Assets/HotfixView/UI/UILogin/AfterCreateZoneScene_CreateLoginUI.cs.meta

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

+ 1 - 2
Unity/Assets/HotfixView/UI/UILogin/LoginFinish_RemoveLoginUI.cs

@@ -6,8 +6,7 @@ namespace ET
 	{
 		public override async ETTask Run(EventType.LoginFinish args)
 		{
-			Game.Scene.GetComponent<UIComponent>().Remove(UIType.UILogin);
-			Game.Scene.GetComponent<ResourcesComponent>().UnloadBundle(UIType.UILogin.StringToAB());
+			await UIHelper.Remove(args.ZoneScene, UIType.UILogin);
 		}
 	}
 }

+ 3 - 0
Unity/Assets/Model/Config/StartMachineConfig.cs

@@ -1,3 +1,5 @@
+using MongoDB.Bson.Serialization.Attributes;
+
 namespace ET
 {
 	[Config]
@@ -12,6 +14,7 @@ namespace ET
 
 	public partial class StartMachineConfig: IConfig
 	{
+		[BsonId]
 		public long Id { get; set; }
 		public string InnerIP;
 		public string OuterIP;

+ 3 - 0
Unity/Assets/Model/Config/StartProcessConfig.cs

@@ -1,3 +1,5 @@
+using MongoDB.Bson.Serialization.Attributes;
+
 namespace ET
 {
 	[Config]
@@ -12,6 +14,7 @@ namespace ET
 
 	public partial class StartProcessConfig: IConfig
 	{
+		[BsonId]
 		public long Id { get; set; }
 		public int MachineId;
 		public string InnerPort;

+ 3 - 0
Unity/Assets/Model/Config/StartSceneConfig.cs

@@ -1,3 +1,5 @@
+using MongoDB.Bson.Serialization.Attributes;
+
 namespace ET
 {
 	[Config]
@@ -12,6 +14,7 @@ namespace ET
 
 	public partial class StartSceneConfig: IConfig
 	{
+		[BsonId]
 		public long Id { get; set; }
 		public int Process;
 		public int Zone;

+ 3 - 0
Unity/Assets/Model/Config/StartZoneConfig.cs

@@ -1,3 +1,5 @@
+using MongoDB.Bson.Serialization.Attributes;
+
 namespace ET
 {
 	[Config]
@@ -12,6 +14,7 @@ namespace ET
 
 	public partial class StartZoneConfig: IConfig
 	{
+		[BsonId]
 		public long Id { get; set; }
 		public string DBConnection;
 		public string DBName;

+ 3 - 0
Unity/Assets/Model/Config/UnitConfig.cs

@@ -1,3 +1,5 @@
+using MongoDB.Bson.Serialization.Attributes;
+
 namespace ET
 {
 	[Config]
@@ -12,6 +14,7 @@ namespace ET
 
 	public partial class UnitConfig: IConfig
 	{
+		[BsonId]
 		public long Id { get; set; }
 		public string Name;
 		public string Desc;

+ 1 - 0
Unity/Assets/Model/EventType.cs

@@ -18,6 +18,7 @@
 
         public struct LoginFinish
         {
+            public Scene ZoneScene;
         }
 
         public struct LoadingBegin

+ 8 - 19
Unity/Assets/Model/Module/Config/ACategory.cs

@@ -26,28 +26,17 @@ namespace ET
 	{
 		protected Dictionary<long, T> dict;
 
-		public virtual void BeginInit()
+		public override void BeginInit()
 		{
-			this.dict = new Dictionary<long, T>();
-
 			string configStr = ConfigHelper.GetText(typeof(T).Name);
 
-			foreach (string str in configStr.Split(new[] { "\n" }, StringSplitOptions.None))
+			try
 			{
-				try
-				{
-					string str2 = str.Trim();
-					if (str2 == "")
-					{
-						continue;
-					}
-					T t = ConfigHelper.ToObject<T>(str2);
-					this.dict.Add(t.Id, t);
-				}
-				catch (Exception e)
-				{
-					throw new Exception($"parser json fail: {str}", e);
-				}
+				this.dict = ConfigHelper.ToObject<Dictionary<long, T>>(configStr);
+			}
+			catch (Exception e)
+			{
+				throw new Exception($"parser json fail: {configStr}", e);
 			}
 		}
 
@@ -59,7 +48,7 @@ namespace ET
 			}
 		}
 
-		public virtual void EndInit()
+		public override void EndInit()
 		{
 		}
 

+ 0 - 8
Unity/Assets/Model/Module/Pathfinding.meta

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

+ 2 - 0
Unity/Unity.HotfixView.csproj

@@ -63,6 +63,7 @@
      <Compile Include="Assets\HotfixView\Module\UI\UIComponentSystem.cs" />
      <Compile Include="Assets\HotfixView\Module\UI\UIEventComponentSystem.cs" />
      <Compile Include="Assets\HotfixView\Scene\AfterCreateZoneScene_AddComponent.cs" />
+     <Compile Include="Assets\HotfixView\UI\UIHelper.cs" />
      <Compile Include="Assets\HotfixView\UI\UILoading\LoadingBeginEvent_CreateLoadingUI.cs" />
      <Compile Include="Assets\HotfixView\UI\UILoading\LoadingFinishEvent_RemoveLoadingUI.cs" />
      <Compile Include="Assets\HotfixView\UI\UILoading\UILoadingComponentSystem.cs" />
@@ -71,6 +72,7 @@
      <Compile Include="Assets\HotfixView\UI\UILobby\LoginFinish_CreateLobbyUI.cs" />
      <Compile Include="Assets\HotfixView\UI\UILobby\UILobbyComponentSystem.cs" />
      <Compile Include="Assets\HotfixView\UI\UILobby\UILobbyEvent.cs" />
+     <Compile Include="Assets\HotfixView\UI\UILogin\AfterCreateZoneScene_CreateLoginUI.cs" />
      <Compile Include="Assets\HotfixView\UI\UILogin\LoginFinish_RemoveLoginUI.cs" />
      <Compile Include="Assets\HotfixView\UI\UILogin\UILoginComponentSystem.cs" />
      <Compile Include="Assets\HotfixView\UI\UILogin\UILoginEvent.cs" />