12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using System;
- namespace ET.Server
- {
- /// <summary>
- /// 黄冈晃晃 踢人
- /// </summary>
- [MessageHandler(SceneType.Game)]
- public class C2G_HGHHKickHandler : AMRpcHandler<C2G_HGHHKick, G2C_HGHHKick>
- {
- protected override async ETTask Run(Session session, C2G_HGHHKick request, G2C_HGHHKick response, Action reply)
- {
- Player player = session.GetComponent<SessionPlayerComponent>().GetMyPlayer();
- if (player == null)
- {
- response.Error = ErrorCode.ERR_OperationError;
- response.Message = "玩家不存在或离线...";
- reply();
- return;
- }
-
- // 判断参数
- if (request.RoomId <= 0)
- {
- response.Error = ErrorCode.ERR_ParameterError;
- response.Message = "参数错误,房间号为空...";
- reply();
- return;
- }
-
- Scene scene = session.DomainScene();
-
- // 请求的房间是否能找到
- Room room = scene.GetComponent<GameRoomComponent>().Get(request.RoomId);
- if (room == null)
- {
- response.Error = ErrorCode.ERR_OperationError;
- response.Message = "请求的房间不存在或已解散...";
- reply();
- return;
- }
-
- // 玩家是否是房主
- if (room.OwnerId != player.Id)
- {
- response.Error = ErrorCode.ERR_OperationError;
- response.Message = "玩家不是房主,不可操作...";
- reply();
- return;
- }
-
- // 判断玩家是否在其他房间
- if (!player.RoomId.Equals(request.RoomId))
- {
- response.Error = ErrorCode.ERR_OperationError;
- response.Message = "玩家不在此房间,不可操作...";
- reply();
- return;
- }
-
- // 是否踢自己
- if (request.PlayerId == player.Id)
- {
- response.Error = ErrorCode.ERR_ParameterError;
- response.Message = "不可自己踢自己...";
- reply();
- return;
- }
-
- // 状态是否可踢人
- HGHuangHuangComponent hgHuangHuangComponent = room.GetComponent<HGHuangHuangComponent>();
- if (hgHuangHuangComponent != null && hgHuangHuangComponent.State != 0)
- {
- response.Error = ErrorCode.ERR_ParameterError;
- response.Message = "游戏进行中,不可踢人...";
- reply();
- return;
- }
- room.Remove(request.PlayerId);
- reply();
- await ETTask.CompletedTask;
- }
- }
- }
|