mirror of
https://github.com/project-redbud/FunGame-Desktop.git
synced 2025-04-21 12:39:34 +08:00
完善StartGame和EndGame (#24)
* 更换ShowMessageType引用 * 更新SocketHandler_System * ShowMessage时需要也显示在公屏上 * 完善开始游戏 * 添加EndGame
This commit is contained in:
parent
d3ac188fa0
commit
0cb1481d33
@ -6,7 +6,6 @@ using Milimoe.FunGame.Core.Library.Constant;
|
|||||||
using Milimoe.FunGame.Core.Library.Exception;
|
using Milimoe.FunGame.Core.Library.Exception;
|
||||||
using Milimoe.FunGame.Core.Library.SQLScript.Common;
|
using Milimoe.FunGame.Core.Library.SQLScript.Common;
|
||||||
using Milimoe.FunGame.Core.Library.SQLScript.Entity;
|
using Milimoe.FunGame.Core.Library.SQLScript.Entity;
|
||||||
using Milimoe.FunGame.Desktop.Library;
|
|
||||||
using Milimoe.FunGame.Desktop.Library.Component;
|
using Milimoe.FunGame.Desktop.Library.Component;
|
||||||
using Milimoe.FunGame.Desktop.Model;
|
using Milimoe.FunGame.Desktop.Model;
|
||||||
using Milimoe.FunGame.Desktop.UI;
|
using Milimoe.FunGame.Desktop.UI;
|
||||||
|
@ -304,7 +304,7 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
await StartGameRequest.SendRequestAsync();
|
await StartGameRequest.SendRequestAsync();
|
||||||
if (StartGameRequest.Result == RequestResult.Success)
|
if (StartGameRequest.Result == RequestResult.Success)
|
||||||
{
|
{
|
||||||
return true;
|
return StartGameRequest.GetResult<bool>("result");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -150,14 +150,16 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
protected override void SocketHandler_System(SocketObject ServerMessage)
|
protected override void SocketHandler_System(SocketObject ServerMessage)
|
||||||
{
|
{
|
||||||
// 收到系统消息,可输出消息或弹窗
|
// 收到系统消息,可输出消息或弹窗
|
||||||
string msg = "";
|
|
||||||
ShowMessageType type = ShowMessageType.None;
|
ShowMessageType type = ShowMessageType.None;
|
||||||
|
string msg = "";
|
||||||
|
string title = "系统消息";
|
||||||
int autoclose = 60;
|
int autoclose = 60;
|
||||||
if (ServerMessage.Parameters.Length > 0) msg = ServerMessage.GetParam<string>(0) ?? "";
|
if (ServerMessage.Parameters.Length > 0) type = ServerMessage.GetParam<ShowMessageType>(0);
|
||||||
if (ServerMessage.Parameters.Length > 1) type = ServerMessage.GetParam<ShowMessageType>(1);
|
if (ServerMessage.Parameters.Length > 1) msg = ServerMessage.GetParam<string>(1) ?? "";
|
||||||
if (ServerMessage.Parameters.Length > 2) autoclose = ServerMessage.GetParam<int>(2);
|
if (ServerMessage.Parameters.Length > 2) title = ServerMessage.GetParam<string>(2) ?? title;
|
||||||
if (type == ShowMessageType.None) Main.GetMessage(msg);
|
if (ServerMessage.Parameters.Length > 3) autoclose = ServerMessage.GetParam<int>(3);
|
||||||
else Main.ShowMessage(type, msg, "系统消息", autoclose);
|
Main.GetMessage(msg);
|
||||||
|
if (type != ShowMessageType.None) Main.ShowMessage(type, msg, title, autoclose);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SocketHandler_HeartBeat(SocketObject ServerMessage)
|
protected override void SocketHandler_HeartBeat(SocketObject ServerMessage)
|
||||||
@ -218,5 +220,29 @@ namespace Milimoe.FunGame.Desktop.Controller
|
|||||||
}
|
}
|
||||||
Main.UpdateUI(MainInvokeType.MatchRoom, StartMatchState.Cancel);
|
Main.UpdateUI(MainInvokeType.MatchRoom, StartMatchState.Cancel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void SocketHandler_StartGame(SocketObject ServerMessage)
|
||||||
|
{
|
||||||
|
// 游戏即将开始
|
||||||
|
Room room = General.HallInstance;
|
||||||
|
List<User> users = new();
|
||||||
|
if (ServerMessage.Length > 0) room = ServerMessage.GetParam<Room>(0) ?? General.HallInstance;
|
||||||
|
if (ServerMessage.Length > 1) users = ServerMessage.GetParam<List<User>>(1) ?? users;
|
||||||
|
Main.UpdateUI(MainInvokeType.StartGame, room, users);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void SocketHandler_EndGame(SocketObject ServerMessage)
|
||||||
|
{
|
||||||
|
Room room = General.HallInstance;
|
||||||
|
List<User> users = new();
|
||||||
|
if (ServerMessage.Length > 0) room = ServerMessage.GetParam<Room>(0) ?? General.HallInstance;
|
||||||
|
if (ServerMessage.Length > 1) users = ServerMessage.GetParam<List<User>>(1) ?? users;
|
||||||
|
Main.UpdateUI(MainInvokeType.EndGame, room, users);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void SocketHandler_Gaming(SocketObject ServerMessage)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,18 +74,4 @@ namespace Milimoe.FunGame.Desktop.Library
|
|||||||
FunGame_AutoRetryOff
|
FunGame_AutoRetryOff
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ShowMessageType
|
|
||||||
{
|
|
||||||
None,
|
|
||||||
General,
|
|
||||||
Tip,
|
|
||||||
Warning,
|
|
||||||
Error,
|
|
||||||
YesNo,
|
|
||||||
OKCancel,
|
|
||||||
RetryCancel,
|
|
||||||
Input,
|
|
||||||
InputCancel
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
using Milimoe.FunGame.Core.Library.Exception;
|
using Milimoe.FunGame.Core.Library.Exception;
|
||||||
using Milimoe.FunGame.Desktop.Controller;
|
using Milimoe.FunGame.Desktop.Controller;
|
||||||
using Milimoe.FunGame.Desktop.Library;
|
|
||||||
using Milimoe.FunGame.Desktop.Model;
|
using Milimoe.FunGame.Desktop.Model;
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Desktop.UI
|
namespace Milimoe.FunGame.Desktop.UI
|
||||||
|
@ -3,7 +3,6 @@ using Milimoe.FunGame.Core.Library.Common.Event;
|
|||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
using Milimoe.FunGame.Core.Library.Exception;
|
using Milimoe.FunGame.Core.Library.Exception;
|
||||||
using Milimoe.FunGame.Desktop.Controller;
|
using Milimoe.FunGame.Desktop.Controller;
|
||||||
using Milimoe.FunGame.Desktop.Library;
|
|
||||||
using Milimoe.FunGame.Desktop.Library.Base;
|
using Milimoe.FunGame.Desktop.Library.Base;
|
||||||
using Milimoe.FunGame.Desktop.Model;
|
using Milimoe.FunGame.Desktop.Model;
|
||||||
using Milimoe.FunGame.Desktop.Utility;
|
using Milimoe.FunGame.Desktop.Utility;
|
||||||
|
@ -30,6 +30,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
private readonly Core.Model.RoomList Rooms = RunTime.RoomList;
|
private readonly Core.Model.RoomList Rooms = RunTime.RoomList;
|
||||||
private readonly Core.Model.Session Usercfg = RunTime.Session;
|
private readonly Core.Model.Session Usercfg = RunTime.Session;
|
||||||
private int _MatchSeconds = 0; // 记录匹配房间的秒数
|
private int _MatchSeconds = 0; // 记录匹配房间的秒数
|
||||||
|
private bool _InGame = false;
|
||||||
|
|
||||||
public Main()
|
public Main()
|
||||||
{
|
{
|
||||||
@ -252,6 +253,24 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MainInvokeType.StartGame:
|
||||||
|
if (objs != null && objs.Length > 0)
|
||||||
|
{
|
||||||
|
Room room = (Room)objs[0];
|
||||||
|
List<User> users = (List<User>)objs[1];
|
||||||
|
StartGame(room, users);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MainInvokeType.EndGame:
|
||||||
|
if (objs != null && objs.Length > 0)
|
||||||
|
{
|
||||||
|
Room room = (Room)objs[0];
|
||||||
|
List<User> users = (List<User>)objs[1];
|
||||||
|
EndGame(room, users);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -447,6 +466,37 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
SetButtonEnableIfLogon(true, ClientState.InRoom);
|
SetButtonEnableIfLogon(true, ClientState.InRoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开始游戏
|
||||||
|
/// </summary>
|
||||||
|
private void StartGame(Room room, List<User> users)
|
||||||
|
{
|
||||||
|
_InGame = true;
|
||||||
|
TaskUtility.NewTask(async () =>
|
||||||
|
{
|
||||||
|
int PlayerCount = users.Count;
|
||||||
|
for (int i = 10; i > 0; i--)
|
||||||
|
{
|
||||||
|
WritelnGameInfo("房间 [ " + room.Roomid + " (" + PlayerCount + "人" + GameMode.GetTypeString(room.RoomType) + ") ] 的游戏将在" + i + "秒后开始...");
|
||||||
|
await Task.Delay(1000);
|
||||||
|
}
|
||||||
|
WritelnGameInfo("房间 [ " + room.Roomid + " (" + PlayerCount + "人" + GameMode.GetTypeString(room.RoomType) + ") ] 的游戏正式开始!");
|
||||||
|
});
|
||||||
|
SetButtonEnableIfLogon(false, ClientState.InRoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏结束,结算
|
||||||
|
/// </summary>
|
||||||
|
private void EndGame(Room room, List<User> users)
|
||||||
|
{
|
||||||
|
// test
|
||||||
|
WritelnGameInfo("===== TEST =====");
|
||||||
|
SetButtonEnableIfLogon(true, ClientState.InRoom);
|
||||||
|
_InGame = false;
|
||||||
|
WritelnGameInfo("游戏结束!" + " [ " + users[new Random().Next(users.Count)] + " ] " + "是赢家!");
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 未登录和离线时,停用按钮
|
/// 未登录和离线时,停用按钮
|
||||||
/// 登录的时候要激活按钮
|
/// 登录的时候要激活按钮
|
||||||
@ -455,6 +505,24 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
/// <param name="status">客户端状态</param>
|
/// <param name="status">客户端状态</param>
|
||||||
private void SetButtonEnableIfLogon(bool isLogon, ClientState status)
|
private void SetButtonEnableIfLogon(bool isLogon, ClientState status)
|
||||||
{
|
{
|
||||||
|
if (_InGame)
|
||||||
|
{
|
||||||
|
AccountSetting.Enabled = isLogon;
|
||||||
|
Stock.Enabled = isLogon;
|
||||||
|
Store.Enabled = isLogon;
|
||||||
|
RoomBox.Enabled = isLogon;
|
||||||
|
RefreshRoomList.Enabled = isLogon;
|
||||||
|
CheckMix.Enabled = isLogon;
|
||||||
|
CheckTeam.Enabled = isLogon;
|
||||||
|
CheckHasPass.Enabled = isLogon;
|
||||||
|
QuitRoom.Enabled = isLogon;
|
||||||
|
RoomSetting.Enabled = isLogon;
|
||||||
|
PresetText.Enabled = isLogon;
|
||||||
|
TalkText.Enabled = isLogon;
|
||||||
|
SendTalkText.Enabled = isLogon;
|
||||||
|
Logout.Enabled = isLogon;
|
||||||
|
if (!isLogon) return;
|
||||||
|
}
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
case ClientState.WaitConnect:
|
case ClientState.WaitConnect:
|
||||||
@ -904,25 +972,6 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 鼠标离开停止匹配按钮时,恢复按钮文本为匹配时长
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
/// <exception cref="NotImplementedException"></exception>
|
|
||||||
private void StopMatch_MouseLeave(object? sender, EventArgs e) => SetMatchSecondsText();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 鼠标轻触停止匹配按钮时,将文本从匹配时长转为停止匹配
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
/// <exception cref="NotImplementedException"></exception>
|
|
||||||
private void StopMatch_MouseHover(object? sender, EventArgs e)
|
|
||||||
{
|
|
||||||
StopMatch.Text = "停止匹配";
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 事件
|
#region 事件
|
||||||
@ -1255,6 +1304,25 @@ namespace Milimoe.FunGame.Desktop.UI
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 鼠标离开停止匹配按钮时,恢复按钮文本为匹配时长
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
|
private void StopMatch_MouseLeave(object? sender, EventArgs e) => SetMatchSecondsText();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 鼠标轻触停止匹配按钮时,将文本从匹配时长转为停止匹配
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
|
private void StopMatch_MouseHover(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
StopMatch.Text = "停止匹配";
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 关闭主界面
|
/// 关闭主界面
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
using Milimoe.FunGame.Core.Api.Utility;
|
using Milimoe.FunGame.Core.Api.Utility;
|
||||||
using Milimoe.FunGame.Core.Library.Common.Event;
|
using Milimoe.FunGame.Core.Library.Common.Event;
|
||||||
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
using Milimoe.FunGame.Core.Library.Exception;
|
using Milimoe.FunGame.Core.Library.Exception;
|
||||||
using Milimoe.FunGame.Desktop.Controller;
|
using Milimoe.FunGame.Desktop.Controller;
|
||||||
using Milimoe.FunGame.Desktop.Library;
|
|
||||||
using Milimoe.FunGame.Desktop.Library.Base;
|
using Milimoe.FunGame.Desktop.Library.Base;
|
||||||
using Milimoe.FunGame.Desktop.Model;
|
using Milimoe.FunGame.Desktop.Model;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user