فهرست منبع

配置文件都改成了组件式

tanghai 9 سال پیش
والد
کامیت
d4a1ee5850
25فایلهای تغییر یافته به همراه141 افزوده شده و 80 حذف شده
  1. 18 12
      Server/Model/Server.Model.csproj
  2. 12 13
      Unity/Assets/Editor/ClientConfigEditor/ClientConfigEditor.cs
  3. 15 3
      Unity/Assets/Scripts/Component/ClientConfigComponent.cs
  4. 2 2
      Unity/Assets/Scripts/Component/Config.meta
  5. 0 0
      Unity/Assets/Scripts/Component/Config/ClientConfig.cs
  6. 2 2
      Unity/Assets/Scripts/Component/Config/ClientConfig.cs.meta
  7. 21 0
      Unity/Assets/Scripts/Component/Config/InnerConfig.cs
  8. 12 0
      Unity/Assets/Scripts/Component/Config/InnerConfig.cs.meta
  9. 21 0
      Unity/Assets/Scripts/Component/Config/OuterConfig.cs
  10. 12 0
      Unity/Assets/Scripts/Component/Config/OuterConfig.cs.meta
  11. 4 8
      Unity/Assets/Scripts/Config/AConfig.cs
  12. 0 0
      Unity/Assets/Scripts/Entity/Config.meta
  13. 9 1
      Unity/Assets/Scripts/Entity/Config/BuffConfig.cs
  14. 0 0
      Unity/Assets/Scripts/Entity/Config/BuffConfig.cs.meta
  15. 1 1
      Unity/Assets/Scripts/Entity/Config/StartConfig.cs
  16. 0 0
      Unity/Assets/Scripts/Entity/Config/StartConfig.cs.meta
  17. 0 0
      Unity/Assets/Scripts/Entity/Message.meta
  18. 0 0
      Unity/Assets/Scripts/Entity/Message/Message.cs
  19. 0 0
      Unity/Assets/Scripts/Entity/Message/Message.cs.meta
  20. 3 0
      Unity/Assets/Scripts/Other/EntityType.cs
  21. 0 32
      Unity/Assets/Scripts/Other/Options.cs
  22. 0 1
      Unity/ClientConfig.txt
  23. 1 1
      Unity/Controller/Event/InitSceneStartEvent_InitGame.cs
  24. 1 0
      Unity/StartConfig.txt
  25. 7 4
      Unity/Unity.CSharp.csproj

+ 18 - 12
Server/Model/Server.Model.csproj

@@ -47,6 +47,15 @@
     <Compile Include="..\..\Unity\Assets\Scripts\Component\ConfigComponent.cs">
       <Link>Component\ConfigComponent.cs</Link>
     </Compile>
+    <Compile Include="..\..\Unity\Assets\Scripts\Component\Config\ClientConfig.cs">
+      <Link>Component\Config\ClientConfig.cs</Link>
+    </Compile>
+    <Compile Include="..\..\Unity\Assets\Scripts\Component\Config\InnerConfig.cs">
+      <Link>Component\Config\InnerConfig.cs</Link>
+    </Compile>
+    <Compile Include="..\..\Unity\Assets\Scripts\Component\Config\OuterConfig.cs">
+      <Link>Component\Config\OuterConfig.cs</Link>
+    </Compile>
     <Compile Include="..\..\Unity\Assets\Scripts\Component\EventComponent.cs">
       <Link>Component\EventComponent.cs</Link>
     </Compile>
@@ -83,9 +92,18 @@
     <Compile Include="..\..\Unity\Assets\Scripts\Config\ICategory.cs">
       <Link>Config\ICategory.cs</Link>
     </Compile>
+    <Compile Include="..\..\Unity\Assets\Scripts\Entity\Config\BuffConfig.cs">
+      <Link>Entity\Config\BuffConfig.cs</Link>
+    </Compile>
+    <Compile Include="..\..\Unity\Assets\Scripts\Entity\Config\StartConfig.cs">
+      <Link>Entity\Config\StartConfig.cs</Link>
+    </Compile>
     <Compile Include="..\..\Unity\Assets\Scripts\Entity\Game.cs">
       <Link>Entity\Game.cs</Link>
     </Compile>
+    <Compile Include="..\..\Unity\Assets\Scripts\Entity\Message\Message.cs">
+      <Link>Entity\Message\Message.cs</Link>
+    </Compile>
     <Compile Include="..\..\Unity\Assets\Scripts\Entity\Scene.cs">
       <Link>Entity\Scene.cs</Link>
     </Compile>
@@ -137,27 +155,15 @@
     <Compile Include="..\..\Unity\Assets\Scripts\Message\RpcException.cs">
       <Link>Message\RpcException.cs</Link>
     </Compile>
-    <Compile Include="..\..\Unity\Assets\Scripts\Model\Config\BuffConfig.cs">
-      <Link>Model\Config\BuffConfig.cs</Link>
-    </Compile>
-    <Compile Include="..\..\Unity\Assets\Scripts\Model\Message\Message.cs">
-      <Link>Model\Message\Message.cs</Link>
-    </Compile>
     <Compile Include="..\..\Unity\Assets\Scripts\Other\BsonClassMapRegister.cs">
       <Link>Other\BsonClassMapRegister.cs</Link>
     </Compile>
-    <Compile Include="..\..\Unity\Assets\Scripts\Other\ClientConfig.cs">
-      <Link>Other\ClientConfig.cs</Link>
-    </Compile>
     <Compile Include="..\..\Unity\Assets\Scripts\Other\EntityType.cs">
       <Link>Other\EntityType.cs</Link>
     </Compile>
     <Compile Include="..\..\Unity\Assets\Scripts\Other\Options.cs">
       <Link>Other\Options.cs</Link>
     </Compile>
-    <Compile Include="..\..\Unity\Assets\Scripts\Other\StartConfig.cs">
-      <Link>Other\StartConfig.cs</Link>
-    </Compile>
     <Compile Include="Component\AppManagerComponent.cs" />
     <Compile Include="Component\LogToClientComponent.cs" />
     <Compile Include="Component\GateSessionKeyComponent.cs" />

+ 12 - 13
Unity/Assets/Editor/ClientConfigEditor/ClientConfigEditor.cs

@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
+using System.IO;
 using Base;
 using Model;
 using UnityEditor;
@@ -11,9 +8,9 @@ namespace MyEditor
 {
 	public class ClientConfigEditor : EditorWindow
 	{
-		private const string Path = "./ClientConfig.txt";
+		private const string Path = "./StartConfig.txt";
 
-		private ClientConfig config;
+		private StartConfig config;
 
 		[MenuItem("Tools/客户端配置")]
 		private static void ShowWindow()
@@ -25,21 +22,23 @@ namespace MyEditor
 		{
 			if (!File.Exists(Path))
 			{
-				this.config = new ClientConfig();
+				this.config = new StartConfig();
+				this.config.AppType = AppType.Client;
+				this.config.ServerIP = "*";
+				this.config.AddComponent<ClientConfig>();
 				return;
 			}
 
 			string s = File.ReadAllText(Path);
-			this.config = MongoHelper.FromJson<ClientConfig>(s);
+			this.config = MongoHelper.FromJson<StartConfig>(s);
 		}
 
 		private void OnGUI()
 		{
-			this.config.Host = EditorGUILayout.TextField("地址: ", this.config.Host);
-			this.config.Port = EditorGUILayout.IntField("端口: ", this.config.Port);
-
-			GUILayout.BeginHorizontal();
-
+			ClientConfig clientConfig = this.config.GetComponent<ClientConfig>();
+			clientConfig.Host = EditorGUILayout.TextField("地址: ", clientConfig.Host);
+			clientConfig.Port = EditorGUILayout.IntField("端口: ", clientConfig.Port);
+			
 			if (GUILayout.Button("保存"))
 			{
 				using (StreamWriter sw = new StreamWriter(new FileStream(Path, FileMode.Create)))

+ 15 - 3
Unity/Assets/Scripts/Component/ClientConfigComponent.cs

@@ -14,12 +14,24 @@ namespace Model
 
 	public class ClientConfigComponent : Component
     {
-		public ClientConfig Config { get; private set; }
+		public StartConfig Config { get; private set; }
 
 		public void Awake()
 		{
-			string s = File.ReadAllText("./ClientConfig.txt");
-			this.Config = MongoHelper.FromJson<ClientConfig>(s);
+			string s = File.ReadAllText("./StartConfig.txt");
+			this.Config = MongoHelper.FromJson<StartConfig>(s);
+		}
+
+		public override void Dispose()
+		{
+			if (this.Id == 0)
+			{
+				return;
+			}
+
+			base.Dispose();
+
+			this.Config.Dispose();
 		}
     }
 }

+ 2 - 2
Unity/Assets/Scripts/Model.meta → Unity/Assets/Scripts/Component/Config.meta

@@ -1,7 +1,7 @@
 fileFormatVersion: 2
-guid: a7ca76f312d51e7469f7578030024db0
+guid: e98bd4118f88e1c428e3af0983722aa8
 folderAsset: yes
-timeCreated: 1477905041
+timeCreated: 1478144281
 licenseType: Pro
 DefaultImporter:
   userData: 

+ 0 - 0
Unity/Assets/Scripts/Other/ClientConfig.cs → Unity/Assets/Scripts/Component/Config/ClientConfig.cs


+ 2 - 2
Unity/Assets/Scripts/Other/ClientConfig.cs.meta → Unity/Assets/Scripts/Component/Config/ClientConfig.cs.meta

@@ -1,6 +1,6 @@
 fileFormatVersion: 2
-guid: 500eb7f5c0a52e045a339f55912f8a2b
-timeCreated: 1477315494
+guid: befeb8cfbdbfc5b4ea5f967c200d4751
+timeCreated: 1478144281
 licenseType: Pro
 MonoImporter:
   serializedVersion: 2

+ 21 - 0
Unity/Assets/Scripts/Component/Config/InnerConfig.cs

@@ -0,0 +1,21 @@
+using Base;
+using MongoDB.Bson.Serialization.Attributes;
+
+namespace Model
+{
+	[BsonIgnoreExtraElements]
+	public class InnerConfig : Component
+	{
+		public string Host { get; set; }
+		public int Port { get; set; }
+
+		[BsonIgnore]
+		public string Address
+		{
+			get
+			{
+				return $"{this.Host}:{this.Port}";
+			}
+		}
+	}
+}

+ 12 - 0
Unity/Assets/Scripts/Component/Config/InnerConfig.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 35f166fd86ee5e44aaec9326bb0a5454
+timeCreated: 1478144281
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 21 - 0
Unity/Assets/Scripts/Component/Config/OuterConfig.cs

@@ -0,0 +1,21 @@
+using Base;
+using MongoDB.Bson.Serialization.Attributes;
+
+namespace Model
+{
+	[BsonIgnoreExtraElements]
+	public class OuterConfig : Component
+	{
+		public string Host { get; set; }
+		public int Port { get; set; }
+
+		[BsonIgnore]
+		public string Address
+		{
+			get
+			{
+				return $"{this.Host}:{this.Port}";
+			}
+		}
+	}
+}

+ 12 - 0
Unity/Assets/Scripts/Component/Config/OuterConfig.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 31224cfdac2f28c42bd641d5a2e80fe8
+timeCreated: 1478144281
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 4 - 8
Unity/Assets/Scripts/Config/AConfig.cs

@@ -1,21 +1,17 @@
-using System.ComponentModel;
-using MongoDB.Bson.Serialization.Attributes;
+using Base;
 
 namespace Model
 {
 	/// <summary>
 	/// 每个Config的基类
 	/// </summary>
-	public abstract class AConfig: ISupportInitialize
+	public abstract class AConfig: Entity
 	{
-		[BsonId]
-		public long Id { get; set; }
-
-		public virtual void BeginInit()
+		public AConfig(string entityType): base(entityType)
 		{
 		}
 
-		public virtual void EndInit()
+		public AConfig(long id, string entityType): base(id, entityType)
 		{
 		}
 	}

+ 0 - 0
Unity/Assets/Scripts/Model/Config.meta → Unity/Assets/Scripts/Entity/Config.meta


+ 9 - 1
Unity/Assets/Scripts/Model/Config/BuffConfig.cs → Unity/Assets/Scripts/Entity/Config/BuffConfig.cs

@@ -7,7 +7,15 @@ namespace Model
 	{
 		public string Name { get; set; }
 		public int Time { get; set; }
-    }
+
+		public BuffConfig(): base(EntityType.BuffConfig)
+		{
+		}
+
+		public BuffConfig(long id): base(id, EntityType.BuffConfig)
+		{
+		}
+	}
 
 	[Config(AppType.Client | AppType.Gate)]
 	public class BuffCategory : ACategory<BuffConfig>

+ 0 - 0
Unity/Assets/Scripts/Model/Config/BuffConfig.cs.meta → Unity/Assets/Scripts/Entity/Config/BuffConfig.cs.meta


+ 1 - 1
Unity/Assets/Scripts/Other/StartConfig.cs → Unity/Assets/Scripts/Entity/Config/StartConfig.cs

@@ -4,7 +4,7 @@ using MongoDB.Bson.Serialization.Attributes;
 
 namespace Model
 {
-	public class StartConfig: Entity
+	public class StartConfig: AConfig
 	{
 		public int AppId { get; set; }
 		

+ 0 - 0
Unity/Assets/Scripts/Other/StartConfig.cs.meta → Unity/Assets/Scripts/Entity/Config/StartConfig.cs.meta


+ 0 - 0
Unity/Assets/Scripts/Model/Message.meta → Unity/Assets/Scripts/Entity/Message.meta


+ 0 - 0
Unity/Assets/Scripts/Model/Message/Message.cs → Unity/Assets/Scripts/Entity/Message/Message.cs


+ 0 - 0
Unity/Assets/Scripts/Model/Message/Message.cs.meta → Unity/Assets/Scripts/Entity/Message/Message.cs.meta


+ 3 - 0
Unity/Assets/Scripts/Other/EntityType.cs

@@ -8,5 +8,8 @@
 		public const string UI = "UI";
 		public const string Config = "Config";
 		public const string Network = "Network";
+
+		// Config
+		public const string BuffConfig = "BuffConfig";
 	}
 }

+ 0 - 32
Unity/Assets/Scripts/Other/Options.cs

@@ -29,36 +29,4 @@ namespace Model
 			return MongoHelper.FromBson<Options>(MongoHelper.ToBson(this));
 		}
 	}
-
-	[BsonIgnoreExtraElements]
-	public class InnerConfig: Component
-	{
-		public string Host { get; set; }
-		public int Port { get; set; }
-
-		[BsonIgnore]
-		public string Address
-		{
-			get
-			{
-				return $"{this.Host}:{this.Port}";
-			}
-		}
-	}
-
-	[BsonIgnoreExtraElements]
-	public class OuterConfig: Component
-	{
-		public string Host { get; set; }
-		public int Port { get; set; }
-
-		[BsonIgnore]
-		public string Address
-		{
-			get
-			{
-				return $"{this.Host}:{this.Port}";
-			}
-		}
-	}
 }

+ 0 - 1
Unity/ClientConfig.txt

@@ -1 +0,0 @@
-{ "_t" : "ClientConfig", "Host" : "127.0.0.1", "Port" : 10000 }

+ 1 - 1
Unity/Controller/Event/InitSceneStartEvent_InitGame.cs

@@ -13,7 +13,7 @@ namespace Controller
 		public async void Run()
 		{
 			Game.Scene.AddComponent<MessageDispatherComponent, AppType>(AppType.Client);
-			ClientConfig clientConfig = Game.Scene.AddComponent<ClientConfigComponent>().Config;
+			ClientConfig clientConfig = Game.Scene.AddComponent<ClientConfigComponent>().Config.GetComponent<ClientConfig>();
 			NetOuterComponent networkComponent = Game.Scene.AddComponent<NetOuterComponent>();
 			using (Session session = networkComponent.Create(clientConfig.Address))
 			{

+ 1 - 0
Unity/StartConfig.txt

@@ -0,0 +1 @@
+{ "_t" : "StartConfig", "_id" : NumberLong("96871590002689"), "Type" : "Config", "components" : [{ "_t" : "ClientConfig", "_id" : NumberLong("96871590002690"), "Host" : "127.0.0.1", "Port" : 10000 }], "AppId" : 0, "AppType" : "None", "ServerIP" : null }

+ 7 - 4
Unity/Unity.CSharp.csproj

@@ -83,6 +83,9 @@
     <Compile Include="Assets\Scripts\Component\ChildrenComponent.cs" />
     <Compile Include="Assets\Scripts\Component\ClientConfigComponent.cs" />
     <Compile Include="Assets\Scripts\Component\ConfigComponent.cs" />
+    <Compile Include="Assets\Scripts\Component\Config\OuterConfig.cs" />
+    <Compile Include="Assets\Scripts\Component\Config\InnerConfig.cs" />
+    <Compile Include="Assets\Scripts\Component\Config\ClientConfig.cs" />
     <Compile Include="Assets\Scripts\Component\EventComponent.cs" />
     <Compile Include="Assets\Scripts\Component\GameObjectComponent.cs" />
     <Compile Include="Assets\Scripts\Component\KVComponent.cs" />
@@ -120,14 +123,13 @@
     <Compile Include="Assets\Scripts\Message\MessageHandlerAttribute.cs" />
     <Compile Include="Assets\Scripts\Message\OpcodeHelper.cs" />
     <Compile Include="Assets\Scripts\Message\RpcException.cs" />
-    <Compile Include="Assets\Scripts\Model\Config\BuffConfig.cs" />
-    <Compile Include="Assets\Scripts\Model\Message\Message.cs" />
+    <Compile Include="Assets\Scripts\Entity\Config\BuffConfig.cs" />
+    <Compile Include="Assets\Scripts\Entity\Message\Message.cs" />
     <Compile Include="Assets\Scripts\Other\BsonClassMapRegister.cs" />
-    <Compile Include="Assets\Scripts\Other\ClientConfig.cs" />
     <Compile Include="Assets\Scripts\Other\EntityType.cs" />
     <Compile Include="Assets\Scripts\Other\GameException.cs" />
     <Compile Include="Assets\Scripts\Other\Options.cs" />
-    <Compile Include="Assets\Scripts\Other\StartConfig.cs" />
+    <Compile Include="Assets\Scripts\Entity\Config\StartConfig.cs" />
     <Compile Include="Assets\Scripts\Other\UIType.cs" />
     <Compile Include="Assets\Scripts\ReferenceCollector.cs" />
   </ItemGroup>
@@ -135,5 +137,6 @@
     <None Include="Assets\CSharp 6.0 Support\AsyncTools\Plugins\AsyncBridge.Net35.xml" />
     <None Include="Assets\CSharp 6.0 Support\AsyncTools\Plugins\System.Threading.xml" />
   </ItemGroup>
+  <ItemGroup />
   <Import Project="$(MSBuildExtensionsPath)\SyntaxTree\UnityVS\2015\UnityVS.CSharp.targets" />
 </Project>