Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
老鱼er
et
提交
a594cc50
E
et
项目概览
老鱼er
/
et
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
1
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,发现更多精彩内容 >>
提交
a594cc50
编写于
10月 27, 2014
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
动态加载Controller Assembly,以后可以方便的Reload
上级
d2208d6c
变更
27
隐藏空白更改
内联
并排
Showing
27 changed file
with
325 addition
and
119 deletion
+325
-119
CSharp/CSharp.sln
CSharp/CSharp.sln
+17
-15
CSharp/Game/BehaviorTree/NodeType.cs
CSharp/Game/BehaviorTree/NodeType.cs
+0
-9
CSharp/Game/Controller/BehaviorTreeNode/Not.cs
CSharp/Game/Controller/BehaviorTreeNode/Not.cs
+1
-1
CSharp/Game/Controller/BehaviorTreeNode/Selector.cs
CSharp/Game/Controller/BehaviorTreeNode/Selector.cs
+1
-1
CSharp/Game/Controller/BehaviorTreeNode/Sequence.cs
CSharp/Game/Controller/BehaviorTreeNode/Sequence.cs
+1
-1
CSharp/Game/Controller/Controller.csproj
CSharp/Game/Controller/Controller.csproj
+26
-0
CSharp/Game/Controller/Factories/UnitFactory.cs
CSharp/Game/Controller/Factories/UnitFactory.cs
+15
-0
CSharp/Game/Controller/NodeType.cs
CSharp/Game/Controller/NodeType.cs
+9
-0
CSharp/Game/Controller/UnitType.cs
CSharp/Game/Controller/UnitType.cs
+9
-0
CSharp/Game/Controller/packages.config
CSharp/Game/Controller/packages.config
+1
-1
CSharp/Game/Model/BehaviorTree/BehaviorTree.cs
CSharp/Game/Model/BehaviorTree/BehaviorTree.cs
+1
-1
CSharp/Game/Model/BehaviorTree/BehaviorTreeFactory.cs
CSharp/Game/Model/BehaviorTree/BehaviorTreeFactory.cs
+8
-11
CSharp/Game/Model/BehaviorTree/BlackBoard.cs
CSharp/Game/Model/BehaviorTree/BlackBoard.cs
+1
-1
CSharp/Game/Model/BehaviorTree/Node.cs
CSharp/Game/Model/BehaviorTree/Node.cs
+1
-2
CSharp/Game/Model/BehaviorTree/NodeAttribute.cs
CSharp/Game/Model/BehaviorTree/NodeAttribute.cs
+3
-3
CSharp/Game/Model/Component/BehaviorTreeComponent.cs
CSharp/Game/Model/Component/BehaviorTreeComponent.cs
+24
-0
CSharp/Game/Model/Component/BuffComponent.cs
CSharp/Game/Model/Component/BuffComponent.cs
+18
-18
CSharp/Game/Model/Component/ConfigComponent.cs
CSharp/Game/Model/Component/ConfigComponent.cs
+17
-28
CSharp/Game/Model/Component/FactoryComponent.cs
CSharp/Game/Model/Component/FactoryComponent.cs
+49
-0
CSharp/Game/Model/Component/UnitComponent.cs
CSharp/Game/Model/Component/UnitComponent.cs
+3
-3
CSharp/Game/Model/Config/UnitConfig.cs
CSharp/Game/Model/Config/UnitConfig.cs
+1
-1
CSharp/Game/Model/Model.csproj
CSharp/Game/Model/Model.csproj
+10
-6
CSharp/Game/Model/UnitType.cs
CSharp/Game/Model/UnitType.cs
+0
-9
CSharp/Game/Model/World.cs
CSharp/Game/Model/World.cs
+0
-7
CSharp/Game/MongoDBTest/MongoDBTest.cs
CSharp/Game/MongoDBTest/MongoDBTest.cs
+21
-1
CSharp/Server/Login/Login.csproj
CSharp/Server/Login/Login.csproj
+52
-0
CSharp/Server/Login/Properties/AssemblyInfo.cs
CSharp/Server/Login/Properties/AssemblyInfo.cs
+36
-0
未找到文件。
CSharp/CSharp.sln
浏览文件 @
a594cc50
...
...
@@ -30,8 +30,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ENetTest", "Platform\ENetTe
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Game", "Game", "{D0CC1FF4-2747-4278-A51F-BE9AA959175B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BehaviorTree", "Game\BehaviorTree\BehaviorTree.csproj", "{C4E7A34A-095C-4983-AB63-FC2D20CD6824}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ENetExe", "Platform\ENetExe\ENetExe.csproj", "{CBA52DC8-1C80-4A79-9AC5-73514EBBD749}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2814EB55-E1C2-4751-AC14-94116DA9D22B}"
...
...
@@ -50,6 +48,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BehaviorTreeModule", "App\M
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDBTest", "Game\MongoDBTest\MongoDBTest.csproj", "{93FB20CF-827A-4CED-A273-90117EB7192F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Server", "Server", "{AAD111B8-4746-4445-A428-97A72A04FCCD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Login", "Server\Login\Login.csproj", "{2B3EC6BE-0920-4C93-934F-41DC76108818}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
...
...
@@ -126,18 +128,6 @@ Global
{901A8E5C-C4C6-4C3C-8E18-068D75119F5D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{901A8E5C-C4C6-4C3C-8E18-068D75119F5D}.Release|Win32.ActiveCfg = Release|Any CPU
{901A8E5C-C4C6-4C3C-8E18-068D75119F5D}.Release|x86.ActiveCfg = Release|Any CPU
{C4E7A34A-095C-4983-AB63-FC2D20CD6824}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C4E7A34A-095C-4983-AB63-FC2D20CD6824}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4E7A34A-095C-4983-AB63-FC2D20CD6824}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{C4E7A34A-095C-4983-AB63-FC2D20CD6824}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{C4E7A34A-095C-4983-AB63-FC2D20CD6824}.Debug|Win32.ActiveCfg = Debug|Any CPU
{C4E7A34A-095C-4983-AB63-FC2D20CD6824}.Debug|x86.ActiveCfg = Debug|Any CPU
{C4E7A34A-095C-4983-AB63-FC2D20CD6824}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4E7A34A-095C-4983-AB63-FC2D20CD6824}.Release|Any CPU.Build.0 = Release|Any CPU
{C4E7A34A-095C-4983-AB63-FC2D20CD6824}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{C4E7A34A-095C-4983-AB63-FC2D20CD6824}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{C4E7A34A-095C-4983-AB63-FC2D20CD6824}.Release|Win32.ActiveCfg = Release|Any CPU
{C4E7A34A-095C-4983-AB63-FC2D20CD6824}.Release|x86.ActiveCfg = Release|Any CPU
{CBA52DC8-1C80-4A79-9AC5-73514EBBD749}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CBA52DC8-1C80-4A79-9AC5-73514EBBD749}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CBA52DC8-1C80-4A79-9AC5-73514EBBD749}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
...
...
@@ -234,6 +224,18 @@ Global
{93FB20CF-827A-4CED-A273-90117EB7192F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{93FB20CF-827A-4CED-A273-90117EB7192F}.Release|Win32.ActiveCfg = Release|Any CPU
{93FB20CF-827A-4CED-A273-90117EB7192F}.Release|x86.ActiveCfg = Release|Any CPU
{2B3EC6BE-0920-4C93-934F-41DC76108818}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2B3EC6BE-0920-4C93-934F-41DC76108818}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2B3EC6BE-0920-4C93-934F-41DC76108818}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{2B3EC6BE-0920-4C93-934F-41DC76108818}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{2B3EC6BE-0920-4C93-934F-41DC76108818}.Debug|Win32.ActiveCfg = Debug|Any CPU
{2B3EC6BE-0920-4C93-934F-41DC76108818}.Debug|x86.ActiveCfg = Debug|Any CPU
{2B3EC6BE-0920-4C93-934F-41DC76108818}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2B3EC6BE-0920-4C93-934F-41DC76108818}.Release|Any CPU.Build.0 = Release|Any CPU
{2B3EC6BE-0920-4C93-934F-41DC76108818}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2B3EC6BE-0920-4C93-934F-41DC76108818}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2B3EC6BE-0920-4C93-934F-41DC76108818}.Release|Win32.ActiveCfg = Release|Any CPU
{2B3EC6BE-0920-4C93-934F-41DC76108818}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
...
...
@@ -245,7 +247,6 @@ Global
{C9992B7C-313E-4C9F-A954-640D01EDFB58} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
{D0B4CFAC-A368-4742-9863-68776CFA9938} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
{901A8E5C-C4C6-4C3C-8E18-068D75119F5D} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
{C4E7A34A-095C-4983-AB63-FC2D20CD6824} = {D0CC1FF4-2747-4278-A51F-BE9AA959175B}
{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}
...
...
@@ -254,5 +255,6 @@ Global
{E69C1F22-E004-4D69-8667-787BD243454B} = {D0CC1FF4-2747-4278-A51F-BE9AA959175B}
{6CD185D1-08E0-4729-A999-2D5B57BA8193} = {C4C64188-4FAE-4CC3-A9E6-D9D4AF7429B6}
{93FB20CF-827A-4CED-A273-90117EB7192F} = {D0CC1FF4-2747-4278-A51F-BE9AA959175B}
{2B3EC6BE-0920-4C93-934F-41DC76108818} = {AAD111B8-4746-4445-A428-97A72A04FCCD}
EndGlobalSection
EndGlobal
CSharp/Game/BehaviorTree/NodeType.cs
已删除
100644 → 0
浏览文件 @
d2208d6c
namespace
BehaviorTree
{
public
enum
NodeType
{
Selector
=
1
,
Sequence
=
2
,
Not
=
10
,
}
}
\ No newline at end of file
CSharp/Game/
BehaviorTre
e/Not.cs
→
CSharp/Game/
Controller/BehaviorTreeNod
e/Not.cs
浏览文件 @
a594cc50
using
Model
;
namespace
BehaviorTree
namespace
Controller
{
[
Node
(
NodeType
.
Not
)]
public
class
Not
:
Node
...
...
CSharp/Game/
BehaviorTre
e/Selector.cs
→
CSharp/Game/
Controller/BehaviorTreeNod
e/Selector.cs
浏览文件 @
a594cc50
using
Model
;
namespace
BehaviorTree
namespace
Controller
{
[
Node
(
NodeType
.
Selector
)]
public
class
Selector
:
Node
...
...
CSharp/Game/
BehaviorTre
e/Sequence.cs
→
CSharp/Game/
Controller/BehaviorTreeNod
e/Sequence.cs
浏览文件 @
a594cc50
using
Model
;
namespace
BehaviorTree
namespace
Controller
{
[
Node
(
NodeType
.
Sequence
)]
internal
class
Sequence
:
Node
...
...
CSharp/Game/Controller/Controller.csproj
浏览文件 @
a594cc50
...
...
@@ -12,6 +12,8 @@
<TargetFrameworkVersion>
v4.5.1
</TargetFrameworkVersion>
<FileAlignment>
512
</FileAlignment>
<TargetFrameworkProfile
/>
<SolutionDir
Condition=
"$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'"
>
..\..\
</SolutionDir>
<RestorePackages>
true
</RestorePackages>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
>
<DebugSymbols>
true
</DebugSymbols>
...
...
@@ -31,11 +33,25 @@
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"MongoDB.Bson, Version=1.9.2.235, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL"
>
<SpecificVersion>
False
</SpecificVersion>
<HintPath>
..\..\packages\mongocsharpdriver.1.9.2\lib\net35\MongoDB.Bson.dll
</HintPath>
</Reference>
<Reference
Include=
"MongoDB.Driver, Version=1.9.2.235, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL"
>
<SpecificVersion>
False
</SpecificVersion>
<HintPath>
..\..\packages\mongocsharpdriver.1.9.2\lib\net35\MongoDB.Driver.dll
</HintPath>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Core"
/>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"BehaviorTreeNode\Not.cs"
/>
<Compile
Include=
"BehaviorTreeNode\Selector.cs"
/>
<Compile
Include=
"BehaviorTreeNode\Sequence.cs"
/>
<Compile
Include=
"BuffController.cs"
/>
<Compile
Include=
"NodeType.cs"
/>
<Compile
Include=
"Factories\UnitFactory.cs"
/>
<Compile
Include=
"UnitType.cs"
/>
</ItemGroup>
<ItemGroup>
<Folder
Include=
"Properties\"
/>
...
...
@@ -50,7 +66,17 @@
<Name>
Model
</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None
Include=
"packages.config"
/>
</ItemGroup>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
<Import
Project=
"$(SolutionDir)\.nuget\NuGet.targets"
Condition=
"Exists('$(SolutionDir)\.nuget\NuGet.targets')"
/>
<Target
Name=
"EnsureNuGetPackageBuildImports"
BeforeTargets=
"PrepareForBuild"
>
<PropertyGroup>
<ErrorText>
这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
</ErrorText>
</PropertyGroup>
<Error
Condition=
"!Exists('$(SolutionDir)\.nuget\NuGet.targets')"
Text=
"$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))"
/>
</Target>
<!-- 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">
...
...
CSharp/Game/
Model
/UnitFactory.cs
→
CSharp/Game/
Controller/Factories
/UnitFactory.cs
浏览文件 @
a594cc50
namespace
Model
{
public
static
class
UnitFactory
{
public
static
Unit
Create
(
int
configId
)
{
return
World
.
Instance
.
GetComponent
<
FactoryComponent
<
Unit
>>().
Create
(
configId
);
}
}
using
Model
;
[
FactoryAttribute
(
typeof
(
Unit
),
(
int
)
UnitType
.
Player
)]
namespace
Controller
{
[
Factory
(
typeof
(
Unit
),
UnitType
.
Player
)]
public
class
UnitPlayerFactory
:
IFactory
<
Unit
>
{
public
Unit
Create
(
int
configId
)
...
...
CSharp/Game/Controller/NodeType.cs
0 → 100644
浏览文件 @
a594cc50
namespace
Controller
{
public
static
class
NodeType
{
public
const
int
Selector
=
1
;
public
const
int
Sequence
=
2
;
public
const
int
Not
=
10
;
}
}
\ No newline at end of file
CSharp/Game/Controller/UnitType.cs
0 → 100644
浏览文件 @
a594cc50
namespace
Controller
{
public
static
class
UnitType
{
public
const
int
Player
=
1
;
public
const
int
Npc
=
2
;
public
const
int
Dog
=
3
;
}
}
CSharp/Game/
BehaviorTree/P
ackages.config
→
CSharp/Game/
Controller/p
ackages.config
浏览文件 @
a594cc50
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"mongocsharpdriver"
version
=
"1.9.2"
targetFramework
=
"net45"
/>
<
package
id
=
"mongocsharpdriver"
version
=
"1.9.2"
targetFramework
=
"net45
1
"
/>
</
packages
>
\ No newline at end of file
CSharp/Game/BehaviorTree/BehaviorTree.cs
→
CSharp/Game/
Model/
BehaviorTree/BehaviorTree.cs
浏览文件 @
a594cc50
namespace
BehaviorTree
namespace
Model
{
public
class
BehaviorTree
{
...
...
CSharp/Game/BehaviorTree/BehaviorTreeFactory.cs
→
CSharp/Game/
Model/
BehaviorTree/BehaviorTreeFactory.cs
浏览文件 @
a594cc50
using
System
;
using
System.Collections.Generic
;
using
System.Reflection
;
using
Model
;
namespace
BehaviorTree
namespace
Model
{
public
class
BehaviorTreeFactory
{
...
...
@@ -17,17 +16,16 @@ namespace BehaviorTree
}
}
private
readonly
Dictionary
<
NodeType
,
Func
<
NodeConfig
,
Node
>>
dictionary
=
new
Dictionary
<
NodeType
,
Func
<
NodeConfig
,
Node
>>();
private
Dictionary
<
int
,
Func
<
NodeConfig
,
Node
>>
dictionary
;
private
BehaviorTreeFactory
()
{
Assembly
assembly
=
typeof
(
BehaviorTreeFactory
).
Assembly
;
this
.
RegisterNodes
(
assembly
);
}
public
void
RegisterNodes
(
Assembly
assembly
)
public
void
Load
(
Assembly
assembly
)
{
this
.
dictionary
=
new
Dictionary
<
int
,
Func
<
NodeConfig
,
Node
>>();
Type
[]
types
=
assembly
.
GetTypes
();
foreach
(
var
type
in
types
)
{
...
...
@@ -40,19 +38,18 @@ namespace BehaviorTree
Type
classType
=
type
;
this
.
dictionary
.
Add
(
attribute
.
NodeType
,
config
=>
(
Node
)
Activator
.
CreateInstance
(
classType
,
new
object
[]
{
config
}));
config
=>
(
Node
)
Activator
.
CreateInstance
(
classType
,
new
object
[]
{
config
}));
}
}
private
Node
CreateNode
(
NodeConfig
config
)
{
if
(!
this
.
dictionary
.
ContainsKey
(
(
NodeType
)
config
.
Id
))
if
(!
this
.
dictionary
.
ContainsKey
(
config
.
Id
))
{
throw
new
KeyNotFoundException
(
string
.
Format
(
"CreateNode cannot found: {0}"
,
config
.
Id
));
}
return
this
.
dictionary
[
(
NodeType
)
config
.
Id
](
config
);
return
this
.
dictionary
[
config
.
Id
](
config
);
}
private
Node
CreateTreeNode
(
NodeConfig
config
)
...
...
CSharp/Game/BehaviorTree/BlackBoard.cs
→
CSharp/Game/
Model/
BehaviorTree/BlackBoard.cs
浏览文件 @
a594cc50
using
Common.Base
;
namespace
BehaviorTree
namespace
Model
{
public
class
BlackBoard
:
Object
{
...
...
CSharp/Game/BehaviorTree/Node.cs
→
CSharp/Game/
Model/
BehaviorTree/Node.cs
浏览文件 @
a594cc50
using
System.Collections.Generic
;
using
Model
;
namespace
BehaviorTree
namespace
Model
{
public
abstract
class
Node
{
...
...
CSharp/Game/BehaviorTree/NodeAttribute.cs
→
CSharp/Game/
Model/
BehaviorTree/NodeAttribute.cs
浏览文件 @
a594cc50
using
System
;
namespace
BehaviorTree
namespace
Model
{
[
AttributeUsage
(
AttributeTargets
.
Class
)]
public
class
NodeAttribute
:
Attribute
{
public
NodeType
NodeType
{
get
;
private
set
;
}
public
int
NodeType
{
get
;
private
set
;
}
public
NodeAttribute
(
NodeType
nodeType
)
public
NodeAttribute
(
int
nodeType
)
{
this
.
NodeType
=
nodeType
;
}
...
...
CSharp/Game/Model/Component/BehaviorTreeComponent.cs
0 → 100644
浏览文件 @
a594cc50
using
System.Collections.Generic
;
using
System.Reflection
;
using
Common.Base
;
namespace
Model
{
public
class
BehaviorTreeComponent
:
Component
<
World
>
{
private
Dictionary
<
int
,
BehaviorTree
>
trees
=
new
Dictionary
<
int
,
BehaviorTree
>();
public
void
Load
(
Assembly
assembly
)
{
BehaviorTreeFactory
behaviorTreeFactory
=
BehaviorTreeFactory
.
Instance
;
behaviorTreeFactory
.
Load
(
assembly
);
NodeConfig
[]
nodeConfigs
=
World
.
Instance
.
GetComponent
<
ConfigComponent
>().
GetAll
<
NodeConfig
>();
foreach
(
NodeConfig
nodeConfig
in
nodeConfigs
)
{
BehaviorTree
behaviorTree
=
behaviorTreeFactory
.
CreateTree
(
nodeConfig
);
this
.
trees
[
nodeConfig
.
Id
]
=
behaviorTree
;
}
}
}
}
CSharp/Game/Model/BuffComponent.cs
→
CSharp/Game/Model/
Component/
BuffComponent.cs
浏览文件 @
a594cc50
...
...
@@ -9,17 +9,17 @@ namespace Model
public
class
BuffComponent
:
Component
<
Unit
>
{
[
BsonElement
]
private
HashSet
<
Buff
>
buffs
{
get
;
set
;
}
private
HashSet
<
Buff
>
buffs
;
private
Dictionary
<
ObjectId
,
Buff
>
buffIdDict
{
get
;
set
;
}
private
Dictionary
<
ObjectId
,
Buff
>
idBuff
;
private
MultiMap
<
BuffType
,
Buff
>
buffTypeMMap
{
get
;
set
;
}
private
MultiMap
<
BuffType
,
Buff
>
typeBuff
;
public
BuffComponent
()
{
this
.
buffs
=
new
HashSet
<
Buff
>();
this
.
buffIdDict
=
new
Dictionary
<
ObjectId
,
Buff
>();
this
.
buffTypeMMap
=
new
MultiMap
<
BuffType
,
Buff
>();
this
.
idBuff
=
new
Dictionary
<
ObjectId
,
Buff
>();
this
.
typeBuff
=
new
MultiMap
<
BuffType
,
Buff
>();
}
public
override
void
BeginInit
()
...
...
@@ -27,8 +27,8 @@ namespace Model
base
.
BeginInit
();
this
.
buffs
=
new
HashSet
<
Buff
>();
this
.
buffIdDict
=
new
Dictionary
<
ObjectId
,
Buff
>();
this
.
buffTypeMMap
=
new
MultiMap
<
BuffType
,
Buff
>();
this
.
idBuff
=
new
Dictionary
<
ObjectId
,
Buff
>();
this
.
typeBuff
=
new
MultiMap
<
BuffType
,
Buff
>();
}
public
override
void
EndInit
()
...
...
@@ -37,8 +37,8 @@ namespace Model
foreach
(
var
buff
in
this
.
buffs
)
{
this
.
buffIdDict
.
Add
(
buff
.
Id
,
buff
);
this
.
buffTypeMMap
.
Add
(
buff
.
Config
.
Type
,
buff
);
this
.
idBuff
.
Add
(
buff
.
Id
,
buff
);
this
.
typeBuff
.
Add
(
buff
.
Config
.
Type
,
buff
);
}
}
...
...
@@ -49,34 +49,34 @@ namespace Model
throw
new
ArgumentException
(
string
.
Format
(
"already exist same buff, Id: {0} ConfigId: {1}"
,
buff
.
Id
,
buff
.
Config
.
Id
));
}
if
(
this
.
buffIdDict
.
ContainsKey
(
buff
.
Id
))
if
(
this
.
idBuff
.
ContainsKey
(
buff
.
Id
))
{
throw
new
ArgumentException
(
string
.
Format
(
"already exist same buff, Id: {0} ConfigId: {1}"
,
buff
.
Id
,
buff
.
Config
.
Id
));
}
this
.
buffs
.
Add
(
buff
);
this
.
buffIdDict
.
Add
(
buff
.
Id
,
buff
);
this
.
buffTypeMMap
.
Add
(
buff
.
Config
.
Type
,
buff
);
this
.
idBuff
.
Add
(
buff
.
Id
,
buff
);
this
.
typeBuff
.
Add
(
buff
.
Config
.
Type
,
buff
);
}
public
Buff
GetById
(
ObjectId
id
)
{
if
(!
this
.
buffIdDict
.
ContainsKey
(
id
))
if
(!
this
.
idBuff
.
ContainsKey
(
id
))
{
return
null
;
}
return
this
.
buffIdDict
[
id
];
return
this
.
idBuff
[
id
];
}
public
Buff
GetOneByType
(
BuffType
type
)
{
return
this
.
buffTypeMMap
.
GetOne
(
type
);
return
this
.
typeBuff
.
GetOne
(
type
);
}
public
Buff
[]
GetByType
(
BuffType
type
)
{
return
this
.
buffTypeMMap
.
GetByKey
(
type
);
return
this
.
typeBuff
.
GetByKey
(
type
);
}
private
bool
Remove
(
Buff
buff
)
...
...
@@ -87,8 +87,8 @@ namespace Model
}
this
.
buffs
.
Remove
(
buff
);
this
.
buffIdDict
.
Remove
(
buff
.
Id
);
this
.
buffTypeMMap
.
Remove
(
buff
.
Config
.
Type
,
buff
);
this
.
idBuff
.
Remove
(
buff
.
Id
);
this
.
typeBuff
.
Remove
(
buff
.
Config
.
Type
,
buff
);
return
true
;
}
...
...
CSharp/Game/Model/ConfigComponent.cs
→
CSharp/Game/Model/Co
mponent/Co
nfigComponent.cs
浏览文件 @
a594cc50
...
...
@@ -10,42 +10,31 @@ namespace Model
{
public
Dictionary
<
Type
,
ICategory
>
allConfig
;
private
Assembly
[]
assemblies
;
public
void
Load
(
Assembly
[]
ass
)
public
void
Load
(
Assembly
assembly
)
{
allConfig
=
new
Dictionary
<
Type
,
ICategory
>();
this
.
assemblies
=
ass
;
foreach
(
Assembly
assembly
in
assembli
es
)
Type
[]
types
=
assembly
.
GetTypes
()
;
foreach
(
Type
type
in
typ
es
)
{
Type
[]
types
=
assembly
.
GetTypes
(
);
foreach
(
Type
type
in
types
)
object
[]
attrs
=
type
.
GetCustomAttributes
(
typeof
(
ConfigAttribute
),
false
);
if
(
attrs
.
Length
==
0
)
{
object
[]
attrs
=
type
.
GetCustomAttributes
(
typeof
(
ConfigAttribute
),
false
);
if
(
attrs
.
Length
==
0
)
{
continue
;
}
object
obj
=
(
Activator
.
CreateInstance
(
type
));
continue
;
}
ICategory
iCategory
=
obj
as
ICategory
;
if
(
iCategory
==
null
)
{
throw
new
Exception
(
string
.
Format
(
"class: {0} not inherit from ACategory"
,
type
.
Name
));
}
iCategory
.
BeginInit
();
iCategory
.
EndInit
();
object
obj
=
(
Activator
.
CreateInstance
(
type
));
allConfig
[
iCategory
.
ConfigType
]
=
iCategory
;
ICategory
iCategory
=
obj
as
ICategory
;
if
(
iCategory
==
null
)
{
throw
new
Exception
(
string
.
Format
(
"class: {0} not inherit from ACategory"
,
type
.
Name
));
}
}
}
iCategory
.
BeginInit
();
iCategory
.
EndInit
();
public
void
Reload
()
{
this
.
Load
(
this
.
assemblies
);
allConfig
[
iCategory
.
ConfigType
]
=
iCategory
;
}
}
public
T
Get
<
T
>(
int
id
)
where
T
:
AConfig
...
...
CSharp/Game/Model/FactoryComponent.cs
→
CSharp/Game/Model/
Component/
FactoryComponent.cs
浏览文件 @
a594cc50
...
...
@@ -9,37 +9,34 @@ namespace Model
{
private
Dictionary
<
int
,
IFactory
<
T
>>
allConfig
;
public
void
Load
(
IEnumerable
<
Assembly
>
assemblies
)
public
void
Load
(
Assembly
assembly
)
{
allConfig
=
new
Dictionary
<
int
,
IFactory
<
T
>>();
foreach
(
Assembly
assembly
in
assemblies
)
Type
[]
types
=
assembly
.
GetTypes
();
foreach
(
Type
type
in
types
)
{
Type
[]
types
=
assembly
.
GetTypes
(
);
foreach
(
Type
type
in
types
)
object
[]
attrs
=
type
.
GetCustomAttributes
(
typeof
(
FactoryAttribute
),
false
);
if
(
attrs
.
Length
==
0
)
{
object
[]
attrs
=
type
.
GetCustomAttributes
(
typeof
(
FactoryAttribute
),
false
);
if
(
attrs
.
Length
==
0
)
{
continue
;
}
FactoryAttribute
attribute
=
(
FactoryAttribute
)
attrs
[
0
];
if
(
attribute
.
ClassType
!=
typeof
(
T
))
{
continue
;
}
continue
;
}
object
obj
=
(
Activator
.
CreateInstance
(
type
));
FactoryAttribute
attribute
=
(
FactoryAttribute
)
attrs
[
0
];
if
(
attribute
.
ClassType
!=
typeof
(
T
))
{
continue
;
}
IFactory
<
T
>
iFactory
=
obj
as
IFactory
<
T
>;
if
(
iFactory
==
null
)
{
throw
new
Exception
(
string
.
Format
(
"class: {0} not inherit from IFactory"
,
type
.
Name
));
}
object
obj
=
(
Activator
.
CreateInstance
(
type
));
allConfig
[
attribute
.
Type
]
=
iFactory
;
IFactory
<
T
>
iFactory
=
obj
as
IFactory
<
T
>;
if
(
iFactory
==
null
)
{
throw
new
Exception
(
string
.
Format
(
"class: {0} not inherit from IFactory"
,
type
.
Name
));
}
allConfig
[
attribute
.
Type
]
=
iFactory
;
}
}
...
...
CSharp/Game/Model/UnitComponent.cs
→
CSharp/Game/Model/
Component/
UnitComponent.cs
浏览文件 @
a594cc50
...
...
@@ -11,8 +11,8 @@ namespace Model
private
readonly
Dictionary
<
ObjectId
,
Unit
>
units
=
new
Dictionary
<
ObjectId
,
Unit
>();
private
readonly
Dictionary
<
UnitType
,
Dictionary
<
ObjectId
,
Unit
>>
typeUnits
=
new
Dictionary
<
UnitType
,
Dictionary
<
ObjectId
,
Unit
>>();
private
readonly
Dictionary
<
int
,
Dictionary
<
ObjectId
,
Unit
>>
typeUnits
=
new
Dictionary
<
int
,
Dictionary
<
ObjectId
,
Unit
>>();
public
void
Add
(
Unit
unit
)
{
...
...
@@ -31,7 +31,7 @@ namespace Model
return
unit
;
}
public
Unit
[]
GetOneType
(
UnitType
type
)
public
Unit
[]
GetOneType
(
int
type
)
{
Dictionary
<
ObjectId
,
Unit
>
oneTypeUnits
=
null
;
if
(!
this
.
typeUnits
.
TryGetValue
(
type
,
out
oneTypeUnits
))
...
...
CSharp/Game/Model/Config/UnitConfig.cs
浏览文件 @
a594cc50
...
...
@@ -4,7 +4,7 @@ namespace Model
{
public
class
UnitConfig
:
AConfig
{
public
UnitType
Type
{
get
;
set
;
}
public
int
Type
{
get
;
set
;
}
}
[
Config
]
...
...
CSharp/Game/Model/Model.csproj
浏览文件 @
a594cc50
...
...
@@ -45,19 +45,23 @@
<Reference
Include=
"System.Core"
/>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"Component\BehaviorTreeComponent.cs"
/>
<Compile
Include=
"BehaviorTree\BehaviorTree.cs"
/>
<Compile
Include=
"BehaviorTree\BehaviorTreeFactory.cs"
/>
<Compile
Include=
"BehaviorTree\BlackBoard.cs"
/>
<Compile
Include=
"BehaviorTree\Node.cs"
/>
<Compile
Include=
"BehaviorTree\NodeAttribute.cs"
/>
<Compile
Include=
"Buff.cs"
/>
<Compile
Include=
"BuffComponent.cs"
/>
<Compile
Include=
"ConfigComponent.cs"
/>
<Compile
Include=
"
Component\
BuffComponent.cs"
/>
<Compile
Include=
"Co
mponent\Co
nfigComponent.cs"
/>
<Compile
Include=
"Config\UnitConfig.cs"
/>
<Compile
Include=
"Config\BuffConfig.cs"
/>
<Compile
Include=
"FactoryAttribute.cs"
/>
<Compile
Include=
"FactoryComponent.cs"
/>
<Compile
Include=
"
Component\
FactoryComponent.cs"
/>
<Compile
Include=
"IFactory.cs"
/>
<Compile
Include=
"UnitFactory.cs"
/>
<Compile
Include=
"UnitType.cs"
/>
<Compile
Include=
"Component\UnitComponent.cs"
/>
<Compile
Include=
"BuffType.cs"
/>
<Compile
Include=
"GameObject.cs"
/>
<Compile
Include=
"UnitComponent.cs"
/>
<Compile
Include=
"Config\GlobalConfig.cs"
/>
<Compile
Include=
"Config\NodeConfig.cs"
/>
<Compile
Include=
"Unit.cs"
/>
...
...
CSharp/Game/Model/UnitType.cs
已删除
100644 → 0
浏览文件 @
d2208d6c
namespace
Model
{
public
enum
UnitType
{
Player
=
1
,
Npc
=
2
,
Dog
=
3
,
}
}
CSharp/Game/Model/World.cs
浏览文件 @
a594cc50
...
...
@@ -14,13 +14,6 @@
private
World
()
{
this
.
AddComponent
<
UnitComponent
>();
ConfigComponent
configComponent
=
this
.
AddComponent
<
ConfigComponent
>();
configComponent
.
Load
(
new
[]
{
typeof
(
World
).
Assembly
});
FactoryComponent
<
Unit
>
factoryComponent
=
this
.
AddComponent
<
FactoryComponent
<
Unit
>>();
factoryComponent
.
Load
(
new
[]
{
typeof
(
World
).
Assembly
});
}
}
}
\ No newline at end of file
CSharp/Game/MongoDBTest/MongoDBTest.cs
浏览文件 @
a594cc50
using
System
;
using
System.IO
;
using
System.Reflection
;
using
Common.Helper
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
Model
;
...
...
@@ -19,7 +21,25 @@ namespace MongoDBTest
var
database
=
server
.
GetDatabase
(
"test"
);
var
collection
=
database
.
GetCollection
<
Unit
>(
"Unit"
);
Unit
player1
=
UnitFactory
.
Create
(
1
);
World
world
=
World
.
Instance
;
// 加载配置
ConfigComponent
configComponent
=
world
.
AddComponent
<
ConfigComponent
>();
configComponent
.
Load
(
typeof
(
World
).
Assembly
);
Assembly
assembly
=
Assembly
.
Load
(
File
.
ReadAllBytes
(
@"./Controller.dll"
));
// 构造工厂
FactoryComponent
<
Unit
>
factoryComponent
=
world
.
AddComponent
<
FactoryComponent
<
Unit
>>();
factoryComponent
.
Load
(
assembly
);
// 构造行为树
BehaviorTreeComponent
behaviorTreeComponent
=
world
.
AddComponent
<
BehaviorTreeComponent
>();
behaviorTreeComponent
.
Load
(
assembly
);
Unit
player1
=
factoryComponent
.
Create
(
1
);
Buff
buff
=
new
Buff
(
1
);
player1
.
GetComponent
<
BuffComponent
>().
Add
(
buff
);
player1
[
"hp"
]
=
10
;
...
...
CSharp/
Game/BehaviorTree/BehaviorTree
.csproj
→
CSharp/
Server/Login/Login
.csproj
浏览文件 @
a594cc50
...
...
@@ -4,22 +4,19 @@
<PropertyGroup>
<Configuration
Condition=
" '$(Configuration)' == '' "
>
Debug
</Configuration>
<Platform
Condition=
" '$(Platform)' == '' "
>
AnyCPU
</Platform>
<ProjectGuid>
{
C4E7A34A-095C-4983-AB63-FC2D20CD6824
}
</ProjectGuid>
<ProjectGuid>
{
2B3EC6BE-0920-4C93-934F-41DC76108818
}
</ProjectGuid>
<OutputType>
Library
</OutputType>
<AppDesignerFolder>
Properties
</AppDesignerFolder>
<RootNamespace>
BehaviorTree
</RootNamespace>
<AssemblyName>
BehaviorTree
</AssemblyName>
<TargetFrameworkVersion>
v4.5
.1
</TargetFrameworkVersion>
<RootNamespace>
Login
</RootNamespace>
<AssemblyName>
Login
</AssemblyName>
<TargetFrameworkVersion>
v4.5
</TargetFrameworkVersion>
<FileAlignment>
512
</FileAlignment>
<SolutionDir
Condition=
"$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'"
>
..\..\
</SolutionDir>
<RestorePackages>
true
</RestorePackages>
<TargetFrameworkProfile
/>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
>
<DebugSymbols>
true
</DebugSymbols>
<DebugType>
full
</DebugType>
<Optimize>
false
</Optimize>
<OutputPath>
..\..\B
in\Debug\
</OutputPath>
<OutputPath>
b
in\Debug\
</OutputPath>
<DefineConstants>
DEBUG;TRACE
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
...
...
@@ -27,56 +24,29 @@
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "
>
<DebugType>
pdbonly
</DebugType>
<Optimize>
true
</Optimize>
<OutputPath>
..\..\B
in\Release\
</OutputPath>
<OutputPath>
b
in\Release\
</OutputPath>
<DefineConstants>
TRACE
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"MongoDB.Bson, Version=1.9.2.235, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL"
>
<SpecificVersion>
False
</SpecificVersion>
<HintPath>
..\..\packages\mongocsharpdriver.1.9.2\lib\net35\MongoDB.Bson.dll
</HintPath>
</Reference>
<Reference
Include=
"MongoDB.Driver"
>
<HintPath>
..\..\packages\mongocsharpdriver.1.9.2\lib\net35\MongoDB.Driver.dll
</HintPath>
</Reference>
<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=
"BehaviorTree.cs"
/>
<Compile
Include=
"BlackBoard.cs"
/>
<Compile
Include=
"Node.cs"
/>
<Compile
Include=
"BehaviorTreeFactory.cs"
/>
<Compile
Include=
"NodeAttribute.cs"
/>
<Compile
Include=
"NodeType.cs"
/>
<Compile
Include=
"Not.cs"
/>
<Compile
Include=
"Selector.cs"
/>
<Compile
Include=
"Sequence.cs"
/>
</ItemGroup>
<ItemGroup>
<ProjectReference
Include=
"..\..\Platform\Common\Common.csproj"
>
<Project>
{19f8f043-1f99-4550-99df-dea5c7d77e55}
</Project>
<Name>
Common
</Name>
</ProjectReference>
<ProjectReference
Include=
"..\Model\Model.csproj"
>
<Project>
{0FA529D1-D0A9-4A8E-90F5-117CE80F2EDE}
</Project>
<Name>
Model
</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None
Include=
"packages.config"
/>
</ItemGroup>
<ItemGroup>
<Folder
Include=
"Properties\"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
</ItemGroup>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
<Import
Project=
"$(SolutionDir)\.nuget\NuGet.targets"
Condition=
"Exists('$(SolutionDir)\.nuget\NuGet.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>
<!-- 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/Server/Login/Properties/AssemblyInfo.cs
0 → 100644
浏览文件 @
a594cc50
using
System.Reflection
;
using
System.Runtime.CompilerServices
;
using
System.Runtime.InteropServices
;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[
assembly
:
AssemblyTitle
(
"Login"
)]
[
assembly
:
AssemblyDescription
(
""
)]
[
assembly
:
AssemblyConfiguration
(
""
)]
[
assembly
:
AssemblyCompany
(
"Microsoft"
)]
[
assembly
:
AssemblyProduct
(
"Login"
)]
[
assembly
:
AssemblyCopyright
(
"Copyright © Microsoft 2014"
)]
[
assembly
:
AssemblyTrademark
(
""
)]
[
assembly
:
AssemblyCulture
(
""
)]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[
assembly
:
ComVisible
(
false
)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[
assembly
:
Guid
(
"bef9bfd1-d7ec-45dd-95b1-7b4397ab4812"
)]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[
assembly
:
AssemblyVersion
(
"1.0.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.0.0.0"
)]
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录