Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
guo450212436
et
提交
95a8e65a
E
et
项目概览
guo450212436
/
et
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
et
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
95a8e65a
编写于
8月 18, 2014
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.配置类放到Common里
2.数据和控制逻辑分离,数据放到Model里,控制逻辑放到Control里,Control以后可以Reload
上级
4876dab1
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
241 addition
and
70 deletion
+241
-70
CSharp/CSharp.sln
CSharp/CSharp.sln
+30
-15
CSharp/Game/BehaviorTree/BehaviorTree.csproj
CSharp/Game/BehaviorTree/BehaviorTree.csproj
+0
-4
CSharp/Game/Component/IConfigInitialize.cs
CSharp/Game/Component/IConfigInitialize.cs
+0
-8
CSharp/Game/Component/KeyDefine.cs
CSharp/Game/Component/KeyDefine.cs
+0
-7
CSharp/Game/Controller/BuffController.cs
CSharp/Game/Controller/BuffController.cs
+15
-0
CSharp/Game/Controller/Controller.csproj
CSharp/Game/Controller/Controller.csproj
+53
-0
CSharp/Game/Controller/Properties/AssemblyInfo.cs
CSharp/Game/Controller/Properties/AssemblyInfo.cs
+36
-0
CSharp/Game/Model/Buff.cs
CSharp/Game/Model/Buff.cs
+1
-1
CSharp/Game/Model/BuffManager.cs
CSharp/Game/Model/BuffManager.cs
+1
-1
CSharp/Game/Model/Character.cs
CSharp/Game/Model/Character.cs
+1
-1
CSharp/Game/Model/GameObject.cs
CSharp/Game/Model/GameObject.cs
+1
-1
CSharp/Game/Model/GameObjectManager.cs
CSharp/Game/Model/GameObjectManager.cs
+1
-1
CSharp/Game/Model/Model.csproj
CSharp/Game/Model/Model.csproj
+0
-6
CSharp/Game/Model/packages.config
CSharp/Game/Model/packages.config
+0
-0
CSharp/Game/World/Config/GlobalConfig.cs
CSharp/Game/World/Config/GlobalConfig.cs
+1
-1
CSharp/Game/World/World.cs
CSharp/Game/World/World.cs
+7
-3
CSharp/Game/World/World.csproj
CSharp/Game/World/World.csproj
+2
-2
CSharp/Platform/Common/Common.csproj
CSharp/Platform/Common/Common.csproj
+4
-0
CSharp/Platform/Common/Config/ConfigAttribute.cs
CSharp/Platform/Common/Config/ConfigAttribute.cs
+9
-0
CSharp/Platform/Common/Config/ConfigCategory.cs
CSharp/Platform/Common/Config/ConfigCategory.cs
+18
-18
CSharp/Platform/Common/Config/ConfigManager.cs
CSharp/Platform/Common/Config/ConfigManager.cs
+60
-0
CSharp/Platform/Common/Config/IType.cs
CSharp/Platform/Common/Config/IType.cs
+1
-1
未找到文件。
CSharp/CSharp.sln
浏览文件 @
95a8e65a
...
...
@@ -34,8 +34,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BehaviorTree", "Game\Behavi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "World", "Game\World\World.csproj", "{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Component", "Game\Component\Component.csproj", "{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tree", "App\Modules\Tree\Tree.csproj", "{6CD185D1-08E0-4729-A999-2D5B57BA8193}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ENetExe", "Platform\ENetExe\ENetExe.csproj", "{CBA52DC8-1C80-4A79-9AC5-73514EBBD749}"
...
...
@@ -48,6 +46,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TNetTest", "Platform\TNetTe
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Platform\Common\Common.csproj", "{19F8F043-1F99-4550-99DF-DEA5C7D77E55}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "Game\Model\Model.csproj", "{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Controller", "Game\Controller\Controller.csproj", "{E69C1F22-E004-4D69-8667-787BD243454B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
...
...
@@ -148,18 +150,6 @@ Global
{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}.Release|Win32.ActiveCfg = Release|Any CPU
{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}.Release|x86.ActiveCfg = Release|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Debug|Win32.ActiveCfg = Debug|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Debug|x86.ActiveCfg = Debug|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Release|Any CPU.Build.0 = Release|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Release|Win32.ActiveCfg = Release|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Release|x86.ActiveCfg = Release|Any CPU
{6CD185D1-08E0-4729-A999-2D5B57BA8193}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6CD185D1-08E0-4729-A999-2D5B57BA8193}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CD185D1-08E0-4729-A999-2D5B57BA8193}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
...
...
@@ -220,6 +210,30 @@ Global
{19F8F043-1F99-4550-99DF-DEA5C7D77E55}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{19F8F043-1F99-4550-99DF-DEA5C7D77E55}.Release|Win32.ActiveCfg = Release|Any CPU
{19F8F043-1F99-4550-99DF-DEA5C7D77E55}.Release|x86.ActiveCfg = Release|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Debug|Win32.ActiveCfg = Debug|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Debug|x86.ActiveCfg = Debug|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Release|Any CPU.Build.0 = Release|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Release|Win32.ActiveCfg = Release|Any CPU
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}.Release|x86.ActiveCfg = Release|Any CPU
{E69C1F22-E004-4D69-8667-787BD243454B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E69C1F22-E004-4D69-8667-787BD243454B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E69C1F22-E004-4D69-8667-787BD243454B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{E69C1F22-E004-4D69-8667-787BD243454B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{E69C1F22-E004-4D69-8667-787BD243454B}.Debug|Win32.ActiveCfg = Debug|Any CPU
{E69C1F22-E004-4D69-8667-787BD243454B}.Debug|x86.ActiveCfg = Debug|Any CPU
{E69C1F22-E004-4D69-8667-787BD243454B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E69C1F22-E004-4D69-8667-787BD243454B}.Release|Any CPU.Build.0 = Release|Any CPU
{E69C1F22-E004-4D69-8667-787BD243454B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{E69C1F22-E004-4D69-8667-787BD243454B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{E69C1F22-E004-4D69-8667-787BD243454B}.Release|Win32.ActiveCfg = Release|Any CPU
{E69C1F22-E004-4D69-8667-787BD243454B}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
...
...
@@ -233,11 +247,12 @@ Global
{901A8E5C-C4C6-4C3C-8E18-068D75119F5D} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
{C4E7A34A-095C-4983-AB63-FC2D20CD6824} = {D0CC1FF4-2747-4278-A51F-BE9AA959175B}
{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0} = {D0CC1FF4-2747-4278-A51F-BE9AA959175B}
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE} = {D0CC1FF4-2747-4278-A51F-BE9AA959175B}
{6CD185D1-08E0-4729-A999-2D5B57BA8193} = {C4C64188-4FAE-4CC3-A9E6-D9D4AF7429B6}
{CBA52DC8-1C80-4A79-9AC5-73514EBBD749} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
{B42D431A-3A54-4649-942A-C5356D7F9FBC} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
{F176D1FA-63E5-4B89-9A03-D44CCCCC069A} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
{19F8F043-1F99-4550-99DF-DEA5C7D77E55} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE} = {D0CC1FF4-2747-4278-A51F-BE9AA959175B}
{E69C1F22-E004-4D69-8667-787BD243454B} = {D0CC1FF4-2747-4278-A51F-BE9AA959175B}
EndGlobalSection
EndGlobal
CSharp/Game/BehaviorTree/BehaviorTree.csproj
浏览文件 @
95a8e65a
...
...
@@ -61,10 +61,6 @@
<Project>
{19f8f043-1f99-4550-99df-dea5c7d77e55}
</Project>
<Name>
Common
</Name>
</ProjectReference>
<ProjectReference
Include=
"..\Component\Component.csproj"
>
<Project>
{0fa529d1-d0a9-4a8e-90f5-117ce80f2ede}
</Project>
<Name>
Component
</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None
Include=
"packages.config"
/>
...
...
CSharp/Game/Component/IConfigInitialize.cs
已删除
100644 → 0
浏览文件 @
4876dab1
namespace
Component
{
public
interface
IConfigInitialize
{
string
ConfigName
{
get
;
}
void
Init
(
string
dir
);
}
}
\ No newline at end of file
CSharp/Game/Component/KeyDefine.cs
已删除
100644 → 0
浏览文件 @
4876dab1
namespace
Component
{
public
static
class
KeyDefine
{
public
const
string
KMessage
=
"message"
;
}
}
\ No newline at end of file
CSharp/Game/Controller/BuffController.cs
0 → 100644
浏览文件 @
95a8e65a
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Controller
{
/// <summary>
/// 控制复杂的buff逻辑,可以reload
/// </summary>
public
class
BuffController
{
}
}
CSharp/Game/Controller/Controller.csproj
0 → 100644
浏览文件 @
95a8e65a
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"12.0"
DefaultTargets=
"Build"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<Import
Project=
"$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition=
"Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"
/>
<PropertyGroup>
<Configuration
Condition=
" '$(Configuration)' == '' "
>
Debug
</Configuration>
<Platform
Condition=
" '$(Platform)' == '' "
>
AnyCPU
</Platform>
<ProjectGuid>
{E69C1F22-E004-4D69-8667-787BD243454B}
</ProjectGuid>
<OutputType>
Library
</OutputType>
<AppDesignerFolder>
Properties
</AppDesignerFolder>
<RootNamespace>
Controller
</RootNamespace>
<AssemblyName>
Controller
</AssemblyName>
<TargetFrameworkVersion>
v4.5
</TargetFrameworkVersion>
<FileAlignment>
512
</FileAlignment>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
>
<DebugSymbols>
true
</DebugSymbols>
<DebugType>
full
</DebugType>
<Optimize>
false
</Optimize>
<OutputPath>
..\..\Bin\Debug\
</OutputPath>
<DefineConstants>
DEBUG;TRACE
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "
>
<DebugType>
pdbonly
</DebugType>
<Optimize>
true
</Optimize>
<OutputPath>
..\..\Bin\Release\
</OutputPath>
<DefineConstants>
TRACE
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Core"
/>
<Reference
Include=
"System.Xml.Linq"
/>
<Reference
Include=
"System.Data.DataSetExtensions"
/>
<Reference
Include=
"Microsoft.CSharp"
/>
<Reference
Include=
"System.Data"
/>
<Reference
Include=
"System.Xml"
/>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"BuffController.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
</ItemGroup>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
CSharp/Game/Controller/Properties/AssemblyInfo.cs
0 → 100644
浏览文件 @
95a8e65a
using
System.Reflection
;
using
System.Runtime.CompilerServices
;
using
System.Runtime.InteropServices
;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[
assembly
:
AssemblyTitle
(
"Controller"
)]
[
assembly
:
AssemblyDescription
(
""
)]
[
assembly
:
AssemblyConfiguration
(
""
)]
[
assembly
:
AssemblyCompany
(
"Microsoft"
)]
[
assembly
:
AssemblyProduct
(
"Controller"
)]
[
assembly
:
AssemblyCopyright
(
"Copyright © Microsoft 2014"
)]
[
assembly
:
AssemblyTrademark
(
""
)]
[
assembly
:
AssemblyCulture
(
""
)]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[
assembly
:
ComVisible
(
false
)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[
assembly
:
Guid
(
"2857e4a1-f2c1-4c17-8b67-6d25f98265ed"
)]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[
assembly
:
AssemblyVersion
(
"1.0.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.0.0.0"
)]
CSharp/Game/
Component
/Buff.cs
→
CSharp/Game/
Model
/Buff.cs
浏览文件 @
95a8e65a
using
Common.Component
;
namespace
Component
namespace
Model
{
public
class
Buff
:
Object
{
...
...
CSharp/Game/
Component
/BuffManager.cs
→
CSharp/Game/
Model
/BuffManager.cs
浏览文件 @
95a8e65a
...
...
@@ -3,7 +3,7 @@ using System.ComponentModel;
using
MongoDB.Bson
;
using
MongoDB.Bson.Serialization.Attributes
;
namespace
Component
namespace
Model
{
public
class
BuffManager
:
ISupportInitialize
{
...
...
CSharp/Game/
Component
/Character.cs
→
CSharp/Game/
Model
/Character.cs
浏览文件 @
95a8e65a
namespace
Component
namespace
Model
{
/// <summary>
/// 角色对象
...
...
CSharp/Game/
Component
/GameObject.cs
→
CSharp/Game/
Model
/GameObject.cs
浏览文件 @
95a8e65a
using
Common.Component
;
namespace
Component
namespace
Model
{
public
class
GameObject
:
Object
{
...
...
CSharp/Game/
Component
/GameObjectManager.cs
→
CSharp/Game/
Model
/GameObjectManager.cs
浏览文件 @
95a8e65a
...
...
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using
System.Linq
;
using
MongoDB.Bson
;
namespace
Component
namespace
Model
{
public
class
GameObjectManager
{
...
...
CSharp/Game/
Component/Component
.csproj
→
CSharp/Game/
Model/Model
.csproj
浏览文件 @
95a8e65a
...
...
@@ -49,13 +49,7 @@
<Compile
Include=
"BuffManager.cs"
/>
<Compile
Include=
"Character.cs"
/>
<Compile
Include=
"GameObject.cs"
/>
<Compile
Include=
"ConfigAttribute.cs"
/>
<Compile
Include=
"ConfigCategory.cs"
/>
<Compile
Include=
"ConfigManager.cs"
/>
<Compile
Include=
"GameObjectManager.cs"
/>
<Compile
Include=
"IConfigInitialize.cs"
/>
<Compile
Include=
"IType.cs"
/>
<Compile
Include=
"KeyDefine.cs"
/>
</ItemGroup>
<ItemGroup>
<Folder
Include=
"Properties\"
/>
...
...
CSharp/Game/
Component
/packages.config
→
CSharp/Game/
Model
/packages.config
浏览文件 @
95a8e65a
文件已移动
CSharp/Game/World/Config/GlobalConfig.cs
浏览文件 @
95a8e65a
namespace
Component
.Config
namespace
Model
.Config
{
public
class
GlobalConfig
:
IType
{
...
...
CSharp/Game/World/World.cs
浏览文件 @
95a8e65a
using
Component
;
using
Model
;
namespace
World
{
public
class
World
{
private
static
readonly
World
instance
=
new
World
();
private
readonly
ConfigManager
configManager
=
ConfigManager
.
Instance
;
private
readonly
ConfigManager
configManager
=
new
ConfigManager
(
typeof
(
World
).
Assembly
)
;
private
readonly
GameObjectManager
gameObjectManager
=
new
GameObjectManager
();
...
...
@@ -18,6 +18,10 @@ namespace World
}
}
private
World
()
{
}
public
ConfigManager
ConfigManager
{
get
...
...
CSharp/Game/World/World.csproj
浏览文件 @
95a8e65a
...
...
@@ -46,9 +46,9 @@
<Project>
{19f8f043-1f99-4550-99df-dea5c7d77e55}
</Project>
<Name>
Common
</Name>
</ProjectReference>
<ProjectReference
Include=
"..\
Component\Component
.csproj"
>
<ProjectReference
Include=
"..\
Model\Model
.csproj"
>
<Project>
{0fa529d1-d0a9-4a8e-90f5-117ce80f2ede}
</Project>
<Name>
Component
</Name>
<Name>
Model
</Name>
</ProjectReference>
</ItemGroup>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
...
...
CSharp/Platform/Common/Common.csproj
浏览文件 @
95a8e65a
...
...
@@ -63,6 +63,10 @@
<Compile
Include=
"Component\IEventAttribute.cs"
/>
<Compile
Include=
"Component\IEvent.cs"
/>
<Compile
Include=
"Component\Object.cs"
/>
<Compile
Include=
"Config\ConfigAttribute.cs"
/>
<Compile
Include=
"Config\ConfigCategory.cs"
/>
<Compile
Include=
"Config\ConfigManager.cs"
/>
<Compile
Include=
"Config\IType.cs"
/>
<Compile
Include=
"Helper\BigIntegerHelper.cs"
/>
<Compile
Include=
"Helper\ByteHelper.cs"
/>
<Compile
Include=
"Helper\EnumHelper.cs"
/>
...
...
CSharp/
Game/Component
/ConfigAttribute.cs
→
CSharp/
Platform/Common/Config
/ConfigAttribute.cs
浏览文件 @
95a8e65a
using
System
;
namespace
Component
namespace
Model
{
[
AttributeUsage
(
AttributeTargets
.
Class
)]
public
class
ConfigAttribute
:
Attribute
{
public
string
RelativeDirectory
{
get
;
set
;
}
public
ConfigAttribute
()
{
this
.
RelativeDirectory
=
@"..\Config"
;
}
}
}
\ No newline at end of file
CSharp/
Game/Component
/ConfigCategory.cs
→
CSharp/
Platform/Common/Config
/ConfigCategory.cs
浏览文件 @
95a8e65a
...
...
@@ -4,12 +4,28 @@ using System.ComponentModel;
using
System.IO
;
using
Common.Helper
;
namespace
Component
namespace
Model
{
public
abstract
class
ConfigCategory
<
T
>:
ISupportInitialize
,
IConfigInitialize
where
T
:
IType
public
abstract
class
ConfigCategory
<
T
>:
ISupportInitialize
where
T
:
IType
{
protected
readonly
Dictionary
<
int
,
T
>
dict
=
new
Dictionary
<
int
,
T
>();
protected
ConfigCategory
()
{
string
path
=
Path
.
Combine
(
@"./Config/"
,
this
.
ConfigName
);
if
(!
Directory
.
Exists
(
path
))
{
throw
new
Exception
(
string
.
Format
(
"not found config path: {0}"
,
path
));
}
foreach
(
var
file
in
Directory
.
GetFiles
(
path
))
{
var
t
=
MongoHelper
.
FromJson
<
T
>(
File
.
ReadAllText
(
file
));
this
.
dict
.
Add
(
t
.
Type
,
t
);
}
}
public
T
this
[
int
type
]
{
get
...
...
@@ -31,22 +47,6 @@ namespace Component
return
this
.
dict
;
}
public
void
Init
(
string
configsDir
)
{
string
path
=
Path
.
Combine
(
configsDir
,
this
.
ConfigName
);
if
(!
Directory
.
Exists
(
path
))
{
throw
new
Exception
(
string
.
Format
(
"not found config path: {0}"
,
path
));
}
foreach
(
var
file
in
Directory
.
GetFiles
(
path
))
{
var
t
=
MongoHelper
.
FromJson
<
T
>(
File
.
ReadAllText
(
file
));
this
.
dict
.
Add
(
t
.
Type
,
t
);
}
}
public
void
BeginInit
()
{
}
...
...
CSharp/
Game/Component
/ConfigManager.cs
→
CSharp/
Platform/Common/Config
/ConfigManager.cs
浏览文件 @
95a8e65a
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.
IO
;
using
System.
Reflection
;
namespace
Component
namespace
Model
{
public
class
ConfigManager
{
private
static
readonly
ConfigManager
instance
=
new
ConfigManager
();
public
static
ConfigManager
Instance
{
get
{
return
instance
;
}
}
public
Dictionary
<
string
,
object
>
allConfig
;
p
rivate
ConfigManager
(
)
p
ublic
ConfigManager
(
Assembly
assembly
)
{
this
.
Load
(
);
Load
(
assembly
);
}
p
rivate
void
Load
(
)
p
ublic
void
Load
(
Assembly
assembly
)
{
var
localAllConfig
=
new
Dictionary
<
string
,
object
>();
string
currentDir
=
AppDomain
.
CurrentDomain
.
BaseDirectory
;
Type
[]
types
=
typeof
(
ConfigManager
).
Assembly
.
GetTypes
();
Type
[]
types
=
assembly
.
GetTypes
();
foreach
(
var
type
in
types
)
{
object
[]
attrs
=
type
.
GetCustomAttributes
(
typeof
(
ConfigAttribute
),
false
);
...
...
@@ -36,59 +25,34 @@ namespace Component
{
continue
;
}
object
obj
=
(
Activator
.
CreateInstance
(
type
));
var
iInit
=
obj
as
IConfigInitialize
;
if
(
iInit
==
null
)
{
throw
new
Exception
(
string
.
Format
(
"class {0} is not IConfigInitialize"
,
type
.
Name
));
}
var
iSupportInitialize
=
obj
as
ISupportInitialize
;
if
(
iSupportInitialize
!=
null
)
{
iSupportInitialize
.
BeginInit
();
}
string
configDir
=
Path
.
Combine
(
currentDir
,
((
ConfigAttribute
)
attrs
[
0
]).
RelativeDirectory
);
if
(!
Directory
.
Exists
(
configDir
))
{
throw
new
Exception
(
string
.
Format
(
"not found config dir: {0}"
,
configDir
));
}
iInit
.
Init
(
configDir
);
if
(
iSupportInitialize
!=
null
)
{
iSupportInitialize
.
EndInit
();
}
localAllConfig
[
iInit
.
Config
Name
]
=
obj
;
localAllConfig
[
type
.
Name
]
=
obj
;
}
this
.
allConfig
=
localAllConfig
;
}
public
void
Reload
()
{
this
.
Load
();
}
public
T
Get
<
T
>(
int
type
)
where
T
:
IType
{
var
config
Manager
=
(
ConfigCategory
<
T
>)
this
.
allConfig
[
typeof
(
T
).
Name
];
return
config
Manager
[
type
];
var
config
Category
=
(
ConfigCategory
<
T
>)
this
.
allConfig
[
typeof
(
T
).
Name
];
return
config
Category
[
type
];
}
public
Dictionary
<
int
,
T
>
GetAll
<
T
>()
where
T
:
IType
{
var
config
Manager
=
(
ConfigCategory
<
T
>)
this
.
allConfig
[
typeof
(
T
).
Name
];
return
config
Manager
.
GetAll
();
var
config
Category
=
(
ConfigCategory
<
T
>)
this
.
allConfig
[
typeof
(
T
).
Name
];
return
config
Category
.
GetAll
();
}
public
ConfigCategory
<
T
>
GetConfig
Manager
<
T
>()
where
T
:
IType
public
ConfigCategory
<
T
>
GetConfig
Category
<
T
>()
where
T
:
IType
{
return
(
ConfigCategory
<
T
>)
this
.
allConfig
[
typeof
(
T
).
Name
];
}
...
...
CSharp/
Game/Component
/IType.cs
→
CSharp/
Platform/Common/Config
/IType.cs
浏览文件 @
95a8e65a
namespace
Component
namespace
Model
{
public
interface
IType
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录