Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
guo450212436
et
提交
5bb66d41
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,发现更多精彩内容 >>
提交
5bb66d41
编写于
2月 10, 2015
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.增加一个登录消息
2.Network程序集移动到Common中
上级
601cdbe7
变更
34
隐藏空白更改
内联
并排
Showing
34 changed file
with
193 addition
and
200 deletion
+193
-200
CSharp/CSharp.sln
CSharp/CSharp.sln
+1
-16
CSharp/Game/Controller/Action/MessageAction.cs
CSharp/Game/Controller/Action/MessageAction.cs
+20
-8
CSharp/Game/Controller/Controller.csproj
CSharp/Game/Controller/Controller.csproj
+2
-2
CSharp/Game/Controller/Factory/UnitFactory.cs
CSharp/Game/Controller/Factory/UnitFactory.cs
+3
-4
CSharp/Game/Controller/Message/CMsgLogin.cs
CSharp/Game/Controller/Message/CMsgLogin.cs
+0
-16
CSharp/Game/Controller/Message/CMsgLoginEvent.cs
CSharp/Game/Controller/Message/CMsgLoginEvent.cs
+29
-0
CSharp/Game/Controller/MessageType.cs
CSharp/Game/Controller/MessageType.cs
+7
-0
CSharp/Game/Model/Component/ActorComponent.cs
CSharp/Game/Model/Component/ActorComponent.cs
+16
-5
CSharp/Game/Model/Component/ChannelUnitInfoComponent.cs
CSharp/Game/Model/Component/ChannelUnitInfoComponent.cs
+15
-0
CSharp/Game/Model/Component/EventComponent.cs
CSharp/Game/Model/Component/EventComponent.cs
+30
-9
CSharp/Game/Model/Component/FactoryComponent.cs
CSharp/Game/Model/Component/FactoryComponent.cs
+1
-2
CSharp/Game/Model/Component/NetworkComponent.cs
CSharp/Game/Model/Component/NetworkComponent.cs
+6
-4
CSharp/Game/Model/Model.csproj
CSharp/Game/Model/Model.csproj
+3
-5
CSharp/Game/Model/UnitType.cs
CSharp/Game/Model/UnitType.cs
+2
-2
CSharp/Game/MongoDBTest/MongoDBTest.cs
CSharp/Game/MongoDBTest/MongoDBTest.cs
+1
-1
CSharp/Platform/Common/Common.csproj
CSharp/Platform/Common/Common.csproj
+2
-0
CSharp/Platform/Common/Network/AChannel.cs
CSharp/Platform/Common/Network/AChannel.cs
+1
-1
CSharp/Platform/Common/Network/IService.cs
CSharp/Platform/Common/Network/IService.cs
+4
-1
CSharp/Platform/Network/Network.csproj
CSharp/Platform/Network/Network.csproj
+0
-60
CSharp/Platform/Network/Properties/AssemblyInfo.cs
CSharp/Platform/Network/Properties/AssemblyInfo.cs
+0
-39
CSharp/Platform/TNet/TChannel.cs
CSharp/Platform/TNet/TChannel.cs
+1
-1
CSharp/Platform/TNet/TNet.csproj
CSharp/Platform/TNet/TNet.csproj
+0
-4
CSharp/Platform/TNet/TService.cs
CSharp/Platform/TNet/TService.cs
+14
-1
CSharp/Platform/TNetTest/TNetTest.csproj
CSharp/Platform/TNetTest/TNetTest.csproj
+0
-4
CSharp/Platform/TNetTest/TServiceTest.cs
CSharp/Platform/TNetTest/TServiceTest.cs
+1
-1
CSharp/Platform/UNet/NativeMethods.cs
CSharp/Platform/UNet/NativeMethods.cs
+1
-1
CSharp/Platform/UNet/UChannel.cs
CSharp/Platform/UNet/UChannel.cs
+1
-1
CSharp/Platform/UNet/UNet.csproj
CSharp/Platform/UNet/UNet.csproj
+11
-4
CSharp/Platform/UNet/UPacket.cs
CSharp/Platform/UNet/UPacket.cs
+1
-1
CSharp/Platform/UNet/UService.cs
CSharp/Platform/UNet/UService.cs
+14
-1
CSharp/Platform/UNet/USocket.cs
CSharp/Platform/UNet/USocket.cs
+1
-1
CSharp/Platform/UNet/packages.config
CSharp/Platform/UNet/packages.config
+4
-0
CSharp/Platform/UNetTest/UNetTest.csproj
CSharp/Platform/UNetTest/UNetTest.csproj
+0
-4
CSharp/Platform/UNetTest/UServiceTest.cs
CSharp/Platform/UNetTest/UServiceTest.cs
+1
-1
未找到文件。
CSharp/CSharp.sln
浏览文件 @
5bb66d41
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.3
0723
.0
VisualStudioVersion = 12.0.3
1101
.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{C4C64188-4FAE-4CC3-A9E6-D9D4AF7429B6}"
EndProject
...
...
@@ -48,8 +48,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ENet", "Platform\ENet\ENet.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UNetTest", "Platform\UNetTest\UNetTest.csproj", "{901A8E5C-C4C6-4C3C-8E18-068D75119F5D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Network", "Platform\Network\Network.csproj", "{3BD499FF-3C34-4920-8B21-C55FBA580843}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProfileExe", "Platform\ProfileExe\ProfileExe.csproj", "{CBA52DC8-1C80-4A79-9AC5-73514EBBD749}"
EndProject
Global
...
...
@@ -212,18 +210,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
{3BD499FF-3C34-4920-8B21-C55FBA580843}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3BD499FF-3C34-4920-8B21-C55FBA580843}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3BD499FF-3C34-4920-8B21-C55FBA580843}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{3BD499FF-3C34-4920-8B21-C55FBA580843}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{3BD499FF-3C34-4920-8B21-C55FBA580843}.Debug|Win32.ActiveCfg = Debug|Any CPU
{3BD499FF-3C34-4920-8B21-C55FBA580843}.Debug|x86.ActiveCfg = Debug|Any CPU
{3BD499FF-3C34-4920-8B21-C55FBA580843}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3BD499FF-3C34-4920-8B21-C55FBA580843}.Release|Any CPU.Build.0 = Release|Any CPU
{3BD499FF-3C34-4920-8B21-C55FBA580843}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{3BD499FF-3C34-4920-8B21-C55FBA580843}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{3BD499FF-3C34-4920-8B21-C55FBA580843}.Release|Win32.ActiveCfg = Release|Any CPU
{3BD499FF-3C34-4920-8B21-C55FBA580843}.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
...
...
@@ -254,7 +240,6 @@ Global
{D0B4CFAC-A368-4742-9863-68776CFA9938} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
{C9992B7C-313E-4C9F-A954-640D01EDFB58} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
{901A8E5C-C4C6-4C3C-8E18-068D75119F5D} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
{3BD499FF-3C34-4920-8B21-C55FBA580843} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
{CBA52DC8-1C80-4A79-9AC5-73514EBBD749} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
EndGlobalSection
EndGlobal
CSharp/Game/Controller/Action/MessageAction.cs
浏览文件 @
5bb66d41
using
Common.Event
;
using
System
;
using
System.Threading.Tasks
;
using
Common.Event
;
using
Common.Network
;
using
Model
;
using
MongoDB.Bson
;
namespace
Controller
{
[
Action
(
ActionType
.
MessageAction
)]
public
class
MessageAction
:
IEvent
S
ync
public
class
MessageAction
:
IEvent
As
ync
{
public
void
Run
(
Env
env
)
public
async
Task
RunAsync
(
Env
env
)
{
Unit
unit
=
World
.
Instance
.
GetComponent
<
UnitComponent
>().
Get
(
ObjectId
.
Empty
);
if
(
unit
==
null
)
AChannel
channel
=
env
.
Get
<
AChannel
>(
EnvKey
.
Channel
);
ChannelUnitInfoComponent
channelUnitInfoComponent
=
channel
.
GetComponent
<
ChannelUnitInfoComponent
>();
if
(
channelUnitInfoComponent
!=
null
)
{
Unit
unit
=
World
.
Instance
.
GetComponent
<
UnitComponent
>().
Get
(
channelUnitInfoComponent
.
PlayerId
);
if
(
unit
==
null
)
{
return
;
}
unit
.
GetComponent
<
ActorComponent
>().
Add
(
env
);
return
;
}
unit
.
GetComponent
<
ActorComponent
>().
Add
(
env
);
var
message
=
env
.
Get
<
byte
[
]>
(
EnvKey
.
Message
);
int
opcode
=
BitConverter
.
ToUInt16
(
message
,
0
);
await
World
.
Instance
.
GetComponent
<
EventComponent
<
MessageAttribute
>>().
RunAsync
(
opcode
,
env
);
}
}
}
\ No newline at end of file
CSharp/Game/Controller/Controller.csproj
浏览文件 @
5bb66d41
...
...
@@ -55,10 +55,10 @@
<Compile
Include=
"ConfigCategory\UnitCategory.cs"
/>
<Compile
Include=
"Action\BuffTimeoutAction.cs"
/>
<Compile
Include=
"Event\AfterAddBuff.cs"
/>
<Compile
Include=
"Message\CMsgLogin.cs"
/>
<Compile
Include=
"MessageType.cs"
/>
<Compile
Include=
"Message\CMsgLoginEvent.cs"
/>
<Compile
Include=
"NodeType.cs"
/>
<Compile
Include=
"Factory\UnitFactory.cs"
/>
<Compile
Include=
"UnitType.cs"
/>
</ItemGroup>
<ItemGroup>
<Folder
Include=
"Properties\"
/>
...
...
CSharp/Game/Controller/Factory/UnitFactory.cs
浏览文件 @
5bb66d41
...
...
@@ -2,15 +2,14 @@
namespace
Controller
{
[
Factory
(
typeof
(
Unit
),
UnitType
.
Player
)]
public
class
UnitPlayerFactory
:
IFactory
<
Unit
>
[
Factory
(
typeof
(
Unit
),
UnitType
.
Gate
Player
)]
public
class
Unit
Gate
PlayerFactory
:
IFactory
<
Unit
>
{
public
Unit
Create
(
int
configId
)
{
Unit
player
=
new
Unit
(
configId
);
player
.
AddComponent
<
BuffComponent
>();
Buff
buff
=
new
Buff
(
1
,
player
.
Id
);
player
.
GetComponent
<
BuffComponent
>().
Add
(
buff
);
player
.
AddComponent
<
ActorComponent
>().
Run
();
World
.
Instance
.
GetComponent
<
UnitComponent
>().
Add
(
player
);
return
player
;
}
...
...
CSharp/Game/Controller/Message/CMsgLogin.cs
已删除
100644 → 0
浏览文件 @
601cdbe7
using
System
;
using
System.Threading.Tasks
;
using
Common.Event
;
using
Model
;
namespace
Controller.Message
{
[
Message
(
1
)]
internal
class
CMsgLogin
:
IEventAsync
{
public
Task
RunAsync
(
Env
env
)
{
throw
new
NotImplementedException
();
}
}
}
CSharp/Game/Controller/Message/CMsgLoginEvent.cs
0 → 100644
浏览文件 @
5bb66d41
using
Common.Event
;
using
Common.Helper
;
using
Model
;
using
Common.Network
;
namespace
Controller.Message
{
public
class
CMsgLogin
{
public
byte
[]
Account
{
get
;
set
;
}
public
byte
[]
PassMd5
{
get
;
set
;
}
}
[
Message
(
MessageType
.
CMsgLogin
)]
internal
class
CMsgLoginEvent
:
IEventSync
{
public
void
Run
(
Env
env
)
{
var
messageBytes
=
env
.
Get
<
byte
[
]>
(
EnvKey
.
Message
);
CMsgLogin
cmsg
=
MongoHelper
.
FromBson
<
CMsgLogin
>(
messageBytes
,
2
);
Unit
unit
=
World
.
Instance
.
GetComponent
<
FactoryComponent
<
Unit
>>().
Create
(
UnitType
.
GatePlayer
,
1
);
AChannel
channel
=
env
.
Get
<
AChannel
>(
EnvKey
.
Channel
);
ChannelUnitInfoComponent
channelUnitInfoComponent
=
channel
.
AddComponent
<
ChannelUnitInfoComponent
>();
channelUnitInfoComponent
.
Account
=
cmsg
.
Account
;
channelUnitInfoComponent
.
PlayerId
=
unit
.
Id
;
}
}
}
CSharp/Game/Controller/MessageType.cs
0 → 100644
浏览文件 @
5bb66d41
namespace
Controller
{
public
static
class
MessageType
{
public
const
int
CMsgLogin
=
1
;
}
}
CSharp/Game/Model/Component/ActorComponent.cs
浏览文件 @
5bb66d41
...
...
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using
System.Threading.Tasks
;
using
Common.Base
;
using
Common.Event
;
using
Common.Logger
;
namespace
Model
{
...
...
@@ -10,16 +11,26 @@ namespace Model
{
private
readonly
Queue
<
Env
>
msgEnvQueue
=
new
Queue
<
Env
>();
public
Action
msgAction
=
()
=>
{};
public
Action
msgAction
=
()
=>
{};
public
Env
Env
{
get
;
private
set
;
}
public
async
void
Run
()
{
while
(
true
)
{
Env
env
=
await
this
.
Get
();
var
message
=
env
.
Get
<
byte
[
]>
(
EnvKey
.
Message
);
int
opcode
=
BitConverter
.
ToUInt16
(
message
,
0
);
await
World
.
Instance
.
GetComponent
<
EventComponent
<
MessageAttribute
>>().
Run
(
opcode
,
env
);
try
{
Env
env
=
await
this
.
Get
();
this
.
Env
=
env
;
var
message
=
env
.
Get
<
byte
[
]>
(
EnvKey
.
Message
);
int
opcode
=
BitConverter
.
ToUInt16
(
message
,
0
);
await
World
.
Instance
.
GetComponent
<
EventComponent
<
MessageAttribute
>>().
RunAsync
(
opcode
,
env
);
}
catch
(
Exception
e
)
{
Log
.
Trace
(
string
.
Format
(
e
.
ToString
()));
}
}
}
...
...
CSharp/Game/Model/Component/ChannelUnitInfoComponent.cs
0 → 100644
浏览文件 @
5bb66d41
using
Common.Base
;
using
Common.Network
;
using
MongoDB.Bson
;
namespace
Model
{
/// <summary>
/// channel中保存Unit一些信息,例如帐号
/// </summary>
public
class
ChannelUnitInfoComponent
:
Component
<
AChannel
>
{
public
byte
[]
Account
{
get
;
set
;
}
public
ObjectId
PlayerId
{
get
;
set
;
}
}
}
CSharp/Game/Model/Component/EventComponent.cs
浏览文件 @
5bb66d41
...
...
@@ -61,10 +61,37 @@ namespace Model
}
}
public
async
Task
Run
(
int
type
,
Env
env
)
public
void
Run
(
int
type
,
Env
env
)
{
List
<
IEventSync
>
iEventSyncs
=
null
;
if
(
this
.
eventSyncs
.
TryGetValue
(
type
,
out
iEventSyncs
))
if
(!
this
.
eventSyncs
.
TryGetValue
(
type
,
out
iEventSyncs
))
{
throw
new
Exception
(
string
.
Format
(
"no event handler, AttributeType: {0} type: {1}"
,
typeof
(
AttributeType
).
Name
,
type
));
}
foreach
(
IEventSync
iEventSync
in
iEventSyncs
)
{
iEventSync
.
Run
(
env
);
}
}
public
async
Task
RunAsync
(
int
type
,
Env
env
)
{
List
<
IEventSync
>
iEventSyncs
=
null
;
this
.
eventSyncs
.
TryGetValue
(
type
,
out
iEventSyncs
);
List
<
IEventAsync
>
iEventAsyncs
=
null
;
this
.
eventAsyncs
.
TryGetValue
(
type
,
out
iEventAsyncs
);
if
(
iEventSyncs
==
null
&&
iEventAsyncs
==
null
)
{
throw
new
Exception
(
string
.
Format
(
"no event handler, AttributeType: {0} type: {1}"
,
typeof
(
AttributeType
).
Name
,
type
));
}
if
(
iEventSyncs
!=
null
)
{
foreach
(
IEventSync
iEventSync
in
iEventSyncs
)
{
...
...
@@ -72,19 +99,13 @@ namespace Model
}
}
List
<
IEventAsync
>
iEventAsyncs
=
null
;
// ReSharper disable once InvertIf
if
(
this
.
eventAsyncs
.
TryGetValue
(
type
,
out
iEventAsyncs
))
if
(
iEventAsyncs
!=
null
)
{
foreach
(
IEventAsync
iEventAsync
in
iEventAsyncs
)
{
await
iEventAsync
.
RunAsync
(
env
);
}
}
throw
new
Exception
(
string
.
Format
(
"no event handler, AttributeType: {0} type: {1}"
,
typeof
(
AttributeType
).
Name
,
type
));
}
}
}
\ No newline at end of file
CSharp/Game/Model/Component/FactoryComponent.cs
浏览文件 @
5bb66d41
...
...
@@ -39,9 +39,8 @@ namespace Model
}
}
public
T
Create
(
int
configId
)
public
T
Create
(
int
type
,
int
configId
)
{
int
type
=
World
.
Instance
.
GetComponent
<
ConfigComponent
>().
Get
<
UnitConfig
>(
configId
).
Type
;
return
this
.
allConfig
[
type
].
Create
(
configId
);
}
}
...
...
CSharp/Game/Model/Component/
Service
Component.cs
→
CSharp/Game/Model/Component/
Network
Component.cs
浏览文件 @
5bb66d41
using
System
;
using
Common.Base
;
using
Common.Event
;
using
Network
;
using
Common.
Network
;
using
TNet
;
using
UNet
;
namespace
Model
{
public
class
Service
Component
:
Component
<
World
>
public
class
Network
Component
:
Component
<
World
>
{
private
IService
service
;
...
...
@@ -54,8 +54,10 @@ namespace Model
Env
env
=
new
Env
();
env
[
EnvKey
.
Channel
]
=
channel
;
env
[
EnvKey
.
Message
]
=
message
;
await
World
.
Instance
.
GetComponent
<
EventComponent
<
ActionAttribute
>>()
.
Run
(
ActionType
.
MessageAction
,
env
);
#pragma warning disable 4014
World
.
Instance
.
GetComponent
<
EventComponent
<
ActionAttribute
>>()
.
RunAsync
(
ActionType
.
MessageAction
,
env
);
#pragma warning restore 4014
}
}
}
...
...
CSharp/Game/Model/Model.csproj
浏览文件 @
5bb66d41
...
...
@@ -45,6 +45,7 @@
<Reference
Include=
"System.Core"
/>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"Component\ChannelUnitInfoComponent.cs"
/>
<Compile
Include=
"Component\ActorComponent.cs"
/>
<Compile
Include=
"Component\BehaviorTreeComponent.cs"
/>
<Compile
Include=
"BehaviorTree\BehaviorTree.cs"
/>
...
...
@@ -53,7 +54,7 @@
<Compile
Include=
"BehaviorTree\Node.cs"
/>
<Compile
Include=
"BehaviorTree\NodeAttribute.cs"
/>
<Compile
Include=
"Buff.cs"
/>
<Compile
Include=
"Component\
Service
Component.cs"
/>
<Compile
Include=
"Component\
Network
Component.cs"
/>
<Compile
Include=
"Component\BuffComponent.cs"
/>
<Compile
Include=
"Component\ConfigComponent.cs"
/>
<Compile
Include=
"Component\EventComponent.cs"
/>
...
...
@@ -72,6 +73,7 @@
<Compile
Include=
"Config\GlobalConfig.cs"
/>
<Compile
Include=
"Config\NodeConfig.cs"
/>
<Compile
Include=
"Unit.cs"
/>
<Compile
Include=
"UnitType.cs"
/>
<Compile
Include=
"World.cs"
/>
<Compile
Include=
"EventAttribute.cs"
/>
</ItemGroup>
...
...
@@ -83,10 +85,6 @@
<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>
...
...
CSharp/Game/
Controller
/UnitType.cs
→
CSharp/Game/
Model
/UnitType.cs
浏览文件 @
5bb66d41
namespace
Controller
namespace
Model
{
public
static
class
UnitType
{
public
const
int
Player
=
1
;
public
const
int
Gate
Player
=
1
;
public
const
int
Npc
=
2
;
public
const
int
Dog
=
3
;
}
...
...
CSharp/Game/MongoDBTest/MongoDBTest.cs
浏览文件 @
5bb66d41
...
...
@@ -31,7 +31,7 @@ namespace MongoDBTest
world
.
AddComponent
<
BehaviorTreeComponent
>();
world
.
Load
();
Unit
player1
=
world
.
GetComponent
<
FactoryComponent
<
Unit
>>().
Create
(
1
);
Unit
player1
=
world
.
GetComponent
<
FactoryComponent
<
Unit
>>().
Create
(
UnitType
.
GatePlayer
,
1
);
player1
[
"hp"
]
=
10
;
collection
.
Insert
(
player1
);
...
...
CSharp/Platform/Common/Common.csproj
浏览文件 @
5bb66d41
...
...
@@ -88,6 +88,8 @@
<Compile
Include=
"Helper\StringHelper.cs"
/>
<Compile
Include=
"Helper\TimeHelper.cs"
/>
<Compile
Include=
"Helper\XmlHelper.cs"
/>
<Compile
Include=
"Network\AChannel.cs"
/>
<Compile
Include=
"Network\IService.cs"
/>
</ItemGroup>
<ItemGroup>
<None
Include=
"Helper\Packages.config"
/>
...
...
CSharp/Platform/Network/AChannel.cs
→
CSharp/Platform/
Common/
Network/AChannel.cs
浏览文件 @
5bb66d41
...
...
@@ -2,7 +2,7 @@
using
System.Threading.Tasks
;
using
Common.Base
;
namespace
Network
namespace
Common.
Network
{
[
Flags
]
public
enum
PacketFlags
...
...
CSharp/Platform/Network/IService.cs
→
CSharp/Platform/
Common/
Network/IService.cs
浏览文件 @
5bb66d41
using
System
;
using
System.Threading.Tasks
;
using
MongoDB.Bson
;
namespace
Network
namespace
Common.
Network
{
public
enum
NetworkProtocol
{
...
...
@@ -17,6 +18,8 @@ namespace Network
/// <param name="action"></param>
void
Add
(
Action
action
);
AChannel
GetChannel
(
ObjectId
id
);
Task
<
AChannel
>
GetChannel
(
string
host
,
int
port
);
Task
<
AChannel
>
GetChannel
();
...
...
CSharp/Platform/Network/Network.csproj
已删除
100644 → 0
浏览文件 @
601cdbe7
<?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>
{3BD499FF-3C34-4920-8B21-C55FBA580843}
</ProjectGuid>
<OutputType>
Library
</OutputType>
<AppDesignerFolder>
Properties
</AppDesignerFolder>
<RootNamespace>
Network
</RootNamespace>
<AssemblyName>
Network
</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=
"IService.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"AChannel.cs"
/>
</ItemGroup>
<ItemGroup>
<ProjectReference
Include=
"..\Common\Common.csproj"
>
<Project>
{19f8f043-1f99-4550-99df-dea5c7d77e55}
</Project>
<Name>
Common
</Name>
</ProjectReference>
</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/Platform/Network/Properties/AssemblyInfo.cs
已删除
100644 → 0
浏览文件 @
601cdbe7
using
System.Reflection
;
using
System.Runtime.InteropServices
;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[
assembly
:
AssemblyTitle
(
"Network"
)]
[
assembly
:
AssemblyDescription
(
""
)]
[
assembly
:
AssemblyConfiguration
(
""
)]
[
assembly
:
AssemblyCompany
(
"Microsoft"
)]
[
assembly
:
AssemblyProduct
(
"Network"
)]
[
assembly
:
AssemblyCopyright
(
"Copyright © Microsoft 2014"
)]
[
assembly
:
AssemblyTrademark
(
""
)]
[
assembly
:
AssemblyCulture
(
""
)]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[
assembly
:
ComVisible
(
false
)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[
assembly
:
Guid
(
"16f6d5fb-6535-4e2b-afb5-e9a1b240c584"
)]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[
assembly
:
AssemblyVersion
(
"1.0.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.0.0.0"
)]
\ No newline at end of file
CSharp/Platform/TNet/TChannel.cs
浏览文件 @
5bb66d41
...
...
@@ -3,7 +3,7 @@ using System.Threading.Tasks;
using
Common.Helper
;
using
Common.Logger
;
using
MongoDB.Bson
;
using
Network
;
using
Common.
Network
;
namespace
TNet
{
...
...
CSharp/Platform/TNet/TNet.csproj
浏览文件 @
5bb66d41
...
...
@@ -64,10 +64,6 @@
<Project>
{19f8f043-1f99-4550-99df-dea5c7d77e55}
</Project>
<Name>
Common
</Name>
</ProjectReference>
<ProjectReference
Include=
"..\Network\Network.csproj"
>
<Project>
{3bd499ff-3c34-4920-8b21-c55fba580843}
</Project>
<Name>
Network
</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None
Include=
"packages.config"
/>
...
...
CSharp/Platform/TNet/TService.cs
浏览文件 @
5bb66d41
...
...
@@ -2,7 +2,8 @@
using
System.Collections.Generic
;
using
System.Threading.Tasks
;
using
Common.Base
;
using
Network
;
using
Common.Network
;
using
MongoDB.Bson
;
namespace
TNet
{
...
...
@@ -13,6 +14,8 @@ namespace TNet
private
readonly
Dictionary
<
string
,
TChannel
>
channels
=
new
Dictionary
<
string
,
TChannel
>();
private
readonly
Dictionary
<
ObjectId
,
TChannel
>
idChannels
=
new
Dictionary
<
ObjectId
,
TChannel
>();
private
readonly
TimerManager
timerManager
=
new
TimerManager
();
/// <summary>
...
...
@@ -65,12 +68,20 @@ namespace TNet
this
.
poller
.
Add
(
action
);
}
public
AChannel
GetChannel
(
ObjectId
id
)
{
TChannel
channel
=
null
;
this
.
idChannels
.
TryGetValue
(
id
,
out
channel
);
return
channel
;
}
private
async
Task
<
AChannel
>
ConnectAsync
(
string
host
,
int
port
)
{
TSocket
newSocket
=
new
TSocket
(
this
.
poller
);
await
newSocket
.
ConnectAsync
(
host
,
port
);
TChannel
channel
=
new
TChannel
(
newSocket
,
this
);
this
.
channels
[
newSocket
.
RemoteAddress
]
=
channel
;
this
.
idChannels
[
channel
.
Id
]
=
channel
;
return
channel
;
}
...
...
@@ -84,6 +95,7 @@ namespace TNet
await
this
.
acceptor
.
AcceptAsync
(
socket
);
TChannel
channel
=
new
TChannel
(
socket
,
this
);
this
.
channels
[
channel
.
RemoteAddress
]
=
channel
;
this
.
idChannels
[
channel
.
Id
]
=
channel
;
return
channel
;
}
...
...
@@ -94,6 +106,7 @@ namespace TNet
{
return
;
}
this
.
idChannels
.
Remove
(
channel
.
Id
);
this
.
channels
.
Remove
(
channel
.
RemoteAddress
);
this
.
timerManager
.
Remove
(
tChannel
.
SendTimer
);
}
...
...
CSharp/Platform/TNetTest/TNetTest.csproj
浏览文件 @
5bb66d41
...
...
@@ -59,10 +59,6 @@
<Project>
{19f8f043-1f99-4550-99df-dea5c7d77e55}
</Project>
<Name>
Common
</Name>
</ProjectReference>
<ProjectReference
Include=
"..\Network\Network.csproj"
>
<Project>
{3bd499ff-3c34-4920-8b21-c55fba580843}
</Project>
<Name>
Network
</Name>
</ProjectReference>
<ProjectReference
Include=
"..\TNet\TNet.csproj"
>
<Project>
{b42d431a-3a54-4649-942a-c5356d7f9fbc}
</Project>
<Name>
TNet
</Name>
...
...
CSharp/Platform/TNetTest/TServiceTest.cs
浏览文件 @
5bb66d41
...
...
@@ -3,7 +3,7 @@ using System.Threading;
using
System.Threading.Tasks
;
using
Common.Helper
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
Network
;
using
Common.
Network
;
using
TNet
;
namespace
TNetTest
...
...
CSharp/Platform/UNet/NativeMethods.cs
浏览文件 @
5bb66d41
using
System
;
using
System.Runtime.InteropServices
;
using
System.Text
;
using
Network
;
using
Common.
Network
;
namespace
UNet
{
...
...
CSharp/Platform/UNet/UChannel.cs
浏览文件 @
5bb66d41
using
System
;
using
System.Threading.Tasks
;
using
Network
;
using
Common.
Network
;
namespace
UNet
{
...
...
CSharp/Platform/UNet/UNet.csproj
浏览文件 @
5bb66d41
...
...
@@ -34,6 +34,14 @@
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"MongoDB.Bson, Version=1.10.0.52, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL"
>
<SpecificVersion>
False
</SpecificVersion>
<HintPath>
..\..\packages\mongocsharpdriver.1.10.0-rc1\lib\net35\MongoDB.Bson.dll
</HintPath>
</Reference>
<Reference
Include=
"MongoDB.Driver, Version=1.10.0.52, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL"
>
<SpecificVersion>
False
</SpecificVersion>
<HintPath>
..\..\packages\mongocsharpdriver.1.10.0-rc1\lib\net35\MongoDB.Driver.dll
</HintPath>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Core"
/>
</ItemGroup>
...
...
@@ -58,10 +66,9 @@
<Project>
{19F8F043-1F99-4550-99DF-DEA5C7D77E55}
</Project>
<Name>
Common
</Name>
</ProjectReference>
<ProjectReference
Include=
"..\Network\Network.csproj"
>
<Project>
{3bd499ff-3c34-4920-8b21-c55fba580843}
</Project>
<Name>
Network
</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None
Include=
"packages.config"
/>
</ItemGroup>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
<Import
Project=
"$(SolutionDir)\.nuget\nuget.targets"
/>
...
...
CSharp/Platform/UNet/UPacket.cs
浏览文件 @
5bb66d41
using
System
;
using
System.Runtime.InteropServices
;
using
Network
;
using
Common.
Network
;
namespace
UNet
{
...
...
CSharp/Platform/UNet/UService.cs
浏览文件 @
5bb66d41
using
System
;
using
System.Collections.Generic
;
using
System.Threading.Tasks
;
using
Network
;
using
Common.Network
;
using
MongoDB.Bson
;
namespace
UNet
{
...
...
@@ -11,6 +12,8 @@ namespace UNet
private
readonly
Dictionary
<
string
,
UChannel
>
channels
=
new
Dictionary
<
string
,
UChannel
>();
private
readonly
Dictionary
<
ObjectId
,
UChannel
>
idChannels
=
new
Dictionary
<
ObjectId
,
UChannel
>();
/// <summary>
/// 即可做client也可做server
/// </summary>
...
...
@@ -64,6 +67,7 @@ namespace UNet
USocket
newSocket
=
await
this
.
poller
.
ConnectAsync
(
host
,
(
ushort
)
port
);
UChannel
channel
=
new
UChannel
(
newSocket
,
this
);
this
.
channels
[
channel
.
RemoteAddress
]
=
channel
;
this
.
idChannels
[
channel
.
Id
]
=
channel
;
return
channel
;
}
...
...
@@ -82,6 +86,14 @@ namespace UNet
USocket
socket
=
await
this
.
poller
.
AcceptAsync
();
UChannel
channel
=
new
UChannel
(
socket
,
this
);
this
.
channels
[
channel
.
RemoteAddress
]
=
channel
;
this
.
idChannels
[
channel
.
Id
]
=
channel
;
return
channel
;
}
public
AChannel
GetChannel
(
ObjectId
id
)
{
UChannel
channel
=
null
;
this
.
idChannels
.
TryGetValue
(
id
,
out
channel
);
return
channel
;
}
...
...
@@ -92,6 +104,7 @@ namespace UNet
{
return
;
}
this
.
idChannels
.
Remove
(
channel
.
Id
);
this
.
channels
.
Remove
(
channel
.
RemoteAddress
);
}
...
...
CSharp/Platform/UNet/USocket.cs
浏览文件 @
5bb66d41
...
...
@@ -2,7 +2,7 @@
using
System.Collections.Generic
;
using
System.Runtime.InteropServices
;
using
System.Threading.Tasks
;
using
Network
;
using
Common.
Network
;
namespace
UNet
{
...
...
CSharp/Platform/UNet/packages.config
0 → 100644
浏览文件 @
5bb66d41
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"mongocsharpdriver"
version
=
"1.10.0-rc1"
targetFramework
=
"net451"
/>
</
packages
>
\ No newline at end of file
CSharp/Platform/UNetTest/UNetTest.csproj
浏览文件 @
5bb66d41
...
...
@@ -61,10 +61,6 @@
<Project>
{19f8f043-1f99-4550-99df-dea5c7d77e55}
</Project>
<Name>
Common
</Name>
</ProjectReference>
<ProjectReference
Include=
"..\Network\Network.csproj"
>
<Project>
{3bd499ff-3c34-4920-8b21-c55fba580843}
</Project>
<Name>
Network
</Name>
</ProjectReference>
<ProjectReference
Include=
"..\TNet\TNet.csproj"
>
<Project>
{b42d431a-3a54-4649-942a-c5356d7f9fbc}
</Project>
<Name>
TNet
</Name>
...
...
CSharp/Platform/UNetTest/UServiceTest.cs
浏览文件 @
5bb66d41
...
...
@@ -3,7 +3,7 @@ using System.Threading;
using
System.Threading.Tasks
;
using
Common.Helper
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
Network
;
using
Common.
Network
;
using
UNet
;
namespace
UNetTest
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录