mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-04-22 03:59:35 +08:00
添加接口
This commit is contained in:
parent
2618b8b41e
commit
0e9b873b7a
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<BaseOutputPath>..\bin</BaseOutputPath>
|
||||
@ -13,4 +13,12 @@
|
||||
<Title>FunGame</Title>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DebugType>embedded</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DebugType>embedded</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -13,7 +13,7 @@ namespace FunGame.Core.Api.Interface
|
||||
|
||||
namespace FunGame.Core.Implement
|
||||
{
|
||||
public class ServerInterfaceImpl : ServerInterface
|
||||
public class ClientConnectInterfaceImpl : ClientConnectInterface
|
||||
{
|
||||
public string RemoteServerIP()
|
||||
{
|
||||
@ -26,8 +26,13 @@ namespace FunGame.Core.Api.Interface
|
||||
}
|
||||
*/
|
||||
|
||||
public interface ServerInterface
|
||||
public interface ClientConnectInterface
|
||||
{
|
||||
public string RemoteServerIP();
|
||||
}
|
||||
|
||||
public interface ServerInterface
|
||||
{
|
||||
public string ServerNotice();
|
||||
}
|
||||
}
|
@ -59,7 +59,8 @@ namespace FunGame.Core.Api.Model.Enum
|
||||
|
||||
public enum InterfaceType
|
||||
{
|
||||
ServerInterface = 1
|
||||
ClientConnectInterface = 1,
|
||||
ServerInterface = 2
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -88,7 +89,8 @@ namespace FunGame.Core.Api.Model.Enum
|
||||
|
||||
public enum InterfaceMethod
|
||||
{
|
||||
GetServerIP = 1
|
||||
RemoteServerIP = 1,
|
||||
ServerNotice = 2
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -19,12 +19,14 @@ namespace FunGame.Core.Api.Util
|
||||
/**
|
||||
* 定义类名
|
||||
*/
|
||||
public const string ClientConnectInterface = "ClientConnectInterface";
|
||||
public const string ServerInterface = "ServerInterface";
|
||||
|
||||
/**
|
||||
* 定义方法名
|
||||
*/
|
||||
public const string GetRemoteServerIP = "RemoteServerIP";
|
||||
public const string RemoteServerIP = "RemoteServerIP";
|
||||
public const string ServerNotice = "ServerNotice";
|
||||
|
||||
/**
|
||||
* 定义需要反射的DLL
|
||||
@ -35,7 +37,8 @@ namespace FunGame.Core.Api.Util
|
||||
* 无需二次修改的
|
||||
*/
|
||||
public const string Implement = "Impl"; // 实现类的后缀
|
||||
public static string PluginDocPath = System.Diagnostics.Process.GetCurrentProcess() + "/plugins/"; // 插件目录,反射插件DLL需要用LoadFile()方法
|
||||
public static string EXEDocPath = System.Environment.CurrentDirectory.ToString() + "\\"; // 程序目录
|
||||
public static string PluginDocPath = System.Environment.CurrentDirectory + "\\plugins\\"; // 插件目录
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
/////////////// * 下 面 是 工 具 类 实 现 * ////////////////
|
||||
@ -59,7 +62,7 @@ namespace FunGame.Core.Api.Util
|
||||
// 通过类名获取获取命名空间+类名称
|
||||
string ClassName = Interface switch
|
||||
{
|
||||
(int)CommonEnums.InterfaceType.ServerInterface => ServerInterface + Implement,
|
||||
(int)CommonEnums.InterfaceType.ClientConnectInterface => ClientConnectInterface + Implement,
|
||||
_ => "",
|
||||
};
|
||||
List<Type>? Classes = null;
|
||||
@ -84,8 +87,8 @@ namespace FunGame.Core.Api.Util
|
||||
// 通过AssemblyHelperType来获取方法名
|
||||
switch (Method)
|
||||
{
|
||||
case (int)CommonEnums.InterfaceMethod.GetServerIP:
|
||||
return GetRemoteServerIP;
|
||||
case (int)CommonEnums.InterfaceMethod.RemoteServerIP:
|
||||
return RemoteServerIP;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@ -98,7 +101,7 @@ namespace FunGame.Core.Api.Util
|
||||
/// <returns></returns>
|
||||
public object? GetFunGameCoreValue(int Interface, int Method)
|
||||
{
|
||||
Assembly = Assembly.Load(@FUNGAME_CORE);
|
||||
Assembly = Assembly.LoadFile(EXEDocPath + @FUNGAME_CORE + ".dll");
|
||||
Type = GetFunGameCoreImplement(Interface); // 通过类名获取获取命名空间+类名称
|
||||
string MethodName = GetMethodName(Method); // 获取方法名
|
||||
if (Assembly != null && Type != null) this.Method = Type.GetMethod(MethodName); // 从Type中查找方法名
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Company>Milimoe</Company>
|
||||
@ -13,12 +13,19 @@
|
||||
<FileVersion>1.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Implement\" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DebugType>embedded</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DebugType>embedded</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FunGame.Core.Api\FunGame.Core.Api.csproj" />
|
||||
<ProjectReference Include="..\FunGame.Core.Api\FunGame.Core.Api.csproj">
|
||||
<Private>False</Private>
|
||||
<CopyLocalSatelliteAssemblies>True</CopyLocalSatelliteAssemblies>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<PackageIcon>logo.ico</PackageIcon>
|
||||
<Company>Milimoe</Company>
|
||||
<BaseOutputPath>..\bin</BaseOutputPath>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<GenerateDocumentationFile>False</GenerateDocumentationFile>
|
||||
<SignAssembly>False</SignAssembly>
|
||||
<Authors>Milimoe</Authors>
|
||||
<Product>FunGame</Product>
|
||||
@ -21,6 +21,14 @@
|
||||
<FileVersion>1.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DebugType>embedded</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DebugType>embedded</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Images\logo.ico" />
|
||||
</ItemGroup>
|
||||
@ -50,8 +58,12 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FunGame.Core.Api\FunGame.Core.Api.csproj" />
|
||||
<ProjectReference Include="..\FunGame.Core\FunGame.Core.csproj" />
|
||||
<ProjectReference Include="..\FunGame.Core.Api\FunGame.Core.Api.csproj">
|
||||
<CopyLocalSatelliteAssemblies>True</CopyLocalSatelliteAssemblies>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\FunGame.Core\FunGame.Core.csproj">
|
||||
<CopyLocalSatelliteAssemblies>True</CopyLocalSatelliteAssemblies>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -7,7 +7,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using FunGame.Desktop.Models.Enum;
|
||||
using FunGame.Core.Api.Model.Enum;
|
||||
|
||||
namespace FunGame.Desktop.Models.Component
|
||||
{
|
||||
|
@ -1,97 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FunGame.Desktop.Models.Enum
|
||||
{
|
||||
/// <summary>
|
||||
/// 这里存放框架实现相关的State Type Result Method
|
||||
/// 添加FunGame.Core接口和实现时,需要在这里同步添加:InterfaceType和InterfaceMethod
|
||||
/// </summary>
|
||||
public static class CommonEnums
|
||||
{
|
||||
#region State
|
||||
|
||||
public enum StartMatch_State
|
||||
{
|
||||
Matching = 1,
|
||||
Success = 2,
|
||||
Enable = 3,
|
||||
Cancel = 4
|
||||
}
|
||||
|
||||
public enum CreateRoom_State
|
||||
{
|
||||
Creating = 1,
|
||||
Success = 2
|
||||
}
|
||||
|
||||
public enum RoomState
|
||||
{
|
||||
Created = 1,
|
||||
Gaming = 2,
|
||||
Close = 3,
|
||||
Complete = 4
|
||||
}
|
||||
|
||||
public enum OnlineState
|
||||
{
|
||||
Offline = 1,
|
||||
Online = 2,
|
||||
Matching = 3,
|
||||
InRoom = 4,
|
||||
Gaming = 5
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Type
|
||||
|
||||
public enum RoomType
|
||||
{
|
||||
Mix = 1,
|
||||
Team = 2,
|
||||
MixHasPass = 3,
|
||||
TeamHasPass = 4
|
||||
}
|
||||
|
||||
public enum InterfaceType
|
||||
{
|
||||
ServerInterface = 1
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Result
|
||||
|
||||
public enum MessageResult
|
||||
{
|
||||
OK = 1,
|
||||
Cancel = 2,
|
||||
Yes = 3,
|
||||
No = 4,
|
||||
Retry = 5
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method
|
||||
|
||||
public enum WebHelperMethod
|
||||
{
|
||||
CreateSocket = 1,
|
||||
CloseSocket = 2,
|
||||
StartWebHelper = 3,
|
||||
}
|
||||
|
||||
public enum InterfaceMethod
|
||||
{
|
||||
GetServerIP = 1
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FunGame.Desktop.Models.Enum
|
||||
{
|
||||
public static class SocketEnums
|
||||
{
|
||||
public enum Type
|
||||
{
|
||||
GetNotice = 1,
|
||||
Login = 2,
|
||||
CheckLogin = 3,
|
||||
Logout = 4,
|
||||
HeartBeat = 5
|
||||
}
|
||||
|
||||
public const string TYPE_UNKNOWN = "Unknown Type";
|
||||
public const string TYPE_GetNotice = "GetNotice";
|
||||
public const string TYPE_Login = "Login";
|
||||
public const string TYPE_CheckLogin = "CheckLogin";
|
||||
public const string TYPE_Logout = "Logout";
|
||||
public const string TYPE_HeartBeat = "HeartBeat";
|
||||
}
|
||||
}
|
@ -3,13 +3,12 @@ using System.Diagnostics;
|
||||
using System.Net.Sockets;
|
||||
using System.Net;
|
||||
using System.Windows.Forms;
|
||||
using static FunGame.Desktop.Models.Enum.CommonEnums;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using FunGame.Core.Api.Model.Entity;
|
||||
using FunGame.Desktop.Models.Enum;
|
||||
using FunGame.Desktop.Models.Config;
|
||||
using FunGame.Desktop.Utils;
|
||||
using static FunGame.Core.Api.Model.Enum.CommonEnums;
|
||||
|
||||
namespace FunGame.Desktop.UI
|
||||
{
|
||||
@ -173,7 +172,7 @@ namespace FunGame.Desktop.UI
|
||||
{
|
||||
try
|
||||
{
|
||||
string? ipaddress = (string?)Config.DefaultAssemblyHelper.GetFunGameCoreValue((int)InterfaceType.ServerInterface, (int)InterfaceMethod.GetServerIP); // 获取服务器IP
|
||||
string? ipaddress = (string?)Config.DefaultAssemblyHelper.GetFunGameCoreValue((int)InterfaceType.ClientConnectInterface, (int)InterfaceMethod.RemoteServerIP); // 获取服务器IP
|
||||
if (ipaddress != null)
|
||||
{
|
||||
string[] s = ipaddress.Split(':');
|
||||
@ -685,6 +684,7 @@ namespace FunGame.Desktop.UI
|
||||
/// 设置服务器连接状态指示灯
|
||||
/// </summary>
|
||||
/// <param name="green"></param>
|
||||
/// <param name="ping"></param>
|
||||
private void SetServerStatusLight(bool green, int ping = 0)
|
||||
{
|
||||
if (green)
|
||||
|
@ -9,7 +9,7 @@ using FunGame.Desktop.Models.Component;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Net.NetworkInformation;
|
||||
using FunGame.Core.Api.Model.Entity;
|
||||
using FunGame.Desktop.Models.Enum;
|
||||
using FunGame.Core.Api.Model.Enum;
|
||||
using FunGame.Desktop.Models.Config;
|
||||
using FunGame.Desktop.UI;
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<BaseOutputPath>..\bin</BaseOutputPath>
|
||||
<BaseOutputPath>..\bin\</BaseOutputPath>
|
||||
<Authors>Milimoe</Authors>
|
||||
<Company>Milimoe</Company>
|
||||
<Title>FunGame</Title>
|
||||
@ -13,4 +13,12 @@
|
||||
<PackageOutputPath>..\bin\plugin</PackageOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DebugType>embedded</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DebugType>embedded</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
Loading…
x
Reference in New Issue
Block a user