/// <summary> /// 模拟本地动作 /// </summary> private IEnumerator ClientPlayAct(int actCard, int userId, PlayerActType act) { var pushPlayerActS2C = new PushPlayerActS2C(); pushPlayerActS2C.actCard = actCard; pushPlayerActS2C.userId = userId; pushPlayerActS2C.act = act; NetMgr.Instance.OnClientReceiveBuff(MsgNoS2C.PUSH_PLAYER_ACT.GetHashCode(), 0, pushPlayerActS2C); yield return(new WaitForSeconds(1)); curSit = GlobalData.GetNextSit(curSit, 1); if (act == PlayerActType.PUT_CARD) { int getCard = getRangeCard(false); var getCardS2C = new PushPlayerActS2C(); getCardS2C.actCard = getCard; getCardS2C.userId = battleProxy.playerSitInfoDic[curSit].userId; getCardS2C.act = PlayerActType.GET_CARD; NetMgr.Instance.OnClientReceiveBuff(MsgNoS2C.PUSH_PLAYER_ACT.GetHashCode(), 0, getCardS2C); yield return(new WaitForSeconds(1)); GameMgr.Instance.StartCoroutine(ClientPlayerTip()); } else { yield return(new WaitForSeconds(1)); GameMgr.Instance.StartCoroutine(ClientPlayerTip()); } }
/// <summary> /// json格式转为PushPlayerActS2C /// </summary> /// <param name="actJson"></param> /// <returns></returns> private static PushPlayerActS2C paserAct(JsonData actJson) { var act = new PushPlayerActS2C(); act.act = (PlayerActType)int.Parse(actJson["act"].ToString()); act.actCard = int.Parse(actJson["actCard"].ToString()); if (actJson["chiCards"].Count > 0) { for (int i = 0; i < actJson["chiCards"].Count; i++) { act.chiCards.Add(int.Parse(actJson["chiCards"][i].ToString())); } } try { for (int i = 0; i < actJson["flowerCards"].Count; i++) { act.flowerCards.Add(int.Parse(actJson["flowerCards"].ToString())); } } catch (Exception) { } act.targetUserId = int.Parse(actJson["targetUserId"].ToString()); act.userId = int.Parse(actJson["userId"].ToString()); return(act); }
public IEnumerator HuHandler() { var pushPlayerActS2C = new PushPlayerActS2C(); pushPlayerActS2C.actCard = 17; //pushPlayerActS2C.actCard = SimulationGetACard(); pushPlayerActS2C.userId = 9527; pushPlayerActS2C.act = PlayerActType.SELF_HU; NetMgr.Instance.OnClientReceiveBuff(MsgNoS2C.PUSH_PLAYER_ACT.GetHashCode(), 0, pushPlayerActS2C); yield return(new WaitForSeconds(0.1f)); PushMatchResultS2C matchResultS2C = new PushMatchResultS2C(); for (int i = 0; i < GlobalData.SIT_NUM; i++) { var matchResultPlayerVO = new PlayerMatchResultVOS2C(); var playerVO = battleProxy.playerSitInfoDic[i + 1]; matchResultPlayerVO.userId = playerVO.userId; matchResultPlayerVO.addScore = i == 0 ? 24 : -8; matchResultPlayerVO.handCards.AddRange(playerVO.handCards.ToArray()); matchResultS2C.resultInfos.Add(matchResultPlayerVO); } matchResultS2C.huUserId.Add(playerInfoProxy.UserInfo.UserID); NetMgr.Instance.OnClientReceiveBuff(MsgNoS2C.PUSH_MATCH_END.GetHashCode(), 0, matchResultS2C); PushRoomResultS2C roomResultS2C = new PushRoomResultS2C(); for (int i = 0; i < GlobalData.SIT_NUM; i++) { var roomResultPlayerVO = new PlayerRoomResultVOS2C(); var playerVO = battleProxy.playerSitInfoDic[i + 1]; roomResultPlayerVO.userId = playerVO.userId; roomResultPlayerVO.addScore = i == 0 ? 24 : -8; roomResultPlayerVO.anGangCount = 0; roomResultPlayerVO.mingGangCount = 0; roomResultPlayerVO.selfHuCount = i == 0 ? 1 : 0; roomResultPlayerVO.otherHuCount = 0; roomResultPlayerVO.sendPaoCount = 0; roomResultS2C.resultInfos.Add(roomResultPlayerVO); } NetMgr.Instance.OnClientReceiveBuff(MsgNoS2C.PUSH_ROOM_END.GetHashCode(), 0, roomResultS2C); }