提交 83bd33bc 编写于 作者: T tanghai

增加ServerType枚举,简化了代码

上级 58c9772c
......@@ -21,7 +21,7 @@ namespace Controller
continue;
}
InnerConfig innerConfig = startConfig.Config.GetComponent<InnerConfig>();
Entity serverSession = netInnerComponent.Get($"{innerConfig.Host}:{innerConfig.Port}");
Entity serverSession = netInnerComponent.Get(innerConfig.Address);
await serverSession.GetComponent<MessageComponent>().Call<M2A_Reload, A2M_Reload>(new M2A_Reload());
}
}
......
......@@ -20,7 +20,7 @@ namespace Controller
a2MReload.Error = ErrorCode.ERR_ReloadFail;
StartConfig myStartConfig = Game.Scene.GetComponent<StartConfigComponent>().MyConfig;
InnerConfig innerConfig = myStartConfig.Config.GetComponent<InnerConfig>();
a2MReload.Message = $"{innerConfig.Host}:{innerConfig.Port} reload fail, {e}";
a2MReload.Message = $"{innerConfig.Address} reload fail, {e}";
}
reply(a2MReload);
}
......
......@@ -86,6 +86,9 @@
<Compile Include="..\..\Unity\Assets\Scripts\Other\Options.cs">
<Link>Other\Options.cs</Link>
</Compile>
<Compile Include="..\..\Unity\Assets\Scripts\Other\ServerType.cs">
<Link>Other\ServerType.cs</Link>
</Compile>
<Compile Include="..\..\Unity\Assets\Scripts\Other\StartConfig.cs">
<Link>Other\StartConfig.cs</Link>
</Compile>
......
......@@ -5,5 +5,5 @@ cd Bin/Debug/
cmake ../..
make
pkill App.exe
ps -ef | grep App.exe | awk '{print $2}' | xargs kill -9
mono --debug App.exe --id=1 --appType=Manager
\ No newline at end of file
#!/bin/bash
cd Bin/Debug/
pkill App.exe
ps -ef | grep App.exe | awk '{print $2}' | xargs kill -9
mono --debug App.exe --id=1 --appType=Manager
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Base;
using Model;
using UnityEditor;
......@@ -14,8 +13,8 @@ namespace MyEditor
private bool isAll;
private string[] appTypes = { "Manager", "Realm", "Gate" };
private bool[] isCheck = { false, false, false };
private readonly string[] serverTypes = Enum.GetNames(typeof(ServerType));
private bool[] isCheck;
[MenuItem("Tools/服务器管理")]
private static void ShowWindow()
......@@ -25,6 +24,7 @@ namespace MyEditor
private void OnEnable()
{
this.isCheck = new bool[this.serverTypes.Length];
}
private void OnGUI()
......@@ -35,6 +35,7 @@ namespace MyEditor
return;
}
List<string> selected = new List<string>();
this.isAll = GUILayout.Toggle(this.isAll, "All");
if (this.isAll)
......@@ -45,9 +46,9 @@ namespace MyEditor
}
}
for (int i = 0; i < this.appTypes.Length; ++i)
for (int i = 0; i < this.serverTypes.Length; ++i)
{
this.isCheck[i] = GUILayout.Toggle(this.isCheck[i], this.appTypes[i]);
this.isCheck[i] = GUILayout.Toggle(this.isCheck[i], this.serverTypes[i]);
if (!this.isCheck[i])
{
this.isAll = false;
......@@ -62,7 +63,7 @@ namespace MyEditor
{
if (this.isCheck[i])
{
selected.Add(this.appTypes[i]);
selected.Add(this.serverTypes[i]);
}
}
NetworkComponent networkComponent = Game.Scene.GetComponent<NetOuterComponent>();
......
......@@ -43,6 +43,15 @@ namespace Model
{
public string Host { get; set; }
public int Port { get; set; }
[BsonIgnore]
public string Address
{
get
{
return $"{this.Host}:{this.Port}";
}
}
}
[BsonIgnoreExtraElements]
......@@ -50,5 +59,14 @@ namespace Model
{
public string Host { get; set; }
public int Port { get; set; }
[BsonIgnore]
public string Address
{
get
{
return $"{this.Host}:{this.Port}";
}
}
}
}
\ No newline at end of file
namespace Model
{
public enum ServerType
{
Manager,
Realm,
Gate,
}
}
fileFormatVersion: 2
guid: fc81138bdc09d7143ba9a3510635f70a
timeCreated: 1477322119
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -107,6 +107,7 @@
<Compile Include="Assets\Scripts\Message\OpcodeHelper.cs" />
<Compile Include="Assets\Scripts\Other\BsonClassMapRegister.cs" />
<Compile Include="Assets\Scripts\Other\ClientConfig.cs" />
<Compile Include="Assets\Scripts\Other\ServerType.cs" />
<Compile Include="Assets\Scripts\Other\StartConfig.cs" />
<Compile Include="Assets\Scripts\Other\EntityType.cs" />
<Compile Include="Assets\Scripts\Other\GameException.cs" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册