From b0947ae3c97aff213a848185d91f3ec296f64fa8 Mon Sep 17 00:00:00 2001 From: tanghai Date: Thu, 26 Oct 2017 11:30:40 +0800 Subject: [PATCH] =?UTF-8?q?NumericComponent=E5=AE=8C=E7=BE=8E=E7=9A=84?= =?UTF-8?q?=E5=BA=8F=E5=88=97=E5=8C=96=E5=8F=8D=E5=BA=8F=E5=88=97=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Config/StartConfig/Benchmark2.txt | 2 ++ Server/App/Program.cs | 8 -------- Server/Model/Component/NumericComponent.cs | 16 +++++++++++++++- Server/Server.sln | 2 +- 4 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 Config/StartConfig/Benchmark2.txt diff --git a/Config/StartConfig/Benchmark2.txt b/Config/StartConfig/Benchmark2.txt new file mode 100644 index 00000000..4624b413 --- /dev/null +++ b/Config/StartConfig/Benchmark2.txt @@ -0,0 +1,2 @@ +{ "_t" : "StartConfig", "_id" : NumberLong("98547768819754"), "components" : [{ "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10002, "Host2" : null }, { "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20000 }, { "_t" : "HttpConfig", "Url" : "", "AppId" : 0, "AppKey" : "", "ManagerSystemUrl" : "" }, { "_t" : "DBConfig", "ConnectionString" : null, "DBName" : null }], "AppId" : 1, "AppType" : "AllServer", "ServerIP" : "*" } +{ "_t" : "StartConfig", "_id" : NumberLong("98892711264291"), "components" : [{ "_t" : "ClientConfig", "Host" : "127.0.0.1", "Port" : 10002 }], "AppId" : 2, "AppType" : "Benchmark", "ServerIP" : "*" } diff --git a/Server/App/Program.cs b/Server/App/Program.cs index 6bb21026..8ded12cc 100644 --- a/Server/App/Program.cs +++ b/Server/App/Program.cs @@ -41,14 +41,6 @@ namespace App Game.Scene.AddComponent(); Game.Scene.AddComponent(); - Unit unit = new Unit(); - NumericComponent numericComponent = unit.AddComponent(); - numericComponent.Set(NumericType.Speed, 100); - - Log.Debug(MongoHelper.ToJson(unit)); - Unit unit2 = MongoHelper.FromJson(MongoHelper.ToJson(unit)); - Log.Debug(MongoHelper.ToJson(unit2)); - // 根据不同的AppType添加不同的组件 OuterConfig outerConfig = startConfig.GetComponent(); InnerConfig innerConfig = startConfig.GetComponent(); diff --git a/Server/Model/Component/NumericComponent.cs b/Server/Model/Component/NumericComponent.cs index a7a6cb82..d21e2c96 100644 --- a/Server/Model/Component/NumericComponent.cs +++ b/Server/Model/Component/NumericComponent.cs @@ -4,10 +4,24 @@ using MongoDB.Bson.Serialization.Options; namespace Model { + [ObjectEvent] + public class NumericComponentEvent : ObjectEvent, IAwake + { + public void Awake() + { + this.Get().Awake(); + } + } + public class NumericComponent : ComponentDB { [BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)] - public readonly Dictionary NumericDic = new Dictionary(); + public Dictionary NumericDic; + + public void Awake() + { + this.NumericDic = new Dictionary(); + } public float GetAsFloat(NumericType numericType) { diff --git a/Server/Server.sln b/Server/Server.sln index 0c7e8281..0214b918 100644 --- a/Server/Server.sln +++ b/Server/Server.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26730.15 +VisualStudioVersion = 15.0.27004.2005 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server.App", "App\Server.App.csproj", "{11464C2C-E0B6-476E-ABB1-87445E736B76}" EndProject -- GitLab