public void onBtnJoin() { string club_id = id.value; int cid = 0; if (club_id == "" || !int.TryParse(club_id, out cid)) { GameAlert.Show("请填写俱乐部ID"); reset(); return; } NetMgr nm = NetMgr.GetInstance(); nm.request_apis("apply_join_club", "club_id", cid, data => { NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString()); if (ret.errcode != 0) { GameAlert.Show(ret.errmsg); reset(); return; } GameAlert.Show("已成功申请,请等待管理员审核", () => { gameObject.SetActive(false); id.value = ""; }); }); }
public void onBtnSubmit() { string content = mContent.value; if (content == "") { GameAlert.Show("请填写反馈内容"); return; } JsonObject ob = new JsonObject(); ob["content"] = content; ob["qq"] = "123"; ob["phone"] = "12345678901"; NetMgr.GetInstance().request_apis("feedback", ob, data => { NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString()); if (ret.errcode != 0) { GameAlert.Show("提交失败, 请检查网络"); return; } GameAlert.Show("感谢您的反馈,我们会尽快处理!", () => { back(); }); }); }
public void onBtnOK() { int score = int.Parse(getInput(mEditor, "ip_score")); int limit = int.Parse(getInput(mEditor, "ip_limit")); if (limit < 0) { GameAlert.Show("活力值必须小于或者等于0"); return; } limit = 0 - limit; JsonObject ob = new JsonObject(); ob["club_id"] = mClubID; ob["user_id"] = mEditMember.id; ob["score"] = score; ob["limit"] = limit; NetMgr.GetInstance().request_apis("setup_club_member", ob, data => { NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString()); if (ret.errcode != 0) { Debug.Log("setup_club_member fail"); return; } mEditor.gameObject.SetActive(false); refresh(); }); }
protected void SendAlert(string message, List <string> userNames = null, List <Tuple <string, string> > userNameAndMessages = null) { Task.Run(async() => { using (var scope = Services.CreateScope()) { var hubContext = scope.ServiceProvider .GetRequiredService <IHubContext <H, T> >(); GameAlert alert = new GameAlert(message, this.GameType); if (userNames != null && userNames.Any() && !string.IsNullOrEmpty(message)) { await hubContext.Clients.Users(userNames).ReceiveNotification(alert); } if (userNameAndMessages != null && userNameAndMessages.Any()) { foreach (var userNameToMessage in userNameAndMessages) { await hubContext.Clients.User(userNameToMessage.Item1).ReceiveNotification(new GameAlert(userNameToMessage.Item2, this.GameType)); } } if ((userNames == null || !userNames.Any()) && !string.IsNullOrEmpty(message)) { await hubContext.Clients.Group(GameHub.GetChannelGroupIdentifier(this.Id)).ReceiveNotification(alert); } } }); }
public void Login(string account, string token) { int port = 5005; mAccount = account; mToken = token; Debug.Log("Login"); pc.initClient(mServer, port, ret => { if (!ret) { Debug.Log("Login initClient fail"); GameAlert.Show("连接服务器失败,请检查网络"); return; } pc.connect(null, data => { JsonObject msg = new JsonObject(); msg ["uid"] = account; pc.request("gate.gateHandler.queryEntry", msg, OnQuery); }); }); }
public void onBtnCreate() { string _name = name.value; string _desc = desc.value; string msg = null; //int price = 300; if (_name == "") { msg = "俱乐部名字不能为空"; } else if (_desc == "") { msg = "请填写俱乐部介绍"; } //else if (GameMgr.GetInstance ().userMgr.gems < price) // msg = "您的麻油不够"; if (msg != null) { GameAlert.Show(msg); return; } //GameAlert.Show ("创建俱乐部将立即扣除" + price + "麻油,要继续吗?", () => { JsonObject ob = new JsonObject(); ob ["name"] = _name; ob ["desc"] = _desc; if (pickPath != null) { byte[] bytes = File.ReadAllBytes(pickPath); string base64 = Convert.ToBase64String(bytes); ob ["logo"] = base64; } NetMgr nm = NetMgr.GetInstance(); nm.request_apis("create_club", ob, data => { NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString()); if (ret.errcode != 0) { GameAlert.Show(ret.errmsg); return; } GameMgr.GetInstance().get_coins(); GameAlert.Show("俱乐部创建成功!", () => { reset(); back(); }); }); //}, true); }
public void onBuyIAPFail(string code) { Debug.Log("onBuyIAPFail: " + code); buying = false; WaitMgr.Hide(); GameAlert.Show("购买失败:" + code); }
public void onResume(JsonObject data) { //string sign = userMgr.sign; userMgr = JsonUtility.FromJson <UserMgr>(data.ToString()); //userMgr.sign = sign; InitHandler(); string roomid = userMgr.roomid; if (roomid != null && roomid.Length == 6) { enterRoom(roomid, code => { string content = "房间[" + roomid + "]已解散"; if (code == 2224) { content = "房间[" + roomid + "]已满"; } else if (code == 2231) { content = "您的IP和其他玩家相同"; } else if (code == 2232) { content = "您的位置和其他玩家太近"; } else if (code == 2233) { content = "您的定位信息无效,请检查是否开启定位"; } if (code != 0) { GameAlert.Show(content, () => { if (SceneManager.GetActiveScene().name == "04.table3d") { GameManager.GetInstance().exit(); } }); } }); userMgr.roomid = null; } else { if (SceneManager.GetActiveScene().name == "04.table3d" && !ReplayMgr.GetInstance().isReplay()) { GameAlert.Show("房间已结束,点确定返回大厅", () => { GameManager.GetInstance().exit(); }); } } }
public void onBtnSave() { Transform body = transform.Find("Body"); string _name = getInput(body, "name/input"); string _desc = getInput(body, "desc/input"); string msg = null; if (_name == "") { msg = "俱乐部名字不能为空"; } else if (_desc == "") { msg = "请填写俱乐部介绍"; } if (msg != null) { GameAlert.Show(msg); return; } bool auto_start = body.Find("params/auto_start").GetComponent <UIToggle>().value; JsonObject ob = new JsonObject(); ob["id"] = mClubID; ob["name"] = _name; ob["desc"] = _desc; ob["auto_start"] = auto_start; if (pickPath != null) { byte[] bytes = File.ReadAllBytes(pickPath); string base64 = Convert.ToBase64String(bytes); ob["logo"] = base64; } NetMgr nm = NetMgr.GetInstance(); nm.request_apis("set_club", ob, data => { NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString()); if (ret.errcode != 0) { Debug.Log("set_club fail: " + ret.errmsg); return; } GameAlert.Show("俱乐部设置成功!", () => { back(); }); }); }
static int _m_show(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); GameAlert gen_to_be_invoked = (GameAlert)translator.FastGetCSObj(L, 1); int gen_param_count = LuaAPI.lua_gettop(L); if (gen_param_count == 4 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && translator.Assignable <System.Action>(L, 3) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 4)) { string _content = LuaAPI.lua_tostring(L, 2); System.Action _act = translator.GetDelegate <System.Action>(L, 3); bool _needCancel = LuaAPI.lua_toboolean(L, 4); gen_to_be_invoked.show(_content, _act, _needCancel); return(0); } if (gen_param_count == 3 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && translator.Assignable <System.Action>(L, 3)) { string _content = LuaAPI.lua_tostring(L, 2); System.Action _act = translator.GetDelegate <System.Action>(L, 3); gen_to_be_invoked.show(_content, _act); return(0); } if (gen_param_count == 2 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)) { string _content = LuaAPI.lua_tostring(L, 2); gen_to_be_invoked.show(_content); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to GameAlert.show!")); }
void Awake() { Transform dv = transform.Find("Dissolve"); mDissolve = dv.gameObject; mInfo = dv.Find("info").GetComponent <UILabel>(); Transform seats = dv.Find("seats"); for (int i = 0; i < seats.childCount; i++) { mSeats.Add(seats.GetChild(i)); } mBtnAgree = dv.Find("btn_agree").gameObject; mBtnReject = dv.Find("btn_reject").gameObject; mBtnDissolve = dv.Find("btn_dissolve").gameObject; mBtnAgree.GetComponent <UIButton>().onClick.Add(new EventDelegate(this, "onBtnAgree")); mBtnReject.GetComponent <UIButton>().onClick.Add(new EventDelegate(this, "onBtnReject")); mBtnDissolve.GetComponent <UIButton>().onClick.Add(new EventDelegate(this, "onBtnDissolve")); GameMgr gm = GameMgr.GetInstance(); gm.AddHandler("game_reset", data => { mEndTime = 0; mDissolve.SetActive(false); }); gm.AddHandler("dissolve_notice", data => { showDissolveNotice((DissolveInfo)data); }); gm.AddHandler("dissolve_done", data => { mDissolve.SetActive(false); }); gm.AddHandler("dissolve_cancel", data => { DissolveCancel dc = (DissolveCancel)data; mDissolve.SetActive(false); int uid = dc.reject; if (uid > 0 && uid != gm.userMgr.userid) { GameAlert.GetInstance().show("玩家" + uid + "已拒绝解散请求"); } }); }
static int __CreateInstance(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); if (LuaAPI.lua_gettop(L) == 1) { GameAlert gen_ret = new GameAlert(); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to GameAlert constructor!")); }
public void onBuyIAPResp(string receipt) { var file = Application.persistentDataPath + "/receipts/" + receipt; buying = false; if (!File.Exists(file)) { Debug.Log("receipt not exist"); return; } string content = File.ReadAllText(file); var args = new JsonObject(); var token = NetMgr.GetInstance().getToken(); args ["token"] = token; args["receipt"] = content; var http = Http.GetInstance(); http.Post("/pay_iap/query_order", args, data => { Debug.Log("ret from pay_iap"); QueryOrderReply ret = JsonUtility.FromJson <QueryOrderReply> (data.ToString()); if (ret.errcode == (int)QueryOrderErrcode.ORDER_SUCCESS) { GameAlert.Show("购买成功"); GameMgr.GetInstance().get_coins(); File.Delete(file); } else { GameAlert.Show("购买失败:" + ret.errcode); } WaitMgr.Hide(); }, err => { WaitMgr.Hide(); GameAlert.Show("购买通讯失败"); }); }
void enterClub(int clubid) { /* 通过俱乐部名片进入 * 1) 检查是否俱乐部成员 * 2) 如果是普通会员,进入hall界面 * 3) 如果是管理员,进入admin界面 * 4) 如果不是俱乐部成员,发送加入申请 */ NetMgr nm = NetMgr.GetInstance(); nm.request_apis("get_club_role", "club_id", clubid, data => { GetClubRole ret = JsonUtility.FromJson <GetClubRole> (data.ToString()); if (ret.errcode != 0) { Debug.Log("get_club_role fail: " + ret.errcode); return; } string role = ret.data.role; if (role == "member") { GameObject hall = GameObject.Find("PHall"); hall.GetComponent <Hall>().enter(clubid); } else if (role == "admin") { GameObject admin = GameObject.Find("PAdmin"); admin.GetComponent <Admin>().enter(clubid); } else if (role == "outsider") { nm.request_apis("apply_join_club", "club_id", clubid, data2 => { NormalReturn ret2 = JsonUtility.FromJson <NormalReturn>(data2.ToString()); if (ret2.errcode != 0) { Debug.Log("apply_join_club fail: " + ret2.errcode); return; } GameAlert.Show("已成功申请加入俱乐部" + clubid + ",请等待管理员审核"); }); } }); }
void createClubRoom(JsonObject conf) { NetMgr nm = NetMgr.GetInstance(); JsonObject ob = new JsonObject(); ob ["conf"] = conf; nm.request_connector("create_private_room", ob, data => { NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString()); if (ret.errcode != 0) { GameAlert.Show(ret.errmsg); return; } back(); }); }
static int _m_GetInstance_xlua_st_(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); { GameAlert gen_ret = GameAlert.GetInstance( ); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
void OnStateChanged(NetWorkState state) { Debug.Log("onStateChanged: " + state); if (state == NetWorkState.DISCONNECTED) { if (pc.getKicked()) { Loom.QueueOnMainThread(() => { GameAlert.Show("您的帐号已在另一台设备上登录,即将登出", () => { logout(); }); }); } else { mRetry = 0; doReconnect(); } } }
void onInputFinished(string id) { Debug.Log("input finished: " + id); GameMgr gm = GameMgr.GetInstance(); gm.enterRoom(id, code => { if (code != 0) { string content = "房间[" + id + "]不存在"; if (code == 2224) { content = "房间[" + id + "]已满!"; } else if (code == 2222) { content = "钻石不足"; } else if (code == 2231) { content = "您的IP和其他玩家相同"; } else if (code == 2232) { content = "您的位置和其他玩家太近"; } else if (code == 2233) { content = "您的定位信息无效,请检查是否开启定位"; } else if (code == 2251) { content = "您不是俱乐部普通成员,无法加入俱乐部房间"; } GameAlert.Show(content); } }); }
void onBtnSubmit() { NetMgr net = NetMgr.GetInstance(); string account = name.value.Replace(" ", ""); string pass = passwd.value; string[] accounts = new string[] { "test1", "test2", "test3", "test4", "test8" }; bool found = false; for (int i = 0; i < accounts.Length; i++) { if (accounts [i] == account) { found = true; break; } } if (!found) { GameAlert.Show("用户不存在,请重新输入!", () => { name.value = ""; }); return; } if (pass != "654123") { GameAlert.Show("密码错误, 请重新输入!", () => { passwd.value = ""; }); return; } net.TestLogin(account); }
void enterRoom(string roomid) { GameMgr gm = GameMgr.GetInstance(); gm.enterRoom(roomid, code => { if (code != 0) { string content = "房间[" + roomid + "]不存在"; if (code == 2224) { content = "房间[" + roomid + "]已满!"; } else if (code == 2222) { content = "钻石不足"; } else if (code == 2231) { content = "您的IP和其他玩家相同"; } else if (code == 2232) { content = "您的位置和其他玩家太近"; } else if (code == 2233) { content = "您的定位信息无效,请检查是否开启定位"; } else if (code == 2251) { content = "您不是俱乐部普通成员,无法加入俱乐部房间"; } GameAlert.Show(content); } }); }
public void onBtnAdmin() { bool admin = !mEditMember.admin; JsonObject ob = new JsonObject(); ob["club_id"] = mClubID; ob["user_id"] = mEditMember.id; ob["admin"] = admin; NetMgr.GetInstance().request_apis("prompt_club_member", ob, data => { NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString()); if (ret.errcode != 0) { Debug.Log("prompt_club_member fail"); return; } mEditor.gameObject.SetActive(false); refresh(); GameAlert.Show((admin ? "已设置" : "已取消") + mEditMember.name + "管理员权限"); }); }
void showDetail(ClubRoomInfo room) { mRoomID = room.id; Transform detail = transform.Find("detail"); setActive(detail, null, true); Transform seats = detail.Find("seats"); UIGrid grid = seats.GetComponent <UIGrid>(); int nseats = room.players.Count; int empties = 0; for (int i = 0; i < seats.childCount && i < nseats; i++) { ClubRoomPlayer p = room.players [i]; Transform s = seats.GetChild(i); bool empty = p.id == 0; setActive(s, null, true); setActive(s, "name", !empty); setActive(s, "bghead/icon", !empty); setIcon(s, "bghead/icon", p.id); setText(s, "name", p.name); if (empty) { empties++; } } for (int i = nseats; i < seats.childCount; i++) { Transform s = seats.GetChild(i); setActive(s, null, false); } grid.Reposition(); ClubRoomBaseInfo info = room.base_info; Transform rules = detail.Find("rules"); setText(rules, "rule", "上海敲麻"); setText(rules, "huafen", "" + info.huafen); setText(rules, "playernum", "" + info.numOfSeats); setText(rules, "gamenum", "" + info.maxGames); setText(rules, "maxfan", "" + info.maxFan); setText(rules, "maima", info.maima ? "是" : "否"); setText(rules, "qidui", info.qidui ? "是" : "否"); setText(rules, "limit_ip", "否"); setText(rules, "limit_gps", "否"); setBtnEvent(detail, "btn_join", () => { if (empties == 0) { GameAlert.Show("房间已满,请重新选择"); return; } mShow = false; GameMgr.GetInstance().enterRoom(room.room_tag, code => { Debug.Log("club enterRoom code=" + code); if (0 != code) { mShow = true; string content = "房间不存在"; if (code == 2224) { content = "房间已满!"; } else if (code == 2222) { content = "钻石不足"; } else if (code == 2231) { content = "您的IP和其他玩家相同"; } else if (code == 2232) { content = "您的位置和其他玩家太近"; } else if (code == 2233) { content = "您的定位信息无效,请检查是否开启定位"; } else if (code == 2251) { content = "您不是俱乐部普通成员,无法加入俱乐部房间"; } GameAlert.Show(content); } }); }); setBtnEvent(detail, "btn_back", () => { mRoomID = 0; setActive(detail, null, false); }); }
public static void Show(string content, Action act = null, bool needCancel = false) { GameAlert.GetInstance().show(content, act, needCancel); }
void InitHandler() { NetMgr net = NetMgr.GetInstance(); RoomMgr rm = RoomMgr.GetInstance(); PomeloClient pc = net.pc; pc.on("login_result", data => { Debug.Log("login_result"); object ob; if (!data.TryGetValue("errcode", out ob)) { return; } int ret = Convert.ToInt32(ob); if (ret != 0) { Debug.Log("login_result ret=" + ret); return; } JsonObject room = (JsonObject)data["data"]; rm.updateRoom(room); DispatchEvent("game_reset"); }); pc.on("login_finished", data => { Debug.Log("login_finished"); string table = "04.table3d"; string name = SceneManager.GetActiveScene().name; if (name != table) { mHandlerMap.Clear(); LoadingScene.LoadNewScene(table); } else { if (rm.isPlaying()) { net.send("ready"); } } }); pc.on("exit_result", data => { string reason = (string)data["reason"]; if (reason == "kick") { GameAlert.GetInstance().show("您已被管理员请出房间", () => { GameManager.GetInstance().exit(); }); } else if (reason == "request") { GameManager.GetInstance().exit(); } }); pc.on("exit_notify_push", data => { int uid = Convert.ToInt32(data["value"]); int seatindex = rm.userExit(uid); DispatchEvent("user_state_changed", seatindex); }); pc.on("dispress_push", data => { GameManager.GetInstance().exit(); }); pc.on("new_user_comes_push", data => { int seatindex = rm.newUserCome(data); DispatchEvent("user_state_changed", seatindex); }); pc.on("user_state_push", data => { int seatindex = rm.updateUser(data); DispatchEvent("user_state_changed", seatindex); }); pc.on("game_wait_maima_push", data => { rm.updateMaima(data); DispatchEvent("game_wait_maima"); }); pc.on("game_maima_push", data => { rm.updateMaima(data); DispatchEvent("game_maima"); }); pc.on("user_ready_push", data => { int seatindex = rm.updateUser(data); DispatchEvent("user_state_changed", seatindex); }); pc.on("game_dice_push", data => { rm.updateState(data); DispatchEvent("game_dice"); }); pc.on("game_holds_push", data => { Debug.Log("get game_holds_push"); int si = rm.updateSeat(data); DispatchEvent("game_holds", si); }); pc.on("game_holds_len_push", data => { Debug.Log("get game_holds_len_push"); int si = rm.updateSeat(data); DispatchEvent("game_holds_len", si); }); pc.on("game_state_push", data => { rm.updateState(data); DispatchEvent("game_state"); }); pc.on("game_begin_push", data => { Debug.Log("get game_begin_push"); rm.newRound(); rm.updateState(data); foreach (PlayerInfo p in rm.players) { p.ready = false; DispatchEvent("user_state_changed", p.seatindex); } DispatchEvent("game_begin"); }); pc.on("game_playing_push", data => { Debug.Log("get game_playing_push"); rm.updateState(data); DispatchEvent("game_playing"); }); pc.on("game_sync_push", data => { Debug.Log("get game_sync_push"); if (!data.ContainsKey("pseudo")) { rm.updateState(data); rm.updateSeats((JsonArray)data["seats"]); } DispatchEvent("user_hf_updated"); DispatchEvent("game_sync"); }); pc.on("hangang_notify_push", data => { int seatindex = Convert.ToInt32(data["seatindex"]); DispatchEvent("hangang_notify", seatindex); }); pc.on("game_action_push", data => { Debug.Log("get game_action_push"); rm.updateAction(data); DispatchEvent("game_action"); }); pc.on("game_chupai_push", data => { Debug.Log("get game_chupai_push"); rm.updateState(data); ChupaiPush cp = JsonUtility.FromJson <ChupaiPush> (data.ToString()); rm.updateLimit(cp.turn, cp.limit); if (cp.bg == true) { return; } DispatchEvent("game_turn_change"); }); pc.on("game_num_push", data => { rm.updateRoomInfo(data); DispatchEvent("game_num"); }); pc.on("game_over_push", data => { rm.updateOverInfo(data); DispatchEvent("game_over"); }); pc.on("mj_count_push", data => { rm.updateState(data); if (data.ContainsKey("bg")) { return; } DispatchEvent("mj_count"); }); pc.on("hu_push", data => { HuPushInfo info = rm.updateHu(data); if (info.bg) { return; } DispatchEvent("hupai", info); }); pc.on("game_chupai_notify_push", data => { Debug.Log("get game_chupai_notify_push"); ActionInfo info = rm.doChupai(data); if (info.bg == true) { return; } DispatchEvent("game_chupai_notify", info); }); pc.on("game_hf_push", data => { rm.updateFlowers(data); Debug.Log("get game_hf_push"); DispatchEvent("user_hf_updated"); }); pc.on("game_af_push", data => { ActionInfo info = rm.doAddFlower(data); if (info.bg == true) { return; } DispatchEvent("user_hf_updated", info); }); pc.on("game_mopai_push", data => { Debug.Log("get game_mopai_push"); ActionInfo info = rm.doMopai(data); if (info.bg == true) { return; } DispatchEvent("game_mopai", info); }); pc.on("guo_notify_push", data => { Debug.Log("get guo_notify_push"); ActionInfo info = rm.doGuo(data); if (info.bg == true) { return; } DispatchEvent("guo_notify", info); }); pc.on("guo_result", data => { Debug.Log("get guo_result"); DispatchEvent("guo_result"); }); pc.on("peng_notify_push", data => { ActionInfo info = rm.doPeng(data); if (info.bg == true) { return; } DispatchEvent("peng_notify", info); }); pc.on("chi_notify_push", data => { ActionInfo info = rm.doChi(data); if (info.bg == true) { return; } DispatchEvent("chi_notify", info); }); pc.on("gang_notify_push", data => { GangInfo info = rm.doGang(data); if (info.bg == true) { return; } DispatchEvent("gang_notify", info); }); pc.on("ting_notify_push", data => { TingInfo info = rm.doTing(data); if (info.bg == true) { return; } DispatchEvent("ting_notify", info.seatindex); }); pc.on("chat_push", data => { ChatInfo info = JsonUtility.FromJson <ChatInfo>(data.ToString()); DispatchEvent("chat", info); }); pc.on("quick_chat_push", data => { QuickChatInfo info = JsonUtility.FromJson <QuickChatInfo>(data.ToString()); DispatchEvent("quick_chat_push", info); }); pc.on("emoji_push", data => { EmojiPush info = JsonUtility.FromJson <EmojiPush>(data.ToString()); DispatchEvent("emoji_push", info); }); pc.on("demoji_push", data => { Debug.Log("get demoji_push"); DEmojiPush info = JsonUtility.FromJson <DEmojiPush>(data.ToString()); DispatchEvent("demoji_push", info); }); pc.on("dissolve_notice_push", data => { DissolveInfo dv = JsonUtility.FromJson <DissolveInfo>(data.ToString()); rm.dissolve = dv; DispatchEvent("dissolve_notice", dv); }); pc.on("dissolve_done_push", data => { Debug.Log("dissolve_done_push"); DispatchEvent("dissolve_done"); }); pc.on("dissolve_cancel_push", data => { Debug.Log("dissolve_cancel_push"); DissolveCancel dc = JsonUtility.FromJson <DissolveCancel>(data.ToString()); DispatchEvent("dissolve_cancel", dc); }); pc.on("voice_msg_push", data => { VoiceMsgPush vm = JsonUtility.FromJson <VoiceMsgPush>(data.ToString()); DispatchEvent("voice_msg", vm); }); pc.on("start_club_room", data => { }); pc.on("club_room_updated", data => { DispatchEvent("club_room_updated", data); }); pc.on("clu_room_removed", data => { DispatchEvent("clu_room_removed", data); }); pc.on("club_message_notify", data => { ClubMessageNotify ret = JsonUtility.FromJson <ClubMessageNotify>(data.ToString()); sclub_message_notify = ret; DispatchEvent("club_message_notify", ret); }); pc.on("sys_message_updated", data => { DispatchEvent("sys_message_updated", data); }); pc.on("recommend_room_updated", data => { Debug.Log("recommend_room_updated"); DispatchEvent("recommend_room_updated", data); }); }
void onBtnExit(int club_id) { GameAlert.Show("确定退出俱乐部吗?", () => { doExit(club_id); }, true); }
void showRooms() { int cnt = mRooms.Count; NetMgr nm = NetMgr.GetInstance(); int uid = GameMgr.getUserMgr().userid; for (int i = 0; i < mRooms.Count; i++) { ClubRoomInfo room = mRooms [i]; Transform item = getItem(i); Transform seats = item.Find("seats"); bool found = false; int readys = 0; int nplayers = 0; bool idle = room.status == "idle"; int j = 0; for (; j < room.players.Count && j < seats.childCount; j++) { ClubRoomPlayer p = room.players [j]; Transform s = seats.GetChild(j); GameObject name = s.Find("name").gameObject; GameObject ready = s.Find("ready").gameObject; GameObject id = s.Find("id").gameObject; GameObject icon = s.Find("icon").gameObject; GameObject btn_kick = s.Find("btn_kick").gameObject; bool empty = p.id == 0; s.gameObject.SetActive(true); setActive(s, "icon", !empty); setActive(s, "name", !empty); setActive(s, "id", !empty); setActive(s, "ready", !empty && p.ready); setActive(s, "btn_kick", !empty && idle); if (!empty && idle) { setBtnEvent(s, "btn_kick", () => { onBtnKick(p.id, room.id, room.room_tag); }); } if (empty) { continue; } nplayers += 1; if (p.ready) { readys += 1; } setText(s, "name", p.name); setText(s, "id", "" + p.id); setIcon(s, "icon", p.id); if (p.id == uid) { mRoomID = room.id; } } for (int k = j; k < seats.childCount; k++) { Transform s = seats.GetChild(k); s.gameObject.SetActive(false); } ClubRoomBaseInfo info = room.base_info; setText(item, "desc", info.huafen + "/" + info.huafen + (info.maima ? "带苍蝇" : "不带苍蝇") + info.maxGames + "局"); setText(item, "progress", room.num_of_turns + " / " + info.maxGames); setText(item, "roomid", "ID:" + room.id); setText(item, "status", idle ? "开始" : "游戏中"); Transform btn_play = item.Find("btn_play"); btn_play.GetComponent <SpriteMgr> ().setIndex(idle ? 0 : 1); PUtils.onClick(btn_play, () => { if (room.status == "idle") { if (readys != info.numOfSeats) { GameAlert.Show("玩家没有全部准备"); return; } nm.request_connector("start_room", "room_tag", room.room_tag, data => { NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString()); if (ret.errcode != 0) { Debug.Log("start room fail"); return; } refresh(); }); } else { nm.request_connector("stop_room", "room_tag", room.room_tag, data => { NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString()); if (ret.errcode != 0) { Debug.Log("stop room fail"); return; } refresh(); }); } }); setActive(item, "btn_edit", idle && nplayers == 0); setBtnEvent(item, "btn_edit", () => { EditRoom er = getPage <EditRoom>("PEditRoom"); er.UpdateEvents += refresh; er.enter(room); }); setActive(item, "btn_destroy", idle && nplayers == 0); setBtnEvent(item, "btn_destroy", () => { GameAlert.Show("确定解散房间吗?", () => { JsonObject ob = new JsonObject(); ob["roomid"] = room.id; ob["room_tag"] = room.room_tag; ob["club_id"] = room.club_id; nm.request_apis("destroy_club_room", ob, data => { NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString()); if (ret.errcode != 0) { Debug.Log("destroy club room fail"); return; } refresh(); }); }, true); }); } updateItems(mRooms.Count); }