// Use this for initialization void Start() { InitGameTypes(); CommonHandler.instance.AddCommonCb(CommonHandlerCb.onUpdateGameTypeState, SVR_onUpdateGameTypeState); CommonHandler.instance.AddCommonCb(CommonHandlerCb.onBagChanged, SVR_onBagChanged); SocketClient.AddHandler(Route.connector_main_getGameList, SVR_GetGamesBack); SocketClient.AddHandler(Route.connector_main_getRecentPlay, SVR_GetRecentBack); SocketClient.AddHandler(Route.connector_main_searchGame, SVR_SearchBack); InitPlayerInfo(); ResetDiamondCoin(); Transform funBtnParent = transform.Find("funcBtns/Viewport/btns"); foreach (Transform tmpTrsm in funBtnParent) { Button tmpBtn = tmpTrsm.GetComponent <Button>(); if (tmpBtn) { tmpBtn.onClick.AddListener(delegate() { FuncBtn_Click(tmpBtn); }); } } gameTypeText = transform.Find("games/GameTypeText").GetComponent <Text>(); }
// Use this for initialization void Start() { infoText.text = infos[nowIndex]; SocketClient.AddHandler(Route.connector_main_reconnectEnter, SVR_reconnectEntryBack); SocketClient.OnOpen(OnConnectorOpen); SocketClient.OnClose(OnConnectorClose); ReConnect(); }
// Use this for initialization void Start() { //CommonHandler.instance.SetCommonCb(CommonHandlerCb.onFriend, OnFriend); //CommonHandler.instance.SetCommonCb(CommonHandlerCb.onChat, OnChat); SocketClient.AddHandler(Route.onEnterMatchTable, SVR_onEnterMatchTable); SocketClient.AddHandler(Route.onReadyOrNot, SVR_OnReadyOrNot); SocketClient.AddHandler(Route.onOneLeaveMatchTable, SVR_OnOneLeaveWaitTable); SocketClient.AddHandler(Route.onKicked, SVR_onKicked); SocketClient.AddHandler(Route.onInvite, SVR_onInvite); }
// Use this for initialization void Start() { infoText.text = infos[nowIndex]; SocketClient.AddHandler(Route.connector_main_reconnectEnter, SVR_ConnectorLoginBack); SocketClient.AddHandler(Route.info_game_enterTable, SVR_EnterTableBack); SocketClient.AddHandler(Route.onEnterTable, SVR_OnEnterTable); SocketClient.OnOpen(OnConnectorOpen); SocketClient.OnClose(OnConnectorClose); ReConnect(); }
// Use this for initialization void Start() { GameCommon.instance.SetGameReconnectHandler(OnStartGame); SocketClient.AddHandler(Route.onPlayCard, SVR_OnPlayCard); SocketClient.AddHandler(Route.onGameOver, SVR_OnGameOver); SocketClient.AddHandler(Route.onTableDouziSync, SVR_onTableDouziSync); SocketClient.AddHandler(Route.onChatInTable, SVR_onChatInTable); SocketClient.AddHandler(Route.onChatSeqInTable, SVR_onChatSeqInTable); SocketClient.AddHandler(Route.onStepTimeOver, SVR_onStepTimeOver); OnStartGame(); }
void Start() { WatchSocket(); UIManager.instance.ShowPanel(UIPanel.MainScene.AboutGame.gamePanel); if (PlayerInfo.playerData.ifGetAward == 0) { UIManager.instance.ShowPanel(UIPanel.MainScene.signPanel); } SocketClient.AddHandler(Route.onInvite, SVR_onInvite); SocketClient.AddHandler(Route.onEnterMatchTable, SVR_onEnterMatchTable); SocketClient.AddHandler(Route.onKicked, SVR_onKicked); }
/// <summary> /// 开始监听 /// </summary> public void StartListen() { SocketClient.AddHandler(Route.onAskFriend, SVR_onAskFriend); SocketClient.AddHandler(Route.onAddFriend, SVR_onAddFriend); SocketClient.AddHandler(Route.onDelFriend, SVR_onDelFriend); SocketClient.AddHandler(Route.onFriendInfoChange, SVR_onFriendInfoChange); SocketClient.AddHandler(Route.onFriendChat, SVR_onFriendChat); SocketClient.AddHandler(Route.onNewMail, SVR_onNewMail); SocketClient.AddHandler(Route.onUpdateGameTypeState, SVR_onUpdateGameTypeState); SocketClient.AddHandler(Route.onBagChanged, SVR_onBagChanged); SocketClient.AddHandler(Route.onNotice, SVR_onNotice); SocketClient.AddHandler(Route.onGameWinData, SVR_onGameWinData); }
// 服务器连接成功 void SVR_OnConnectorOpen(string msg) { SocketClient.AddHandler("connector.main.entry", SVR_EntryBack); SocketClient.AddHandler("connector.main.updateData", SVR_UpdateDataBack); SocketClient.AddHandler("connector.main.changePassword", SVR_ChangePasswordBack); SocketClient.AddHandler("onKicked", SVR_OnKicked); Proto_entry_req data = new Proto_entry_req(); data.uid = PlayerData.uid; data.token = PlayerData.token; SocketClient.SendMsg("connector.main.entry", data); connectSvrTimes = 0; }
// Use this for initialization void Start() { instance = this; headImgToggleGroup = headImgParent.GetComponent <ToggleGroup>(); transform.Find("now").GetComponent <Image>().sprite = Util.GetSprite(ImgType.HeadImg, PlayerInfo.playerData.headId); for (int i = 1; i <= 4; i++) { Transform tmp = Instantiate(headImgPrefab, headImgParent).transform; tmp.GetComponent <HeadImgPrefab>().Init(i); tmp.GetComponent <Toggle>().group = headImgToggleGroup; } SocketClient.AddHandler(Route.info_main_changeMyInfo, SVR_changeMyInfoBack); }
void OnConnectorOpen(string msg) { CommonHandler.instance.StartListen(); // 请求配置 SocketClient.AddHandler(Route.connector_main_getSomeConfig, SVR_GetConfigBack); SocketClient.SendMsg(Route.connector_main_getSomeConfig); // 登录 SocketClient.AddHandler(Route.connector_main_enter, SVR_ConnectorLoginBack); Proto.login_req tmp = new Proto.login_req(); tmp.uid = PlayerInfo.uid; tmp.token = PlayerInfo.token; SocketClient.SendMsg(Route.connector_main_enter, tmp); }
public void Init(Proto.EnterRoomRsp msg) { meUid = msg.uid; transform.Find("top/roomName").GetComponent <Text>().text = msg.roomName; foreach (var one in msg.players) { NewPlayer(one); } SocketClient.AddHandler(Cmd.onNewPlayer, Svr_onNewPlayer); SocketClient.AddHandler(Cmd.onOneLeave, Svr_onOneLeave); SocketClient.AddHandler(Cmd.onChat, Svr_onChat); }
// Use this for initialization void Start() { NoMailSet(); mailToggleGroup = mailParent.GetComponent <ToggleGroup>(); foreach (Proto.MailData mail in PlayerInfo.mails) { NewMail(mail); } CommonHandler.instance.AddCommonCb(CommonHandlerCb.onNewMail, SVR_onNewMail); SocketClient.AddHandler(Route.info_mail_readMail, SVR_readMailBack); SocketClient.AddHandler(Route.info_mail_delMail, SVR_delMailBack); SocketClient.AddHandler(Route.info_mail_getMailAward, SVR_getMailAwardBack); }
// Use this for initialization void Start() { nicknameInput.placeholder.gameObject.GetComponent <Text>().text = PlayerInfo.playerData.nickname; signatureInput.placeholder.gameObject.GetComponent <Text>().text = PlayerInfo.playerData.signature; sexOneToggle.GetComponent <Image>().sprite = Util.GetSprite(ImgType.SexImg, 1); sexTwoToggle.GetComponent <Image>().sprite = Util.GetSprite(ImgType.SexImg, 2); if (PlayerInfo.playerData.sex == 1) { sexOneToggle.isOn = true; } else { sexTwoToggle.isOn = true; } SocketClient.AddHandler(Route.info_main_changeMyInfo, SVR_changeMyInfoBack); }
void Start() { nowSelectTrsm = qiZiParent.parent.Find("sign/nowSelect").GetComponent <RectTransform>(); step1Trsm = qiZiParent.parent.Find("sign/step1").GetComponent <RectTransform>(); step2Trsm = qiZiParent.parent.Find("sign/step2").GetComponent <RectTransform>(); qiZiParent.GetComponent <XiangQiClick>().Init(offset, geZiWidth); GameCommon.instance.SetGameReconnectHandler(OnStartGame); SocketClient.AddHandler(Route.onPlayCard, SVR_OnPlayCard); SocketClient.AddHandler(Route.onGameOver, SVR_OnGameOver); SocketClient.AddHandler(Route.onTableDouziSync, SVR_onTableDouziSync); SocketClient.AddHandler(Route.onChatInTable, SVR_onChatInTable); SocketClient.AddHandler(Route.onChatSeqInTable, SVR_onChatSeqInTable); SocketClient.AddHandler(Route.onStepTimeOver, SVR_onStepTimeOver); SocketClient.AddHandler(Route.onPingWant, SVR_onPingWant); SocketClient.AddHandler(Route.onPingNo, SVR_onPingNo); OnStartGame(); }
private void Start() { startTimeText = transform.Find("gameStartTime/Text").GetComponent <Text>(); endTimeText = transform.Find("gameEndTime/Text").GetComponent <Text>(); closeTimeText = transform.Find("gameCloseTime/Text").GetComponent <Text>(); DateTime now = DateTime.Now; DateTime tmpTime = new DateTime(now.Year, now.Month, now.Day, now.Hour, 0, 0); string nowTimeStr = tmpTime.ToString("yyyy-MM-dd HH:mm:ss"); startTimeText.text = nowTimeStr; endTimeText.text = nowTimeStr; closeTimeText.text = nowTimeStr; SocketClient.AddHandler(Route.info_game_createGameMatch, SVR_createGameRsp); transform.Find("gameTypeName").GetComponent <Text>().text = PlayerInfo.gameTypes[gameType].name; costText = transform.Find("gameCost").GetComponent <Text>(); InitParam(); }
// 网关服连接成功,请求登录 private void Svr_onConOpen(string msg) { SocketClient.AddHandler(Cmd.connector_main_enterRoom, Svr_enterBack); int headId = 1; foreach (Transform trsm in transform.Find("head")) { if (trsm.GetComponent <Toggle>().isOn) { headId = int.Parse(trsm.name); break; } } var data = new Proto.EnterRoomReq(); data.roomName = roomNameInput.text; data.nickname = nicknameInput.text; data.headId = headId; SocketClient.SendMsg(Cmd.connector_main_enterRoom, data); }
// Use this for initialization void Start() { friendToggleGroup = matchFriendParent.GetComponent <ToggleGroup>(); SocketClient.AddHandler(Route.onNewPlayer, SVR_OnNewPlayer); SocketClient.AddHandler(Route.onReadyOrNot, SVR_OnReadyOrNot); SocketClient.AddHandler(Route.onStartMatch, SVR_OnStartMatch); SocketClient.AddHandler(Route.onCancelMatch, SVR_OnCancelMatch); SocketClient.AddHandler(Route.onOneLeaveMatchTable, SVR_OnOneLeaveWaitTable); SocketClient.AddHandler(Route.onEnterTable, SVR_OnEnterTable); SocketClient.AddHandler(Route.onChatInMatchTable, SVR_onChatInTable); SocketClient.AddHandler(Route.onMatchClose, SVR_OnMatchClose); SocketClient.AddHandler(Route.match_main_leaveTable, SVR_leaveBack); SocketClient.AddHandler(Route.onInvite, SVR_onInvite); SocketClient.AddHandler(Route.onKicked, SVR_onKicked); CommonHandler.instance.AddCommonCb(CommonHandlerCb.onAddFriend, OnAddFriend); CommonHandler.instance.AddCommonCb(CommonHandlerCb.onDelFriend, OnDelFriend); CommonHandler.instance.AddCommonCb(CommonHandlerCb.onFriendInfoChange, OnFriendInfoChange); CommonHandler.instance.AddCommonCb(CommonHandlerCb.onFriendChat, OnFriendChat); Init(); }
Transform nowAwardTrsm = null; // 当前可领取奖励的物体 // Use this for initialization void Start() { Transform awardParent = transform.Find("award"); Transform tmpTrsm; for (int i = 1; i < PlayerInfo.playerData.loginDays; i++) { tmpTrsm = awardParent.Find(i.ToString()); tmpTrsm.GetComponent <Image>().color = new Color32(155, 155, 155, 255); } if (PlayerInfo.playerData.ifGetAward == 1) { tmpTrsm = awardParent.Find(PlayerInfo.playerData.loginDays.ToString()); tmpTrsm.GetComponent <Image>().color = new Color32(155, 155, 155, 255); } else { nowAwardTrsm = awardParent.Find(PlayerInfo.playerData.loginDays.ToString()); } SocketClient.AddHandler(Route.info_main_sign, SVR_signBack); }
private void Awake() { instance = this; SocketClient.AddHandler(Route.info_game_enterMatchTable, SVR_enterFriendTableBack); }
public void Init(Proto.gameInfo tmpGame) { oneGame = tmpGame; SocketClient.AddHandler(Route.info_game_createMatchTable, SVR_createWaitTableRsp); SocketClient.AddHandler(Route.info_game_refreshMyRank, SVR_RefreshRankBack); SocketClient.AddHandler(Route.info_game_getRankList, SVR_GetRankListBack); if (oneGame.state != Proto.gameState.going) { transform.Find("startGame").gameObject.SetActive(false); } if (oneGame.state == Proto.gameState.wait) { transform.Find("rank/rankN/refresh").gameObject.SetActive(false); } else { transform.Find("rank/rankN/refresh/cost").GetComponent <Text>().text = "-" + PlayerInfo.refreshMyRankCost + "金币"; Proto.GetRankListReq msg = new Proto.GetRankListReq(); msg.gameId = oneGame.id; msg.rankSvr = oneGame.rankServer; SocketClient.SendMsg(Route.info_game_getRankList, msg); } transform.Find("gameName/Text").GetComponent <Text>().text = oneGame.gameName; transform.Find("notice/Text").GetComponent <Text>().text = oneGame.gameNotice; transform.Find("rankAward/rank").GetComponent <Text>().text = string.Format("1:\n2:\n3:\n4-{0}:\n" + "{1}-{2}:", oneGame.award[3].rank, oneGame.award[3].rank + 1, oneGame.award[4].rank); transform.Find("rankAward/num").GetComponent <Text>().text = string.Format("{0}\n{1}\n{2}\n{3}\n{4}", oneGame.award[0].num, oneGame.award[1].num, oneGame.award[2].num, oneGame.award[3].num, oneGame.award[4].num); CreateShowPrefab("开始时间:", oneGame.startTime); CreateShowPrefab("结束时间:", oneGame.endTime); CreateShowPrefab("关闭时间:", oneGame.closeTime); CreateShowPrefab("需要密码:", oneGame.password == "" ? "否" : "是"); CreateShowPrefab("排行人数:", oneGame.rankNum + "人"); var param = PlayerInfo.gameTypes[oneGame.gameType].param; var paramData = oneGame.gameParam; foreach (var one in param) { Proto.paramType paramType = Proto.paramType.gameTime; if (one.uiType == Proto.GameParamUIType.dropdown) { paramType = JsonUtility.FromJson <I_param_dropdown>(one.data).type; } else if (one.uiType == Proto.GameParamUIType.input) { paramType = JsonUtility.FromJson <I_param_input>(one.data).type; } string showInfo = ""; switch (paramType) { case Proto.paramType.gameTime: showInfo = paramData.gameTime / 60 + "分钟"; break; case Proto.paramType.stepTime: showInfo = paramData.stepTime / 60 + "分钟"; break; case Proto.paramType.countTime: showInfo = paramData.countTime + "秒"; break; case Proto.paramType.doorCost: showInfo = paramData.doorCost + "豆子"; break; case Proto.paramType.tableCost: showInfo = paramData.tableCost + "豆子"; break; case Proto.paramType.baseCost: showInfo = paramData.baseCost + "豆子"; break; case Proto.paramType.canRoomChat: showInfo = paramData.canRoomChat ? "允许" : "禁止"; break; case Proto.paramType.canInviteFriend: showInfo = paramData.canInviteFriend ? "允许" : "禁止"; break; default: break; } if (showInfo != "") { CreateShowPrefab(PlayerInfo.gameParamName[paramType] + ":", showInfo); } } }
private void Start() { SocketClient.AddHandler(Route.info_game_enterTable, SVR_EnterTableBack); SocketClient.AddHandler(Route.onEnterTable, SVR_OnEnterTable); }
// gate服连接成功,获取网关 private void Svr_onGateOpen(string msg) { SocketClient.AddHandler(Cmd.gate_main_getCon, Svr_getConBack); SocketClient.SendMsg(Cmd.gate_main_getCon); }