public override void SetDataSummary(EsObject obj) { Debug.LogWarning(username + " : " + obj); if (obj.variableExists("disconnected")) { summary.disconnected = obj.getBoolean("disconnected"); summaryTLMN.disconnectedTLMN = obj.getBoolean("disconnected"); } if (obj.variableExists("moneyExchange")) { long.TryParse(obj.getString("moneyExchange"), out summaryTLMN.moneyExchangeTLMN); } if (obj.variableExists("sumPoint")) { summary.sumPoint = obj.getInteger("sumPoint"); summaryTLMN.sumPointTLMN = obj.getInteger("sumPoint"); } if (obj.variableExists("pointLoss")) { summaryTLMN.pointLoss = obj.getInteger("pointLoss"); } if (obj.variableExists("sumRank")) { summary.sumRank = obj.getInteger("sumRank"); summaryTLMN.sumRankTLMN = obj.getInteger("sumRank"); } if (obj.variableExists("hand")) { summary.inHand = new List <int>(obj.getIntegerArray("hand")); summaryTLMN.inHandTLMN = new List <int>(obj.getIntegerArray("hand")); } }
public void OnBettingValueChange(EsObject eso) { if (eso.variableExists("valid")) { btnJoinBet.gameObject.collider.enabled = eso.getBoolean("valid"); btnChangeBet.gameObject.collider.enabled = eso.getBoolean("valid"); if (!eso.getBoolean("valid")) { btnJoinBet.gameObject.GetComponentInChildren <UISprite>().color = new Color(1f, 1f, 1f, 90f / 255f); btnChangeBet.gameObject.GetComponentInChildren <UISprite>().color = new Color(1f, 1f, 1f, 90f / 255f); } else { btnJoinBet.gameObject.GetComponentInChildren <UISprite>().color = new Color(1f, 1f, 1f, 1f); btnChangeBet.gameObject.GetComponentInChildren <UISprite>().color = new Color(1f, 1f, 1f, 1f); } } if (eso.variableExists("bettings")) { InitUser(eso.getEsObjectArray("bettings")); } if (eso.variableExists("maxChipAllow")) { parent.maxChipAllow = eso.getLong("maxChipAllow"); } }
public void UpdateData(EsObject obj) { if (obj.variableExists("config")) { this.lobby = new LobbyPhom(obj); } else { if (obj.variableExists("gameId")) { this.lobby.gameId = obj.getInteger("gameId"); } if (obj.variableExists("description")) { this.lobby.nameLobby = obj.getString("description"); } if (obj.variableExists("maximumPlayers")) { this.lobby.maxNumberPlayer = obj.getInteger("maximumPlayers"); } if (obj.variableExists("numberUsers")) { this.lobby.numberUserInRoom = obj.getInteger("numberUsers"); } if (obj.variableExists("betting")) { this.lobby.betting = obj.getInteger("betting"); } if (obj.variableExists("gameIndex")) { this.lobby.gameIndex = obj.getInteger("gameIndex"); } if (obj.variableExists("password")) { this.lobby.isPassword = obj.getBoolean("password"); } if (obj.variableExists("gamePlaying")) { this.lobby.gamePlaying = obj.getBoolean("gamePlaying"); } } // this.lobby = lobby; numberPlayer.SetValue(lobby.numberUserInRoom); UpdateImageLock(lobby); }
/// <summary> /// Khởi tạo cho gift qua đối tượng esobject /// </summary> public Announcement(EsObject eso) { //this.index = index; //this.description = description; this.money = eso.getInteger("moneyGift"); type = Type.Gift; this.currentDay = eso.getBoolean("currentDate"); }
public void SetingConfig(EsObject esConfig) { if (esConfig.variableExists(DEFINE_LOBBY_NAME)) { nameLobby = esConfig.getString(DEFINE_LOBBY_NAME); } if (esConfig.variableExists(DEFINE_BETTING)) { betting = esConfig.getInteger(DEFINE_BETTING); } if (esConfig.variableExists(DEFINE_INVITED_USERS)) { invitedUsers = esConfig.getStringArray(DEFINE_INVITED_USERS); } GameConfig config = new GameConfig( esConfig.variableExists(DEFINE_GAME_TYPE_TLMN) ? esConfig.getInteger(DEFINE_GAME_TYPE_TLMN) : 0, esConfig.variableExists(DEFINE_USING_CHATCHONG_RULE) ? esConfig.getBoolean(DEFINE_USING_CHATCHONG_RULE) : false, esConfig.variableExists(DEFINE_USING_TYPE_RULE) ? esConfig.getBoolean(DEFINE_USING_TYPE_RULE) : false, esConfig.variableExists(DEFINE_USING_U_TRON_RULE) ? esConfig.getBoolean(DEFINE_USING_U_TRON_RULE) : false, esConfig.variableExists(DEFINE_USING_U_XUONG_RULE) ? esConfig.getBoolean(DEFINE_USING_U_XUONG_RULE) : false, esConfig.variableExists(DEFINE_USING_XAO_KHAN_RULE) ? esConfig.getBoolean(DEFINE_USING_XAO_KHAN_RULE) : false, esConfig.variableExists(DEFINE_USING_DEN_CHONG_RULE) ? esConfig.getBoolean(DEFINE_USING_DEN_CHONG_RULE) : false, esConfig.variableExists(DEFINE_USING_CHOT_CHONG_RULE) ? esConfig.getBoolean(DEFINE_USING_CHOT_CHONG_RULE) : false); if (esConfig.variableExists(DEFINE_LOBBY_PASWORD)) { config.password = esConfig.getString(DEFINE_LOBBY_PASWORD); } this.config = config; }
public void SetDataChannelLobby(EsObject obj) { base.SetDataRoom(obj); if (obj.variableExists("gameId")) { gameId = obj.getInteger("gameId"); } if (obj.variableExists("description")) { nameLobby = obj.getString("description"); } if (obj.variableExists("maximumPlayers")) { maxNumberPlayer = obj.getInteger("maximumPlayers"); } if (obj.variableExists("numberUsers")) { numberUserInRoom = obj.getInteger("numberUsers"); } if (obj.variableExists("betting")) { betting = obj.getInteger("betting"); } if (obj.variableExists("gameIndex")) { gameIndex = obj.getInteger("gameIndex"); } isPassword = false; if (obj.variableExists("password")) { isPassword = obj.getBoolean("password"); } if (obj.variableExists("config")) { SetingConfig(obj.getEsObject("config")); } if (obj.variableExists("gamePlaying")) { gamePlaying = obj.getBoolean("gamePlaying"); } }
public void SetingConfig(EsObject esConfig) { if (esConfig.variableExists(DEFINE_LOBBY_NAME)) { nameLobby = esConfig.getString(DEFINE_LOBBY_NAME); } if (esConfig.variableExists(DEFINE_BETTING)) { betting = esConfig.getInteger(DEFINE_BETTING); } if (esConfig.variableExists(DEFINE_INVITED_USERS)) { invitedUsers = esConfig.getStringArray(DEFINE_INVITED_USERS); } if (esConfig.variableExists(DEFINE_PLAY_ACTION_TIME)) { timePlay = esConfig.getInteger(DEFINE_PLAY_ACTION_TIME); } if (esConfig.variableExists(DEFINE_USING_AUTO_BAT_BAO)) { autoBatBao = esConfig.getBoolean(DEFINE_USING_AUTO_BAT_BAO); } if (esConfig.variableExists(DEFINE_USING_AUTO_U)) { autoU = esConfig.getBoolean(DEFINE_USING_AUTO_U); } if (esConfig.variableExists(DEFINE_USING_NUOI_GA)) { ruleGa = (EGaRule)esConfig.getInteger(DEFINE_USING_NUOI_GA); } GameConfig config = new GameConfig( esConfig.getInteger(DEFINE_RULE_FULL_PLAYING), esConfig.getInteger(DEFINE_USING_NUOI_GA), esConfig.getBoolean(DEFINE_USING_AUTO_BAT_BAO), esConfig.getInteger(DEFINE_PLAY_ACTION_TIME), esConfig.getBoolean(DEFINE_USING_AUTO_U)); if (esConfig.variableExists(DEFINE_LOBBY_PASWORD)) { config.password = esConfig.getString(DEFINE_LOBBY_PASWORD); } this.config = config; }
public Messages(EsObject eso) { if (eso.variableExists("id")) { //id = eso.getInteger("id"); id = eso.getString("id"); } if (eso.variableExists("sender")) { sender = eso.getInteger("sender"); } if (eso.variableExists("sender_name")) { sender_name = eso.getString("sender_name"); } if (eso.variableExists("receiver")) { receiver = eso.getInteger("receiver"); } if (eso.variableExists("receiver_name")) { receiver_name = eso.getString("receiver_name"); } if (eso.variableExists("content")) { content = eso.getString("content"); } if (eso.variableExists("time_sent")) { time_sent = DateTime.Parse(eso.getString("time_sent")); } if (eso.variableExists("read")) { read = eso.getBoolean("read"); } if (eso.variableExists("status")) { status = eso.getInteger("status"); } if (eso.variableExists("sender_avatar")) { sender_avatar = eso.getInteger("sender_avatar"); } if (eso.variableExists("receiver_avatar")) { receiver_avatar = eso.getInteger("receiver_avatar"); } if (eso.variableExists("type")) { type = eso.getInteger("type"); } }
void OnProcessPulginResponse(string command, string action, EsObject eso) { if (command == "checkUser") { if (eso.getBoolean("exist") == false) { NotificationView.ShowMessage("Người chơi không tồn tại.", 5f); return; } FindFriend(transform.GetComponentInChildren <PrefabMessageTabbarControllerView>().txtFindOtherFriend.value, eso.getInteger("avatar")); } }
void SetDataOther(EsObject obj) { if (obj.variableExists("isMaster")) { isMaster = obj.getBoolean("isMaster"); } if (obj.variableExists("slotIndex")) { slotServer = obj.getInteger("slotIndex"); } if (obj.variableExists("playerState")) { PlayerState = ConvertPlayerState(obj.getString("playerState")); } if (obj.variableExists("handSize")) { handSize = obj.getInteger("handSize"); } if (obj.variableExists("isVirtualPlayer")) { isVirtualPlayer = obj.getBoolean("isVirtualPlayer"); } }
private void OnProcessPluginMessage(string command, string action, EsObject Parameters) { WaitingView.Instance.Close(); if (command == Fields.REQUEST.COMMAND_REGISTERTOURNAMENT) { string message = ""; if (Parameters.variableExists("message")) { message = Parameters.getString("message"); } if (Parameters.getBoolean("result")) { TournamentView.Instance.btnRegister.gameObject.SetActive(false); TournamentView.Instance.detail.lblTournamentStatus.gameObject.SetActive(true); TournamentView.Instance.currentShow.info.isRegister = true; GameObject.Destroy(gameObject); // NGUITools.SetActive(TableTournament, true); // NGUITools.SetActive(RegisterForm, false); // GameManager.Server.DoRequestPlugin(Utility.SetEsObject(Fields.REQUEST.COMMAND_GETGENERAL, //new object[] { "id", this.tournamentInfo.tournamentId })); } if (!string.IsNullOrEmpty(message)) { NotificationView.ShowMessage(message); } } if (command == Fields.REQUEST.COMMAND_GETLISTREGISTER) { EsObject[] esObject = Parameters.getEsObjectArray("users"); for (int i = 0; i < esObject.Length; i++) { users.Add(UserTournament.Create(esObject[i], gridUser.transform, userTournamentPrefab)); } gridUser.Reposition(); } if (command == Fields.REQUEST.COMMAND_GETGENERAL) { EsObject[] esObject = Parameters.getEsObjectArray("rounds"); round1.SetData(esObject[0]); round2.SetData(esObject[1]); roud3.SetData(esObject[2]); round4.SetData(esObject[3]); } if (command == Fields.REQUEST.COMMAND_MATCH_LIST) { PopupTournament.Create(Parameters); } }
public override void SetDataSummary(EsObject obj) { if (obj.variableExists("disconnected")) { summary.disconnected = obj.getBoolean("disconnected"); } if (obj.variableExists("moneyExchange")) { long.TryParse(obj.getString("moneyExchange"), out summary.moneyExchange); } if (obj.variableExists("sumPoint")) { summary.sumPoint = obj.getInteger("sumPoint"); } if (obj.variableExists("sumRank")) { summary.sumRank = obj.getInteger("sumRank"); } if (obj.variableExists("hand")) { summary.inHand = new List <int>(obj.getIntegerArray("hand")); } }
public void handleTurnAnnouncement(EsObject obj) { audio.Play(); String playerName = obj.getString(GameConstants.PLAYER_NAME); int seconds = obj.getInteger(GameConstants.TURN_TIME_LIMIT); if (null != clock) { clock.SetTimer(seconds); } bool isBlack = obj.getBoolean(GameConstants.COLOR_IS_BLACK); int[] legalMoves = obj.getIntegerArray(GameConstants.LEGAL_MOVES); clearLegalMoves(); if (playerName == (me)) { // it's my turn! if (myColor < 0) { myColor = GameConstants.BLACK; if (!isBlack) { myColor = GameConstants.WHITE; } } setLegalMoves(legalMoves); canClick = true; errorMessage = ""; } else { canClick = false; } if (isBlack) { waitingMessage = playerName + "'s turn: Black"; } else { waitingMessage = playerName + "'s turn: White"; } }
void ProcessGeneral(string command, string action, EsObject eso) { if (command == Fields.RESPONSE.CREATE_GAME) { #region CREATE_GAME if (eso.getBoolean("successful")) { GameManager.Instance.selectedLobby.SetDataJoinLobby(eso); } else { NotificationView.ShowMessage("Lỗi! Tạo bàn chơi không thành công.", 3f); } #endregion } else if (command == "joinGame") { #region JOIN GAME if (EventLoadSence != null) { EventLoadSence(); } GameManager.Instance.selectedLobby.SetDataJoinLobby(eso); WaitingView.Hide(); PlaySameDevice.SaveDeviceWhenJoinGame(); #endregion } else if (command == "removeFriend") { #region REMOVE FRIEND EsObject obj = eso.getEsObject("user"); User pendingUser = GameManager.Instance.mInfo.pendingBuddies.Find(user => user.username == (obj.variableExists("username") ? obj.getString("username") : obj.getString(Fields.PLAYER.USERNAME))); if (pendingUser != null) { GameManager.Instance.mInfo.pendingBuddies.Remove(pendingUser); if (EventFriendPendingChanged != null) { EventFriendPendingChanged(pendingUser, true); } } else { pendingUser = GameManager.Instance.mInfo.buddies.Find(user => user.username == (obj.variableExists("username") ? obj.getString("username") : obj.getString(Fields.PLAYER.USERNAME))); GameManager.Instance.mInfo.buddies.Remove(pendingUser); if (EventFriendChanged != null) { EventFriendChanged(pendingUser, true); } } #endregion } else if (command == "acceptFriendRequest") { #region ACCEPT FRIEND REQUEST EsObject obj = eso.getEsObject("user"); User user = new User(obj); if (GameManager.Instance.mInfo.requestBuddies.Find(u => u.username == user.username) != null) { GameManager.Instance.mInfo.requestBuddies.Remove(GameManager.Instance.mInfo.requestBuddies.Find(u => u.username == user.username)); } if (GameManager.Instance.mInfo.buddies.Find(u => u.username == user.username) == null) { User pendingUser = GameManager.Instance.mInfo.pendingBuddies.Find(u => u.username == user.username); if (pendingUser != null) { GameManager.Instance.mInfo.pendingBuddies.Remove(pendingUser); } GameManager.Instance.mInfo.buddies.Add(user); if (EventFriendChanged != null) { EventFriendChanged(user, false); } } #endregion } else if (command == "friendRequest") { #region FRIEND REQUEST EsObject obj = eso.getEsObject("user"); User user = new User(obj); GameManager.Instance.mInfo.pendingBuddies.Add(user); if (EventFriendPendingChanged != null) { EventFriendPendingChanged(user, false); } #endregion } else if (command == "inComingMessage") { #region INCOME MESSAGE Messages message = new Messages(eso.getEsObject("message")); GameManager.Instance.mInfo.messages.Add(message); RegisterEventMessageChanged(message, false); #endregion } else if (command == "outGoingMessage") { #region OUT GOING MESSAGE Messages mess = new Messages(); mess.SetDataOutGoing(eso); GameManager.Instance.mInfo.messages.Add(mess); RegisterEventMessageChanged(mess, true); #endregion } else if (command == "systemMessage") { #region SYSTEM MESSAGE Messages message = new Messages(eso.getEsObject("message")); message.sender = 0; message.read = false; message.receiver = GameManager.Instance.mInfo.id; message.receiver_name = GameManager.Instance.mInfo.username; MessageSystemCache.SaveCache(new Hashtable[] { message.ParseToHashtable }); if (message.type != 0) { ServerMessagesView.MessageServer(message.content); } else { RegisterEventMessageChanged(message, false); } #endregion } else if (command == "invitePlayGame") { #region INVITE PLAY GAME string actionInvited = "joinGame"; if (eso.variableExists("action")) { actionInvited = eso.getString("action"); } if (actionInvited == "createGame") { NotificationView.ShowConfirm("Xác nhận", "Bạn có muốn tạo phòng mới hay không?", delegate() { GameManager.Server.DoRequestPlugin(Utility.SetEsObject(Fields.RESPONSE.CREATE_GAME, new object[] { "config", createRoom() })); }, delegate() { GameManager.Server.DoRequestCommand("abortInvitation"); }); } else { #region INVITE PLAYER string userName = eso.getString(Fields.PLAYER.USERNAME); int gameId = eso.getInteger("gameId"); string password = eso.variableExists("password") ? eso.getString("password") : ""; if (password.Length == 0 && eso.variableExists("config")) { EsObject esoConfig = eso.getEsObject("config"); if (esoConfig.variableExists("password")) { password = esoConfig.getString("password"); } } int roomId = eso.getInteger("roomId"); int zoneId = eso.getInteger("zoneId"); int gameIndex = eso.getInteger("gameIndex"); if (GameManager.CurrentScene == ESceneName.LobbyChan || GameManager.CurrentScene == ESceneName.LobbyPhom || GameManager.CurrentScene == ESceneName.LobbyTLMN) { string contentMsg = "Bạn nhận được một lời mời chơi!"; if (userName.Length > 0) { contentMsg = "\"" + Utility.Convert.ToTitleCase(userName) + "\" gửi bạn một lời mời tham gia vào bàn chơi số " + gameIndex + ".\n\n"; } NotificationView.ShowConfirm("Mời chơi", contentMsg, delegate() { //GameManager.Instance.selectedLobby = GameManager.CurrentScene == ESceneName.LobbyChan ? new LobbyChan(zoneId, roomId, gameId) : GameManager.CurrentScene == ESceneName.LobbyPhom ? new LobbyPhom(zoneId, roomId, gameId) : new LobbyTLMN(zoneId, roomId, gameId); if (GameManager.CurrentScene == ESceneName.LobbyPhom) { GameManager.Instance.selectedLobby = new LobbyPhom(zoneId, roomId, gameId); } else if (GameManager.CurrentScene == ESceneName.LobbyChan) { GameManager.Instance.selectedLobby = new LobbyChan(zoneId, roomId, gameId); } else { GameManager.Instance.selectedLobby = new LobbyTLMN(zoneId, roomId, gameId); } GameManager.Server.DoJoinGame(password); }, delegate() { GameManager.Server.DoRequestCommand("abortInvitation"); }); } #endregion } #endregion } else if (command == "updateUserInfo") { #region CẬP NHẬT THÔNG TIN USERS if (eso.variableExists("userName") && eso.getString("userName") == GameManager.Instance.mInfo.username) { if (eso.variableExists("field")) { string field = eso.getString("field"); if (field == "money") { string moneyType = ""; if (eso.variableExists("moneyType")) { moneyType = eso.getString("moneyType"); } if (moneyType != "" && moneyType == "chip") { long.TryParse(eso.getString("value"), out GameManager.Instance.mInfo.chip); } else if (moneyType != "" && moneyType == "gold") { long.TryParse(eso.getString("value"), out GameManager.Instance.mInfo.gold); } } else if (field == "experience") { GameManager.Instance.mInfo.SetDataUser(eso.getEsObject("userInfo")); } if (EventUpdateUserInfo != null) { EventUpdateUserInfo(); } } } else if (eso.variableExists("userName") && eso.getString("userName") != GameManager.Instance.mInfo.username) { if (GameManager.CurrentScene == ESceneName.GameplayChan && eso.variableExists("field")) { string field = eso.getString("field"); if (field == "experience") { if (GameModelChan.GetPlayer(eso.getString("userName")) != null) { GameModelChan.GetPlayer(eso.getString("userName")).SetDataUser(eso.getEsObject("userInfo")); } } } } #endregion } else if (command == "updateConfigClient") { #region CẬP NHẬT THÔNG TIN CONFIG if (eso.variableExists("config")) { IDictionary obj = (IDictionary)JSON.JsonDecode(eso.getString("config")); string type = obj[Fields.CONFIGCLIENT.KEY_TYPE_REAL_TIME].ToString(); switch (type) { case Fields.CONFIGCLIENT.VALUE_ADS: Announcement announce = new Announcement( Convert.ToInt32(obj["index"]), obj["description"].ToString(), obj["scenes"].ToString() == "lobby" ? Announcement.Scene.lobby : obj["scenes"].ToString() == "login" ? Announcement.Scene.login : Announcement.Scene.announce, obj["url"].ToString(), obj["image"].ToString(), obj["type"].ToString() == "Ads" ? Announcement.Type.Advertisement : Announcement.Type.Event ); GameManager.Instance.ListAnnouncement.Remove(GameManager.Instance.ListAnnouncement.Find(ads => ads.show == announce.show && ads.type == Announcement.Type.Advertisement)); GameManager.Instance.ListAnnouncement.Add(announce); if (EventAdsChanged != null) { EventAdsChanged(obj); } break; case Fields.CONFIGCLIENT.VALUE_HELP: StoreGame.Remove(StoreGame.EType.CACHE_HELP); GameManager.Instance.ListHelp.Clear(); StoreGame.SaveString(StoreGame.EType.CACHE_HELP, JSON.JsonEncode(obj[Fields.RESPONSE.PHP_RESPONSE_ITEMS])); ArrayList list = (ArrayList)obj[Fields.RESPONSE.PHP_RESPONSE_ITEMS]; foreach (Hashtable item in list) { GameManager.Instance.ListHelp.Add(item); } if (EventHelpChanged != null) { EventHelpChanged(obj); } break; case Fields.CONFIGCLIENT.VALUE_CONFIG_CLIENT: ArrayList items = (ArrayList)obj[Fields.RESPONSE.PHP_RESPONSE_ITEMS]; foreach (Hashtable item in items) { GameManager.Setting.Platform.AddOrUpdatePlatformConfig(item); } if (GameManager.Setting.Platform.GetConfigByType(PlatformType.url_ping) != null) { ServerWeb.URL_PING = GameManager.Setting.Platform.GetConfigByType(PlatformType.url_ping).Value; } if (EventConfigClientChanged != null) { EventConfigClientChanged(obj); } break; } } #endregion } else if (command == Fields.RESPONSE.DAYLY_GIFT) { #region Thông tin trả về khi nhận quà tặng //AnnouncementView.Instance.Close(); if (eso.variableExists("textNotification")) { if (GameObject.Find("__Announcement") != null) { AnnouncementView.Instance.SetCenterOnNextCurrentDay(); } GameManager.Instance.FunctionDelay(delegate() { string text = eso.getString("textNotification"); NotificationView.ShowMessage(text); }, 1f); GameManager.Instance.ListAnnouncement.RemoveAll(a => a.show == Announcement.Scene.announce && a.type == Announcement.Type.Gift); } #endregion } else if (command == Fields.RESPONSE.GET_MESSAGE) { #region LẤY THÔNG TIN TIN NHẮN TỪ SERVER WaitingView.Hide(); //disable total count khi chưa load messeage this.totalMesseageCount = -1; if (eso.variableExists("messages")) { EsObject[] array = eso.getEsObjectArray("messages"); System.Array.ForEach <EsObject>(array, o => { GameManager.Instance.mInfo.messages.Add(new Messages(o)); }); List <Messages> systemMessage = GameManager.Instance.mInfo.messages.FindAll(m => m.sender == 0); GameManager.Instance.ListMessageSystem.Clear(); while (systemMessage.Count > 0) { GameManager.Instance.ListMessageSystem.Add(systemMessage[0]); GameManager.Instance.mInfo.messages.Remove(systemMessage[0]); systemMessage.RemoveAt(0); } if (EventGetMessageCallBack != null) { EventGetMessageCallBack(); } } #endregion } else if (command == Fields.RESPONSE.GET_BUDDIES) { #region LẤY THÔNG TIN DANH SÁCH BẠN BÈ WaitingView.Hide(); GameManager.Instance.mInfo.SetDataUser(eso); if (EventGetBuddiesCallBack != null) { EventGetBuddiesCallBack(); } #endregion } else if (command == "getLevel") { if (eso.variableExists("level")) { GameManager.Instance.mInfo.level = eso.getInteger("level"); } if (eso.variableExists("experience")) { GameManager.Instance.mInfo.experience = eso.getInteger("experience"); } if (eso.variableExists("expMinCurrentLevel")) { GameManager.Instance.mInfo.expMinCurrentLevel = eso.getInteger("expMinCurrentLevel"); } if (eso.variableExists("expMinNextLevel")) { GameManager.Instance.mInfo.expMinNextLevel = eso.getInteger("expMinNextLevel"); } } }
void PluginMessageOnProcess(string command, string action, EsObject PluginMessageParameters) { if (command == Fields.RESPONSE.LOGIN_RESPONSE) { Debug.Log("OnLoginResponse " + PluginMessageParameters); Debug.Log("Đã nhận được thông tin server"); EsObject esoResponce = PluginMessageParameters; if (esoResponce.getBoolean("loginResult")) { if (esoResponce.variableExists("gifts")) { EsObject[] esoGifts = esoResponce.getEsObjectArray("gifts"); int index = Array.FindIndex(esoGifts, eI => eI.getBoolean("currentDate") == true); if (esoGifts.Length > 0) { for (int i = 0; i < esoGifts.Length; i++) { Announcement ann = new Announcement(esoGifts[i]); ann.index = i; ann.description = "Ngày " + (i + 1); if (i < index) { ann.receivered = true; } GameManager.Instance.ListAnnouncement.Add(ann); } } } if (esoResponce.variableExists("countUnReadMessage")) { GameManager.Server.totalMesseageCount = esoResponce.getInteger("countUnReadMessage"); } GameManager.Setting.BroadcastMessage = esoResponce.getString("broadCastMessage"); //GameManager.Instance.channelRoom = new RoomInfo(esoResponce.getEsObject("firstRoomToJoin")); GameManager.Instance.hallRoom = new RoomInfo(esoResponce.getEsObject("firstRoomToJoin")); GameManager.Instance.mInfo = new User(esoResponce.getEsObject("userInfo")); if (esoResponce.variableExists("ceo_chan")) { Common.RULE_CHIP_COMPARE_BETTING = esoResponce.getInteger("ceo_chan"); } if (esoResponce.variableExists("pingRequire")) { GameManager.Setting.IsPingRequire = esoResponce.getBoolean("pingRequire"); } if (esoResponce.variableExists("gameRoom")) { ((LobbyChan)GameManager.Instance.selectedLobby).SetDataJoinLobby(esoResponce.getEsObject("gameRoom")); GameManager.Instance.selectedChannel.SetDataRoom(esoResponce.getEsObject("gameRoom").getEsObject("gameDetails").getEsObject("parent")); GameManager.Instance.currentRoom = new RoomInfo(GameManager.Instance.hallRoom.zoneId, GameManager.Instance.hallRoom.roomId); GameManager.Server.DoJoinGame(((LobbyChan)GameManager.Instance.selectedLobby).config.password); GameManager.LoadScene(ESceneName.GameplayChan); return; } ServerWeb.StartThread(ServerWeb.URL_REQUEST_USER, new object[] { "username", GameManager.Instance.mInfo.username }, delegate(bool isDone, WWW res, IDictionary json) { }); GameManager.Instance.mInfo.password = lablePassword.value; GameManager.Server.DoJoinRoom(GameManager.Instance.hallRoom.zoneId, GameManager.Instance.hallRoom.roomId); #if UNITY_WEBPLAYER if (!hasAccessToken) { Application.ExternalEval("ajaxLoginUnity(\"" + GameManager.Instance.userNameLogin + "\", \"" + GameManager.Instance.passwordLogin + "\");"); } #endif if (!cbSavePass.value) { StoreGame.Remove(StoreGame.EType.SAVE_USERNAME); StoreGame.Remove(StoreGame.EType.SAVE_PASSWORD); StoreGame.Remove(StoreGame.EType.SAVE_ACCESSTOKEN); GameManager.Instance.userNameLogin = GameManager.Instance.passwordLogin = GameManager.Instance.accessToken = ""; } else { StoreGame.SaveString(StoreGame.EType.SAVE_USERNAME, GameManager.Instance.userNameLogin); StoreGame.SaveString(StoreGame.EType.SAVE_PASSWORD, GameManager.Instance.passwordLogin); StoreGame.SaveString(StoreGame.EType.SAVE_ACCESSTOKEN, GameManager.Instance.accessToken); } } else { Debug.Log("Login false"); IsClickButtonLogin = false; StoreGame.Remove(StoreGame.EType.SAVE_USERNAME); StoreGame.Remove(StoreGame.EType.SAVE_PASSWORD); StoreGame.Remove(StoreGame.EType.SAVE_ACCESSTOKEN); GameManager.Instance.userNameLogin = GameManager.Instance.passwordLogin = GameManager.Instance.accessToken = ""; string message = "Thông tin đăng nhập không hợp lệ. Yêu cầu nhập lại thông tin truy cập."; if (!string.IsNullOrEmpty(esoResponce.getString("reason"))) { message = esoResponce.getString("reason"); } NotificationView.ShowMessage(message); } } WaitingView.Instance.Close(); }
public TournamentInfo(EsObject es) { zoneId = roomId = -1; if (es.variableExists("id")) { this.tournamentId = es.getInteger("id"); } if (es.variableExists("roomId")) { this.roomId = es.getInteger("roomId"); } if (es.variableExists("zoneId")) { this.zoneId = es.getInteger("zoneId"); } if (es.variableExists("displayName")) { this.tournamentName = es.getString("displayName"); } if (es.variableExists("description")) { this.decription = es.getString("description"); } if (es.variableExists("startTimeRegistration")) { startDate = es.getString("startTimeRegistration"); } if (es.variableExists("endTimeRegistration")) { endDate = es.getString("endTimeRegistration"); } if (es.variableExists("startTime")) { startDate = es.getString("startTime"); } if (es.variableExists("config")) { SetConfig((IDictionary)JSON.JsonDecode(es.getString("config"))); } if (es.variableExists("maxPlayers")) { this.maxPlayers = es.getInteger("maxPlayers"); } if (es.variableExists("remainStartTime")) { this.remainStartTime = es.getLong("remainStartTime"); } if (es.variableExists("isRegister")) { this.isRegister = es.getBoolean("isRegister"); } if (es.variableExists("numPlayersRegister")) { this.numPlayersRegister = es.getInteger("numPlayersRegister"); } if (es.variableExists("winner")) { EsObject obj = es.getEsObject("winner"); if (obj.variableExists("userName")) { this.userNameWin = obj.getString("userName"); } if (obj.variableExists("avatar")) { this.avatarWinner = obj.getString("avatar"); } } }
private void addOrUpdateOneChip(EsObject chipObj) { int id = chipObj.getInteger(GameConstants.ID); bool isBlack = chipObj.getBoolean(GameConstants.COLOR_IS_BLACK); int color = GameConstants.BLACK; if (!isBlack) { color = GameConstants.WHITE; } Chip chip = board[id]; chip.setColor(color); Debug.Log("addOrUpdateOneChip: " + id); }
void OnProcessPluginMessage(string command, string action, EsObject paremeters) { if (command == Fields.RESPONSE.FULL_UPDATE) { #region Lấy danh sách các lobby sau khi vào room LobbyRowTLMN.List.Clear(); EsObject[] children = paremeters.getEsObjectArray("children"); UIScrollView panel = parentListLobby.transform.parent.gameObject.GetComponent <UIScrollView>(); foreach (EsObject obj in children) { LobbyTLMN lobby = new LobbyTLMN(obj); LobbyRowTLMN.Create(panelLobbyRow, parentListLobby.transform, lobby); } if (children.Length > 0) { parentListLobby.repositionNow = true; } #endregion } else if (command == Fields.RESPONSE.LOBBY_ADD) { #region Có một lobby mới được tạo. EsObject es = paremeters.getEsObject("child"); UIScrollView panel = parentListLobby.transform.parent.gameObject.GetComponent <UIScrollView>(); LobbyRowTLMN.Create(panelLobbyRow, parentListLobby.transform, new LobbyTLMN(es)); parentListLobby.repositionNow = true; #endregion } else if (command == Fields.RESPONSE.LOBBY_UPDATE) { #region Có một lobby nào đó có thay đổi. EsObject es = paremeters.getEsObject("child"); LobbyRowTLMN row = LobbyRowTLMN.List.Find(o => o.lobby.gameId == es.getInteger("gameId")); if (row != null) { row.UpdateData(es); } #endregion } else if (command == Fields.RESPONSE.LOBBY_REMOVE) { #region Có một lobby nào đó thoát EsObject es = paremeters.getEsObject("child"); LobbyRowTLMN row = LobbyRowTLMN.List.Find(o => o.lobby.gameId == es.getInteger("gameId")); LobbyRowTLMN.Remove(row); parentListLobby.repositionNow = true; parentListUseOnline.repositionNow = true; #endregion } else if (command == Fields.REQUEST.GET_USER_ONLINE) { #region Lấy danh sách những người chơi đang online khi vào room UserOnlineRowTLMN.List.Clear(); EsObject[] children = paremeters.getEsObjectArray("users"); foreach (EsObject obj in children) { if (obj.getString(Fields.PLAYER.USERNAME) == GameManager.Instance.mInfo.username) { continue; } UserOnlineRowTLMN.Create(parentListUseOnline.transform, new User(obj)); } #endregion } else if (command == Fields.RESPONSE.USER_ONLINE_UPDATE) { #region Khi có người mới tham gia hoặc thoát ra khởi room if (action == "addUserOnline") { EsObject es = paremeters.getEsObject(Fields.PLAYER.USERNAME); if (es.getString(Fields.PLAYER.USERNAME) != GameManager.Instance.mInfo.username) { UserOnlineRowTLMN.Create(parentListUseOnline.transform, new User(es)); parentListLobby.repositionNow = true; parentListUseOnline.repositionNow = true; } } else if (action == "removeUserOnline") { EsObject es = paremeters.getEsObject(Fields.PLAYER.USERNAME); EUserOnlineRow row = UserOnlineRowTLMN.List.Find(o => o.user.username == es.getString(Fields.PLAYER.USERNAME)); if (row != null) { UserOnlineRowTLMN.Remove(row); parentListLobby.repositionNow = true; parentListUseOnline.repositionNow = true; } } #endregion } else if (command == "quickJoinGame") { #region Chơi nhanh int gameId = paremeters.getInteger("gameId"); if (gameId == -1) { NotificationView.ShowMessage("Hiện không có bàn chơi nào sẵn sàng.", 3f); } else { LobbyTLMN lobby = LobbyRowTLMN.List.Find(lb => lb.lobby.gameId == gameId).lobby; GameManager.Instance.selectedLobby = new LobbyTLMN(lobby.zoneId, lobby.roomId, lobby.gameId); if (PlaySameDevice.IsCanJoinGameplay) { GameManager.Server.DoJoinGame(""); } } #endregion } else if (command == "error") { int id = paremeters.getInteger("error"); if (id == 0) { Common.MessageRecharge("Bạn không đủ tiền để tham gia bàn chơi."); } else if (id == 1) { NotificationView.ShowMessage("Bàn chơi đã đủ người hoặc đã được thêm máy."); } else if (id == 2) { NotificationView.ShowMessage("Bạn đã bị đuổi khỏi bài chơi trước đó."); } else if (id == 4) { NotificationView.ShowMessage("Mật khẩu không chính xác.\n\nĐề nghị nhập lại."); } else if (id == 5) { string contentMsg = paremeters.getString("textNotification"); int gameId = paremeters.getInteger("gameId"); string password = paremeters.variableExists("password") ? paremeters.getString("password") : ""; NotificationView.ShowConfirm("Xác nhận", contentMsg, delegate() { GameManager.Instance.selectedLobby = new LobbyTLMN(gameId); GameManager.Server.DoJoinGame(password); }, null); } } else if (command == "tryCreateGame") { bool allowCreateRoom = paremeters.getBoolean("allowCreateGame"); if (allowCreateRoom) { if (CommonTLMN.ValidateChipToBetting(((ChannelTLMN)GameManager.Instance.selectedChannel).bettingValues[0])) { GameManager.LoadScene(ESceneName.CreateRoomTLMN); } else { Common.MessageRecharge("Bạn không đủ tiền để tạo bàn chơi."); } } else { string contentMsg = paremeters.getString("textNotification"); int gameId = paremeters.getInteger("gameId"); string password = paremeters.variableExists("password") ? paremeters.getString("password") : ""; NotificationView.ShowConfirm("Xác nhận", contentMsg, delegate() { GameManager.Instance.selectedLobby = new LobbyTLMN(gameId); GameManager.Server.DoJoinGame(password); }, null); } } }
public void SetDataChannelLobby(EsObject obj) { base.SetDataRoom(obj); if (obj.variableExists("gameId")) { gameId = obj.getInteger("gameId"); } if (obj.variableExists("description")) { nameLobby = obj.getString("description"); } if (obj.variableExists("maximumPlayers")) { maxNumberPlayer = obj.getInteger("maximumPlayers"); } if (obj.variableExists("numberUsers")) { numberUserInRoom = obj.getInteger("numberUsers"); } if (obj.variableExists("betting")) { betting = obj.getInteger("betting"); } if (obj.variableExists("playActionTime")) { timePlay = obj.getInteger("playActionTime"); } if (obj.variableExists("gameIndex")) { gameIndex = obj.getInteger("gameIndex"); } if (obj.variableExists("hasRobot")) { hasRobot = obj.getBoolean("hasRobot"); } isPassword = false; if (obj.variableExists("password")) { isPassword = obj.getBoolean("password"); } if (obj.variableExists("config")) { SetingConfig(obj.getEsObject("config")); } if (obj.variableExists("gamePlaying")) { gamePlaying = obj.getBoolean("gamePlaying"); } autoBatBao = false; if (obj.variableExists("usingAutoBatBaoRule")) { gamePlaying = obj.getBoolean("usingAutoBatBaoRule"); } autoU = false; if (obj.variableExists("usingAutoURule")) { gamePlaying = obj.getBoolean("usingAutoURule"); } if (obj.variableExists("usingNuoiGaRule")) { ruleGa = (EGaRule)obj.getInteger("usingNuoiGaRule"); } }