Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
老鱼er
et
提交
54d25fc0
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,发现更多精彩内容 >>
提交
54d25fc0
编写于
1月 08, 2015
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加ServiceComponent,处理连接,分发封包处理
上级
7cb15395
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
80 addition
and
22 deletion
+80
-22
CSharp/Game/Model/Component/BehaviorTreeComponent.cs
CSharp/Game/Model/Component/BehaviorTreeComponent.cs
+9
-1
CSharp/Game/Model/Component/BuffComponent.cs
CSharp/Game/Model/Component/BuffComponent.cs
+1
-0
CSharp/Game/Model/Component/EventComponent.cs
CSharp/Game/Model/Component/EventComponent.cs
+2
-2
CSharp/Game/Model/Component/FactoryComponent.cs
CSharp/Game/Model/Component/FactoryComponent.cs
+1
-1
CSharp/Game/Model/Component/MessageComponent.cs
CSharp/Game/Model/Component/MessageComponent.cs
+0
-9
CSharp/Game/Model/Component/ServiceComponent.cs
CSharp/Game/Model/Component/ServiceComponent.cs
+49
-0
CSharp/Game/Model/Component/TimerComponent.cs
CSharp/Game/Model/Component/TimerComponent.cs
+1
-1
CSharp/Game/Model/EnvKey.cs
CSharp/Game/Model/EnvKey.cs
+1
-0
CSharp/Game/Model/Model.csproj
CSharp/Game/Model/Model.csproj
+9
-1
CSharp/Game/MongoDBTest/MongoDBTest.cs
CSharp/Game/MongoDBTest/MongoDBTest.cs
+5
-5
CSharp/Platform/Common/Config/ACategory.cs
CSharp/Platform/Common/Config/ACategory.cs
+2
-2
未找到文件。
CSharp/Game/Model/Component/BehaviorTreeComponent.cs
浏览文件 @
54d25fc0
...
...
@@ -6,7 +6,7 @@ namespace Model
{
public
class
BehaviorTreeComponent
:
Component
<
World
>,
IAssemblyLoader
{
private
Dictionary
<
int
,
BehaviorTree
>
trees
=
new
Dictionary
<
int
,
BehaviorTree
>();
private
readonly
Dictionary
<
int
,
BehaviorTree
>
trees
=
new
Dictionary
<
int
,
BehaviorTree
>();
public
void
Load
(
Assembly
assembly
)
{
...
...
@@ -20,5 +20,13 @@ namespace Model
this
.
trees
[
nodeConfig
.
Id
]
=
behaviorTree
;
}
}
public
BehaviorTree
this
[
int
id
]
{
get
{
return
this
.
trees
[
id
];
}
}
}
}
\ No newline at end of file
CSharp/Game/Model/Component/BuffComponent.cs
浏览文件 @
54d25fc0
...
...
@@ -111,6 +111,7 @@ namespace Model
this
.
typeBuff
.
Remove
(
buff
.
Config
.
Type
,
buff
);
World
.
Instance
.
GetComponent
<
EventComponent
<
EventAttribute
>>().
Run
(
EventType
.
AfterRemoveBuff
,
env
);
buff
.
Dispose
();
}
public
void
RemoveById
(
ObjectId
id
)
...
...
CSharp/Game/Model/Component/EventComponent.cs
浏览文件 @
54d25fc0
...
...
@@ -15,8 +15,8 @@ namespace Model
{
this
.
events
=
new
Dictionary
<
int
,
List
<
IEvent
>>();
var
types
=
assembly
.
GetTypes
();
foreach
(
var
t
in
types
)
Type
[]
types
=
assembly
.
GetTypes
();
foreach
(
Type
t
in
types
)
{
object
[]
attrs
=
t
.
GetCustomAttributes
(
typeof
(
AttributeType
),
false
);
if
(
attrs
.
Length
==
0
)
...
...
CSharp/Game/Model/Component/FactoryComponent.cs
浏览文件 @
54d25fc0
...
...
@@ -29,7 +29,7 @@ namespace Model
object
obj
=
(
Activator
.
CreateInstance
(
type
));
IFactory
<
T
>
iFactory
=
obj
as
IFactory
<
T
>;
var
iFactory
=
obj
as
IFactory
<
T
>;
if
(
iFactory
==
null
)
{
throw
new
Exception
(
string
.
Format
(
"class: {0} not inherit from IFactory"
,
type
.
Name
));
...
...
CSharp/Game/Model/Component/MessageComponent.cs
已删除
100644 → 0
浏览文件 @
7cb15395
namespace
Model
{
public
class
MessageComponent
{
public
MessageComponent
()
{
}
}
}
\ No newline at end of file
CSharp/Game/Model/Component/ServiceComponent.cs
0 → 100644
浏览文件 @
54d25fc0
using
System
;
using
Common.Base
;
using
Common.Event
;
using
Network
;
using
TNet
;
namespace
Model
{
public
class
ServiceComponent
:
Component
<
World
>
{
private
IService
service
;
public
void
Run
(
string
host
,
int
port
)
{
service
=
new
TService
(
"127.0.0.1"
,
8888
);
service
.
Add
(
AcceptChannel
);
service
.
Run
();
}
/// <summary>
/// 接收连接
/// </summary>
private
async
void
AcceptChannel
()
{
while
(
true
)
{
IChannel
channel
=
await
service
.
GetChannel
();
ProcessChannel
(
channel
);
}
}
/// <summary>
/// 接收分发封包
/// </summary>
/// <param name="channel"></param>
private
static
async
void
ProcessChannel
(
IChannel
channel
)
{
while
(
true
)
{
byte
[]
packet
=
await
channel
.
RecvAsync
();
Env
env
=
new
Env
();
env
[
EnvKey
.
Packet
]
=
packet
;
int
opcode
=
BitConverter
.
ToUInt16
(
packet
,
0
);
World
.
Instance
.
GetComponent
<
EventComponent
<
MessageAttribute
>>().
Run
(
opcode
,
env
);
}
}
}
}
\ No newline at end of file
CSharp/Game/Model/Component/TimerComponent.cs
浏览文件 @
54d25fc0
...
...
@@ -50,7 +50,7 @@ namespace Model
public
void
Update
()
{
long
timeNow
=
TimeHelper
.
Now
();
List
<
long
>
timeoutTimer
=
new
List
<
long
>();
var
timeoutTimer
=
new
List
<
long
>();
foreach
(
long
time
in
this
.
timeId
.
Keys
)
{
if
(
time
>
timeNow
)
...
...
CSharp/Game/Model/EnvKey.cs
浏览文件 @
54d25fc0
...
...
@@ -6,5 +6,6 @@
public
const
string
OwnerId
=
"OwnerId"
;
public
const
string
Buff
=
"Buff"
;
public
const
string
BuffId
=
"BuffId"
;
public
const
string
Packet
=
"Packet"
;
}
}
\ No newline at end of file
CSharp/Game/Model/Model.csproj
浏览文件 @
54d25fc0
...
...
@@ -52,7 +52,7 @@
<Compile
Include=
"BehaviorTree\Node.cs"
/>
<Compile
Include=
"BehaviorTree\NodeAttribute.cs"
/>
<Compile
Include=
"Buff.cs"
/>
<Compile
Include=
"Component\
Messag
eComponent.cs"
/>
<Compile
Include=
"Component\
Servic
eComponent.cs"
/>
<Compile
Include=
"Component\BuffComponent.cs"
/>
<Compile
Include=
"Component\ConfigComponent.cs"
/>
<Compile
Include=
"Component\EventComponent.cs"
/>
...
...
@@ -82,6 +82,14 @@
<Project>
{19f8f043-1f99-4550-99df-dea5c7d77e55}
</Project>
<Name>
Common
</Name>
</ProjectReference>
<ProjectReference
Include=
"..\..\Platform\Network\Network.csproj"
>
<Project>
{3bd499ff-3c34-4920-8b21-c55fba580843}
</Project>
<Name>
Network
</Name>
</ProjectReference>
<ProjectReference
Include=
"..\..\Platform\TNet\TNet.csproj"
>
<Project>
{b42d431a-3a54-4649-942a-c5356d7f9fbc}
</Project>
<Name>
TNet
</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None
Include=
"packages.config"
/>
...
...
CSharp/Game/MongoDBTest/MongoDBTest.cs
浏览文件 @
54d25fc0
...
...
@@ -14,10 +14,10 @@ namespace MongoDBTest
public
void
TestMongoDB
()
{
const
string
connectionString
=
"mongodb://localhost"
;
var
client
=
new
MongoClient
(
connectionString
);
va
r
server
=
client
.
GetServer
();
var
database
=
server
.
GetDatabase
(
"test"
);
var
collection
=
database
.
GetCollection
<
Unit
>(
"Unit"
);
MongoClient
client
=
new
MongoClient
(
connectionString
);
MongoServe
r
server
=
client
.
GetServer
();
MongoDatabase
database
=
server
.
GetDatabase
(
"test"
);
MongoCollection
<
Unit
>
collection
=
database
.
GetCollection
<
Unit
>(
"Unit"
);
World
world
=
World
.
Instance
;
...
...
@@ -36,7 +36,7 @@ namespace MongoDBTest
collection
.
Insert
(
player1
);
var
query
=
Query
<
Unit
>.
EQ
(
e
=>
e
.
Id
,
player1
.
Id
);
IMongoQuery
query
=
Query
<
Unit
>.
EQ
(
e
=>
e
.
Id
,
player1
.
Id
);
Unit
player2
=
collection
.
FindOne
(
query
);
Console
.
WriteLine
(
MongoHelper
.
ToJson
(
player2
));
...
...
CSharp/Platform/Common/Config/ACategory.cs
浏览文件 @
54d25fc0
...
...
@@ -21,9 +21,9 @@ namespace Common.Config
throw
new
Exception
(
string
.
Format
(
"not found config path: {0}"
,
path
));
}
foreach
(
var
file
in
Directory
.
GetFiles
(
path
))
foreach
(
string
file
in
Directory
.
GetFiles
(
path
))
{
var
t
=
MongoHelper
.
FromJson
<
T
>(
File
.
ReadAllText
(
file
));
T
t
=
MongoHelper
.
FromJson
<
T
>(
File
.
ReadAllText
(
file
));
this
.
dict
.
Add
(
t
.
Id
,
t
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录