/// <summary> /// 借珍珠 /// </summary> /// <param name="gold"></param> /// <param name="uid"></param> public void SendBorrowGold(int gold, string uid, CallBack <float> call) { SendBorrowReturnGold req = new SendBorrowReturnGold(); req.glod = gold; req.uid = uid; NetProcess.SendRequest <SendBorrowReturnGold>(req, ProtoIdMap.CMD_SendBorrowGold, (msg) => { SendBorrowReturnGoldAck ack = msg.Read <SendBorrowReturnGoldAck>(); if (ack.code == 1) { //Global.Inst.GetController<CommonTipsController>().ShowTips("打赏成功!"); PlayerModel.Inst.UserInfo.gold -= gold; GlobalEvent.dispatch(eEvent.UPDATE_PROP); if (call != null) { call(ack.data.ware); //} //if (mView!=null) { // mView.UpdateByNet(); } } else { GameUtils.ShowErrorTips(ack.code); } }); }
void InitGame(int mode, bool ispvp = false) { Init(mode, _renderer); if (ispvp == false) { if (mode == 1) { User.Color = eTeam.White; } else { User.Color = eTeam.Black; } } if (User.Color == eTeam.Black) { _renderer.UpdateTurnBackground(eTeam.Black); if (ispvp == true) { NetProcess.SendPassThroughMessage(x - 1, y - 1, User.Color); } } else { _renderer.UpdateTurnBackground(eTeam.White); } }
/// <summary> /// 获取俱乐部信息 /// </summary> public void SendGetClubInfo() { CommonSendProto req = new CommonSendProto(); NetProcess.SendRequest <CommonSendProto>(req, ProtoIdMap.CMD_SendGetClubInfo, (msg) => { ClubInfoAck ack = msg.Read <ClubInfoAck>(); if (ack.code == 1 && ack.data.ClubInfo != null) { SendGetClubPlayerInfo(); ClubModel.Inst.mClubId = ack.data.ClubInfo.clubId; ClubModel.Inst.mClubData = ack.data.ClubInfo; } else { if (ack.code == 15) {//需要创建一个俱乐部 BaseView.GetWidget <CreateClubWidget>(AssetsPathDic.CreateClubWidget, Global.Inst.GetController <MainController>().mView.transform); } else { GameUtils.ShowErrorTips(ack.code); } } }); }
/// <summary> /// 获取房间信息 /// </summary> public void SendJoinRoom(string roomId) { MJJoinRoomRequest req = new MJJoinRoomRequest(); req.roomId = roomId; NetProcess.SendRequest <MJJoinRoomRequest>(req, MJProtoMap.CMD_GoIntoRoom, (msg) => { StartGameBackData data = msg.Read <StartGameBackData>(); if (data.code == 1) { //发送位置信息给服务器 if (PlayerModel.Inst.address != null) { NetProcess.SendRequest <SendAddrReq>(PlayerModel.Inst.address, MJProtoMap.CMD_SendAddress, (msgData) => { SQDebug.Log("gps 返回"); }, false); } if (mGameUI != null) { mGameUI.ReSetUI(true); MJGameModel.Inst.ResetData(); } HandleStartGameData(data.data); } else { GameUtils.ShowErrorTips(data.code); } }); }
/// <summary> /// 获取俱乐部玩家列表 /// </summary> /// <param name="call"></param> public void SendGetClubPlayerInfo() { CommonSendProto req = new CommonSendProto(); NetProcess.SendRequest <CommonSendProto>(req, ProtoIdMap.CMD_SendGetClubUsers, (msg) => { ClubPlayerInfoAck data = msg.Read <ClubPlayerInfoAck>(); if (data.code == 1) { if (data.data != null) { ClubModel.Inst.AllPlayerPeach = data.data.allPlayerPeach; } if (data.data != null && data.data.list != null) { ClubModel.Inst.ClubPlayerInfoData = data.data.list; } ClubView view = Global.Inst.GetController <ClubController>().OpenWindow() as ClubView; view.SetData(ClubModel.Inst.mClubData); } else { GameUtils.ShowErrorTips(data.code); } }); }
/// <summary> /// 获取代理接入打赏纪律 /// </summary> /// <param name="req"></param> public void SendGetNewPageAgentBRInfo(SendGetAgentBRDetail req, CallBack <SendGetAgentBRTotal> call) { NetProcess.SendRequest <SendGetAgentBRDetail>(req, ProtoIdMap.CMD_SendGetBRRecord, (msg) => { SendGetAgentBRAck ack = msg.Read <SendGetAgentBRAck>(); if (ack.code == 1) { SendGetAgentBRTotal num = null; if (ack.data != null) { num = ack.data.totalNum; MainViewModel.Inst.UpdateAgentList(req.type, req.page, ack.data.infoList); } if (call != null) { call(num); } } else { GameUtils.ShowErrorTips(ack.code); } }); }
/// <summary> /// 获取盈利收入信息 /// </summary> /// <param name="req"></param> public void SendGetNewPageGainInfo(SendGetGainDetail req, CallBack <PlayerRecordDetailNum> call) { NetProcess.SendRequest <SendGetGainDetail>(req, ProtoIdMap.CMD_SendGainDetail, (msg) => { SendGetGainAck ack = msg.Read <SendGetGainAck>(); if (ack.code == 1) { PlayerRecordDetailNum nums = null; if (ack.data != null) { nums = ack.data.statisticsNum; MainViewModel.Inst.UpdateGainList(req.type, req.page, ack.data.infoList); } if (call != null) { call(nums); } } else { GameUtils.ShowErrorTips(ack.code); } }); }
/// <summary> /// 获取玩家详细记录 /// </summary> /// <param name="req"></param> /// <param name="call"></param> public void SendGetNewPagePlayerDetailRecord(SendGetAgentBRDetail req, CallBack <PlayerRecordDetailNum> call) { NetProcess.SendRequest <SendGetAgentBRDetail>(req, ProtoIdMap.CMD_SendGetPlayerRecordDetail, (msg) => { PlayerRecordDetailBack ack = msg.Read <PlayerRecordDetailBack>(); if (ack.code == 1) { if (ack.data != null) { MainViewModel.Inst.UpdatePlayerRecordDetailList(req.page, ack.data.infoList); } if (call != null) { if (ack.data != null) { call(ack.data.num); } else { call(null); } } } else { GameUtils.ShowErrorTips(ack.code); } }); }
/// <summary> /// 获取仓库信息 /// </summary> /// <param name="call"></param> public void SendGetWareInfo(CallBack call) { CommonSendProto req = new CommonSendProto(); NetProcess.SendRequest <CommonSendProto>(req, ProtoIdMap.CMD_SendGetWareInfo, (msg) => { SendGetWareInfoAck ack = msg.Read <SendGetWareInfoAck>(); if (ack.code == 1) { PlayerModel.Inst.UserInfo.gold = ack.data.info.gold; PlayerModel.Inst.UserInfo.wareHouse = ack.data.info.ware; PlayerModel.Inst.UserInfo.roomCard = ack.data.info.roomCard; GlobalEvent.dispatch(eEvent.UPDATE_PROP); if (call != null) { call(); } } else { GameUtils.ShowErrorTips(ack.code); } }); }
/// <summary> /// 获取玩家信息 /// </summary> /// <param name="uid"></param> public void SendGetPlayerInfo(string uid, int seatId) { SendGetGoldFlowerUserInfoReq req = new SendGetGoldFlowerUserInfoReq(); req.uid = uid; NetProcess.SendRequest <SendGetGoldFlowerUserInfoReq>(req, GoldFlowerProtoIdMap.CMD_SendGetPlayerInfo, (Msg) => { SendGetGoldFlowerUserInfoAck ack = Msg.Read <SendGetGoldFlowerUserInfoAck>(); if (ack.code == 1) { GameUserInfoWidget widget = BaseView.GetWidget <GameUserInfoWidget>(AssetsPathDic.GameUserInfoWidget, mView.transform); widget.SetData(!(seatId == XXGoldFlowerGameModel.Inst.mMySeatId), ack.data.info.headUrl, ack.data.info.nickName, ack.data.info.userId, ack.data.info.address + "", seatId, (index) => { SendReceiveGameChat chat = new SendReceiveGameChat(); chat.fromSeatId = XXGoldFlowerGameModel.Inst.mMySeatId; chat.toSeatId = seatId; chat.faceIndex = index; chat.chatType = (int)eGameChatContentType.HDFace; SendGameChat(chat); }); } else { GameUtils.ShowErrorTips(ack.code); } }); }
/// <summary> /// 发送准备 /// </summary> public void SendReady(CallBack call = null) { CommonSendProto req = new CommonSendProto(); NetProcess.SendRequest <CommonSendProto>(req, GoldFlowerProtoIdMap.CMD_SendRready, (msg) => { CommonRecieveProto ack = msg.Read <CommonRecieveProto>(); if (ack.code == 1) { } else if (ack.code == 104 || ack.code == 105 || ack.code == 24 || ack.code == 13 || ack.code == 7 || ack.code == 6) { bool gold = XXGoldFlowerGameModel.Inst.mGoldPattern; XXGoldFlowerGameModel.Inst.CleanMode(); Global.Inst.GetController <MainController>().OpenWindow(); CloseWindow(); } else { //GameUtils.ShowErrorTips(ack.code); if (call != null) { call(); } } }); }
/// <summary> /// 进入游戏服务器 /// </summary> /// <param name="ip"></param> /// <param name="port"></param> /// <param name="gameType"></param> public void ConnectGameServer(string ip, int port, bool reconnect = false) { Global.Inst.GetController <NetLoadingController>().ShowLoading(true, false); int old = NetProcess.mCurConnectSessionId; NetProcess.Connect(ip, port, (b, i) => { Global.Inst.GetController <NetLoadingController>().ShowLoading(false); if (b) { LoginModel.Inst.mSessionId = i; NetProcess.ReleaseConnectExpectID(i); MainViewModel.Inst.mNowIp = ip; MainViewModel.Inst.mNowPort = port; GameManager.Instance.StartHeartBreath(Reconnect); Engine.ConnectionManager.Instance.MessageEventQueue.ClearAll(); LoginToGameServer(); } else { if (reconnect) { GameManager.Instance.ReConnet(); } else { Global.Inst.GetController <CommonTipsController>().ShowTips("服务器维护中,请稍后再试", "确定", true, () => { }, null, null, "网络异常"); } } }); }
/// <summary> /// 离开房间 /// </summary> public void SendLeaveRoom() { CommonSendProto req = new CommonSendProto(); NetProcess.SendRequest <CommonSendProto>(req, TenProtoIdMap.CMD_SendLeaveRoom, (msg) => { CommonRecieveProto ack = msg.Read <CommonRecieveProto>(); if (ack.code == 1) { } else if (ack.code == 104 || ack.code == 105 || ack.code == 24 || ack.code == 13 || ack.code == 7 || ack.code == 6) { bool gold = TenModel.Inst.mGoldPattern; TenModel.Inst.CleanModel(); Global.Inst.GetController <GamePatternController>().SendGetRoomList((patternView) => { SQSceneLoader.It.LoadScene("HALL", () => { Global.Inst.GetController <GamePatternController>().OpenWindow(); CloseWindow(); }); if (!gold) { patternView.BackToFriendWidget(); } }); } else { GameUtils.ShowErrorTips(ack.code); } }); }
/// <summary> /// 获取玩家之间的距离 /// </summary> public void SendGetPlayerDistances() { CommonSendProto req = new CommonSendProto(); NetProcess.SendRequest <CommonSendProto>(req, GoldFlowerProtoIdMap.CMD_SendGetPlayerDistances, (msg) => { SendGoldFlowerDistanceAck ack = msg.Read <SendGoldFlowerDistanceAck>(); if (ack.code == 1) { GameDistanceWidget widget = BaseView.GetWidget <GameDistanceWidget>(AssetsPathDic.GameDistanceWidget, mView.transform); if (ack.data.distances != null) { for (int i = 0; i < ack.data.distances.Count; i++) { SendGoldFlowerDistanceInfo dis = ack.data.distances[i]; widget.AddDistancePaire(dis.leftHead, dis.leftName, dis.leftUid, dis.RightHead, dis.RightName, dis.RightUid, dis.distance + "Km"); } } } else { GameUtils.ShowErrorTips(ack.code); } }); }
private void NetworkProcess() { //network { //network thread Task.Run(() => { while (true) { NetProcess.start(); NetProcess.client.PacketRecvSync(); Thread.Sleep(1); } }); //network thread Task.Run(() => { DateTime checktime = DateTime.Now; while (true) { NetProcess.Loop(); Thread.Sleep(1); } }); } }
async void OnLoginButtonClicked(object sender, EventArgs e) { User.Username = usernameEntry.Text; User.Password = passwordEntry.Text; if (User.Username == null || User.Password == null) { messageLabel.Text = "아이디와 비번을 다시 입력하세요"; return; } NetProcess.SendLogin(User.Username, User.Password); if (User.Username == "강병욱" || User.Username == "nhs") { MainPage mainpage = Parent as MainPage; bool find = false; foreach (var child in mainpage.Children) { if (child.Title == "찬송") { find = true; } } if (find == false) { mainpage.Children.Add(new Hymn()); } } }
/// <summary> /// 处理消息 /// </summary> /// <param name="messageId"></param> /// <param name="deal"></param> public void SendDealMessage(int messageId, int deal, Action call) { SendDealMessageReq req = new SendDealMessageReq(); req.id = messageId; req.deal = deal; NetProcess.SendRequest <SendDealMessageReq>(req, ProtoIdMap.CMD_SendDealMessage, (msg) => { DealMessageRecieveProto ack = msg.Read <DealMessageRecieveProto>(); if (ack.code == 1) { if (call != null) { call(); } if (ack.data != null && !string.IsNullOrEmpty(ack.data.agentId)) { PlayerModel.Inst.UserInfo.agentId = ack.data.agentId; // mView.SetClubState(false); } } else { GameUtils.ShowErrorTips(ack.code); } }); }
/// <summary> /// 获取俱乐部玩家信息并刷新 /// </summary> /// <param name="callback"></param> public void SendGetClubPlayerInfoAndUpdate(CallBack <ClubInfo> callback) { NetProcess.SendRequest <CommonSendProto>(null, ProtoIdMap.CMD_SendGetClubUsers, (msg) => { ClubPlayerInfoAck data = msg.Read <ClubPlayerInfoAck>(); if (data.code == 1) { if (data.data != null) { ClubModel.Inst.AllPlayerPeach = data.data.allPlayerPeach; } if (data.data != null && data.data.list != null) { ClubModel.Inst.ClubPlayerInfoData = data.data.list; } if (callback != null) { callback(ClubModel.Inst.mClubData); } } else { GameUtils.ShowErrorTips(data.code); } }); }
/// <summary> /// 重连 /// </summary> public void ReConnet() { mLastReconnetTime = Time.realtimeSinceStartup;//重连时间 LoginModel.Inst.mSessionId = -1; Global.Inst.GetController <NetLoadingController>().ShowLoading(false); GameManager.Instance.CancelHeartBreath(); NetProcess.ReleaseAllConnect(); CallBack call = () => { SQDebug.Log("重连次数" + mAutoReConnectNum); if (mBreathCallBack == null) { Global.Inst.GetController <MainController>().BackToMain(Ip, port); } else { mBreathCallBack(MainViewModel.Inst.mNowIp, MainViewModel.Inst.mNowPort); } }; if (mAutoReConnectNum < 3)//如果自动重连次数少于两次就弹出提示 { mAutoReConnectNum++; call(); } else { Global.Inst.GetController <CommonTipsController>().ShowTips("网络连接失败", "尝试连接|退出游戏", true, call, () => { Application.Quit(); }, null, "网络异常"); } }
public void SendBuyRoomCard(int id) { SendPayBuyRoomCardReq req = new SendPayBuyRoomCardReq(); req.id = id; NetProcess.SendRequest <SendPayBuyRoomCardReq>(req, ProtoIdMap.CMD_SendBuyRoomCard, (msg) => { SendPayBuyRoomCardAck ack = msg.Read <SendPayBuyRoomCardAck>(); if (ack.code == 1) { Global.Inst.GetController <CommonTipsController>().ShowTips("购买成功"); if (ack.data != null) { PlayerModel.Inst.UserInfo.gold = ack.data.gold; PlayerModel.Inst.UserInfo.roomCard = ack.data.roomCard; PlayerModel.Inst.UpdateRoomCardGlods(ack.data.roomCard, ack.data.gold); } } else { GameUtils.ShowErrorTips(ack.code); } }); }
/// <summary> /// 换桌 /// </summary> public void SendChangeDesk() { NetProcess.SendRequest <CommonSendProto>(null, MJProtoMap.CMD_SendChangeDesk, (msg) => { StartGameBackData data = msg.Read <StartGameBackData>(); if (data.code == 1) { if (mGameUI != null) { mGameUI.ReSetUI(true); MJGameModel.Inst.ResetData(); MJGameModel.Inst.mState = eMJRoomStatus.GAMEOVER; MJGameModel.Inst.mStartGameData.roomInfo.roomState = eRoomState.GAMEOVER;//改变房间状态 SetTimeout.remove(ShowSmallSettle); SetTimeout.remove(ChangHandsCardsShow); } HandleStartGameData(data.data); } else { GameUtils.ShowErrorTips(data.code); BackToClub(); } }); }
/// <summary> /// 购买商店物品 /// </summary> /// <param name="mData"></param> /// <param name="_type"></param> public void SendPayInfo(RechargeData mData, int _payType) { string appName = Application.productName; if (mData.type == ePropType.golds) { desc = mData.cost + "金币"; v = "金币"; } else { desc = mData.cost + "房卡"; v = "房卡"; } string ip = GetIP();//ip地址 string appInfo = "小熊字牌|com.xftd.xiaoxiongzipai"; #if UNITY_IPHONE appInfo = "小熊游戏|com.xftd.xiaoxiongzipai"; #endif PayItemId req = new PayItemId(); req.id = mData.id; req.subject = v; req.body = desc; req.appinfo = appInfo; //支付方式 req.payChannelId = _payType == 1 ? "wechat" : "alipay"; #if UNITY_ANDROID req.version = "android_v2_0_1"; #elif UNITY_IPHONE req.version = "ios_v2_0_1"; #endif NetProcess.SendRequest <PayItemId>(req, ProtoIdMap.CMD_SendPayInfo, (msg) => { PayInfoBack data = msg.Read <PayInfoBack>(); if (data.code == 1) { PayInfoItem pdata = data.data.payData; //*@param appKey 签名 //*@param ip ip //*@param subject 商品名称 //*@param amount 订单总金额,单位分 //*@param body 商品描述 //*@param orderNo 订单号 //*@param notifyUrl 支付结果通知地址 //*@param cpChannel 渠道,(非必填) //*@param description 订单附加描述(非必填) //*@param extra 附加数据(非必填) //*@param paySytle 支付方式 1:微信 2:支付宝 //* @param appInfo APP信息 应用名 | 包名 SixqinSDKManager.Inst.SendMsg(SixqinSDKManager.RECHARGE, pdata.appKey, pdata.ip, v, int.Parse(pdata.amount), desc, pdata.orderNo, pdata.notifyUrl, "", "", "", _payType.ToString(), appInfo); } else { GameUtils.ShowErrorTips(data.code); } }); }
async void OnLoginClicked(object sender, System.EventArgs e) { string inputstring = await InputBox(this.Navigation); User.myInfo.NickName = inputstring; NetProcess.SendLogin(inputstring, inputstring); }
public MainView mView;//view public MainController() : base("MainView", "Windows/MainView/MainView") { SetModel <MainViewModel>(); NetProcess.RegisterResponseCallBack(ProtoIdMap.CMD_OnGetGoldChang, OnGetRoomCardGlodsUpdate); NetProcess.RegisterResponseCallBack(ProtoIdMap.CMD_GetPayBackInfo, OnGetPayBackInfo); NetProcess.RegisterResponseCallBack(ProtoIdMap.CMD_OnNewMessageGet, OnNewMessageGet); NetProcess.RegisterResponseCallBack(ProtoIdMap.CMD_OnNewMailShowRed, OnNewMailShowRed); }
/// <summary> /// 离开房间按钮点击 /// </summary> public void OnCloseClick() { Global.Inst.GetController <MJGameController>().SendLeaveRoom(() => { NetProcess.InitNetWork(GameManager.Instance.Ip, GameManager.Instance.port); Global.Inst.GetController <MJGameController>().ConnectedToHallServer(null); }); }
int CheckKey(int mode, bool isSend = false) { if (isComputer) { var ret = pOmok[curStone].placement(x, y, curStone); pOmok[curStone].getXY(ref x, ref y); if (ret != 11 && isSend == false) //삼삼 //내부 체크는 1,1부터 시작 하나 그래픽 ui는 0,0부터 시작 { _renderer.UpdateStone(x, y, curStone == 0 ? eTeam.Black : eTeam.White); } if (isSend == true) //네트워크는 기본 0,0 기준이라 변환해준다. { NetProcess.SendPassThroughMessage(x - 1, y - 1, User.Color); } return(ret); } else if (aix != -1 && aiy != -1) { if (isSend == false) { //내부 좌표는 1,1 시작 ui이는 0,0 시작이라 변환 x = aix + 1; y = aiy + 1; } else { x = aix + 1; y = aiy + 1; } aix = aiy = -1; var ret = pOmok[curStone].placement(x, y, curStone); if (ret != 11 && ret != 10 && isSend == false) //삼삼 11 이미 놓여졌음 10 { _renderer.UpdateStone(x, y, curStone == 0 ? eTeam.Black : eTeam.White, true); } if (isSend == true) //네트워크는 기본 0,0 기준이라 변환해준다. { NetProcess.SendPassThroughMessage(x - 1, y - 1, User.Color == eTeam.White ? eTeam.Black : eTeam.White); } else { } return(ret); } else { return(0); } }
void Awake() { It = this; mConnectionManager = new ConnectionManager(); mConnectionManager.OnConnectEvent = OnExecConnect; mConnectionManager.OnReceiveEvent = OnExecReceive; mConnectionManager.OnCloseEvent = OnExecClose; mNetmaskCtr = Global.Inst.GetController <NetLoadingController>(); }
/// <summary> /// 金币换房卡 /// </summary> public void GoldChangeCard(int mId) { PayItemId req = new PayItemId(); req.id = mId; NetProcess.SendRequest <PayItemId>(req, ProtoIdMap.CMD_SendPayInfo, (msg) => { }); }
void OnApplicationPause(bool b) { if (b)//最小化游戏 { SQDebug.Log("程序失去焦点"); NetProcess.ReleaseAllConnect(); GameManager.Instance.ResetConnetTime(); } }
/// <summary> /// 登录大厅服务器 /// </summary> /// <param name="req"></param> public void LoginToServer(LoginSR.SendLogin req, CallBack call) { LoginModel.Inst.LoginData = req; //连接服务器 ConnectServer(() => { //服务器连接成功后登录服务器 NetProcess.SendRequest <LoginSR.SendLogin>(req, ProtoIdMap.CMD_Login, (msg) => { LoginSR.LoginBack data = msg.Read <LoginSR.LoginBack>(); if (data.code == 1) { if (Application.platform != RuntimePlatform.WindowsEditor && Application.platform != RuntimePlatform.OSXEditor) { SixqinSDKManager.Inst.SendMsg(SixqinSDKManager.GET_INSTALL_DATA);//发送扫二维码添加的好友 } PlayerModel.Inst.Token = data.data.userInfo.token; PlayerModel.Inst.UserInfo = data.data.userInfo; if (Application.platform != RuntimePlatform.WindowsEditor && Application.platform != RuntimePlatform.OSXEditor) { //SixqinSDKManager.Inst.InitJPUSH(PlayerModel.Inst.UserInfo.userId);//初始化jpush } ////公众号 //PlayerModel.Inst.PublicSign = data.data.publicSign; //广播 MainViewModel.Inst.BroadMessage.Clear(); Global.Inst.GetController <MainController>().SendGetNotice(); if (!string.IsNullOrEmpty(data.roomId))//在房间中 { Global.Inst.GetController <XXGoldFlowerGameController>().SendJoinRoomReq(data.roomId); } else { if (call != null) { call(); } } } else if (data.code == 12) { PlayerModel.Inst.Token = data.data.userInfo.token; PlayerModel.Inst.UserInfo = data.data.userInfo; if (Application.platform != RuntimePlatform.WindowsEditor && Application.platform != RuntimePlatform.OSXEditor) { SixqinSDKManager.Inst.InitJPUSH(PlayerModel.Inst.UserInfo.userId);//初始化jpush } Global.Inst.GetController <GamePatternController>().ConnectGameServer(data.data.gameServer.ip, int.Parse(data.data.gameServer.port)); } else { GameUtils.ShowErrorTips(data.code); } }); }); }