水岸东方
This commit is contained in:
16
Entity/Model/DB/UserInfo.cs
Normal file
16
Entity/Model/DB/UserInfo.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace Fantasy;
|
||||
|
||||
public class UserInfo : Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// 昵称
|
||||
/// </summary>
|
||||
public string NickName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 余额
|
||||
/// </summary>
|
||||
public long Money { get; set; }
|
||||
}
|
||||
11
Entity/Model/Game/Player.cs
Normal file
11
Entity/Model/Game/Player.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace Fantasy;
|
||||
|
||||
/// <summary>
|
||||
/// 玩家信息
|
||||
/// </summary>
|
||||
public class Player : Entity
|
||||
{
|
||||
|
||||
}
|
||||
11
Entity/Model/User.cs
Normal file
11
Entity/Model/User.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace Fantasy.Model;
|
||||
|
||||
public sealed class User : Entity
|
||||
{
|
||||
public string NickName { get; set; }
|
||||
public string Head { get; set; }
|
||||
public string Country { get; set; }
|
||||
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public class UsersController : ControllerBase
|
||||
}
|
||||
|
||||
[HttpPost("register")]
|
||||
public IActionResult RegisterUser([FromBody] User user)
|
||||
public IActionResult RegisterUser([FromBody] HttpUser user)
|
||||
{
|
||||
return Ok("User registered successfully");
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public class UsersController : ControllerBase
|
||||
}
|
||||
}
|
||||
|
||||
public class User
|
||||
public class HttpUser
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Benchmark\" />
|
||||
<Folder Include="Outer\NormalMessage\" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -7,9 +7,11 @@ using Fantasy.Platform.Net;
|
||||
|
||||
namespace Fantasy;
|
||||
|
||||
public sealed class C2G_CreateAddressableRequestHandler : MessageRPC<C2G_CreateAddressableRequest, G2C_CreateAddressableResponse>
|
||||
public sealed class
|
||||
C2G_CreateAddressableRequestHandler : MessageRPC<C2G_CreateAddressableRequest, G2C_CreateAddressableResponse>
|
||||
{
|
||||
protected override async FTask Run(Session session, C2G_CreateAddressableRequest request, G2C_CreateAddressableResponse response, Action reply)
|
||||
protected override async FTask Run(Session session, C2G_CreateAddressableRequest request,
|
||||
G2C_CreateAddressableResponse response, Action reply)
|
||||
{
|
||||
var scene = session.Scene;
|
||||
// 1、首先要通过SceneConfig配置文件拿到进行注册Addressable协议的服务器
|
||||
@@ -18,9 +20,11 @@ public sealed class C2G_CreateAddressableRequestHandler : MessageRPC<C2G_CreateA
|
||||
// 我这里仅是演示功能,不是一定要这样拿Map
|
||||
var sceneConfig = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Map)[0];
|
||||
// 2、使用Scene.NetworkMessagingComponent.CallInnerRoute方法跟Gate服务器进行通讯。
|
||||
// CallInnerRoute方法跟Gate服务器进行通讯需要提供一个runTimeId,这个Id在sceneConfig.RouteId可以获取到。
|
||||
// b,这个Id在sceneConfig.RouteId可以获取到。
|
||||
// 第二个参数是需要发送网络协议,这个协议在Fantasy/Examples/Config/ProtoBuf里的InnerBson或Inner文件定义。
|
||||
var responseAddressableId = (M2G_ResponseAddressableId)await scene.NetworkMessagingComponent.CallInnerRoute(sceneConfig.RouteId, new G2M_RequestAddressableId());
|
||||
var responseAddressableId =
|
||||
(M2G_ResponseAddressableId)await scene.NetworkMessagingComponent.CallInnerRoute(sceneConfig.RouteId,
|
||||
new G2M_RequestAddressableId());
|
||||
// 3、给session添加一个AddressableRouteComponent组件,这个组件很重要、能否转发Addressable协议主要是通过这个。
|
||||
var addressableRouteComponent = session.AddComponent<AddressableRouteComponent>();
|
||||
// 4、拿到MapScene返回的AddressableId赋值给addressableRouteComponent.AddressableId。
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Assembly;
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.DataBase;
|
||||
using Fantasy.Helper;
|
||||
using Fantasy.IdFactory;
|
||||
using Fantasy.Platform.Net;
|
||||
|
||||
//Scene 255
|
||||
//gate 20个以内
|
||||
//游戏服 1个
|
||||
//Addressable管理中心 一个
|
||||
//游戏服 50个内
|
||||
//聊天服 1个1
|
||||
|
||||
|
||||
// 设置配置表的路径
|
||||
ConfigTableHelper.Initialize("../../../Config/Binary");
|
||||
// 设置ID生成规则
|
||||
@@ -21,14 +28,10 @@ MachineConfigData.Initialize(machineConfigText);
|
||||
ProcessConfigData.Initialize(processConfigText);
|
||||
WorldConfigData.Initialize(worldConfigText);
|
||||
SceneConfigData.Initialize(sceneConfigText);
|
||||
|
||||
// 注册日志模块到框架
|
||||
// 开发者可以自己注册日志系统到框架,只要实现Fantasy.ILog接口就可以。
|
||||
// 这里用的是NLog日志系统注册到框架中。
|
||||
Fantasy.Log.Register(new Fantasy.NLog("Server"));
|
||||
// 初始化框架,添加程序集到框架中
|
||||
await Fantasy.Platform.Net.Entry.Initialize(Fantasy.AssemblyHelper.Assemblies);
|
||||
// 启动Fantasy.Net
|
||||
await Fantasy.Platform.Net.Entry.Start();
|
||||
// 也可以使用下面的Start方法来初始化并且启动Fantasy.Net
|
||||
// 使用下面这个方法就不用使用上面的两个方法了。
|
||||
// await Fantasy.Platform.Net.Entry.Start(Fantasy.AssemblyHelper.Assemblies);
|
||||
Log.Register(new Fantasy.NLog("Server"));
|
||||
|
||||
await Entry.Start(AssemblyHelper.Assemblies);
|
||||
|
||||
Reference in New Issue
Block a user