提交 937a2539 编写于 作者: T tanghai

1.新的导表跟配置加载,不用对每条记录做反序列化,一次性反序列化整个表

2.UIHelper辅助类,用来创建删除UI
上级 f3632a78
Binary files a/Config/BuffConfig.txt and /dev/null differ
{ "_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" : [] }] }] }
\ No newline at end of file
{"_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"}],
]
{"_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"}],
]
{"_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"}],
]
{"_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"}],
]
{"_id":1001,"Name":"米克尔","Desc":"带有强力攻击技能","Position":1,"Height":178,"Weight":68}
[
[1001, {"_id":1001,"Name":"米克尔","Desc":"带有强力攻击技能","Position":1,"Height":178,"Weight":68}],
]
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;
......
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;
......
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;
......
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;
......
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;
......
{"_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"}],
]
{"_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"}],
]
{"_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"}],
]
{"_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"}],
]
{"_id":1001,"Name":"米克尔","Desc":"带有强力攻击技能","Position":1,"Height":178,"Weight":68}
[
[1001, {"_id":1001,"Name":"米克尔","Desc":"带有强力攻击技能","Position":1,"Height":178,"Weight":68}],
]
......@@ -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());
}
}
......
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);
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 58d8ce7e0909c6344be69282ddc9ddec
folderAsset: yes
timeCreated: 1536749367
licenseType: Pro
DefaultImporter:
guid: dcdc987fc691e43b6b99042ad4351bc0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

namespace ET
{
public class AfterCreateZoneScene_RemoveLoginUI: AEvent<EventType.AfterCreateZoneScene>
{
public override async ETTask Run(EventType.AfterCreateZoneScene args)
{
await UIHelper.Create(args.ZoneScene, UIType.UILogin);
}
}
}
fileFormatVersion: 2
guid: 96a33836b24b0c446933da35be88509d
folderAsset: yes
DefaultImporter:
guid: f86b269e7cff94f3cb2a36780d7a9f27
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -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);
}
}
}
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;
......
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;
......
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;
......
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;
......
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;
......
......@@ -18,6 +18,7 @@
public struct LoginFinish
{
public Scene ZoneScene;
}
public struct LoadingBegin
......
......@@ -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()
{
}
......
......@@ -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" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册