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 SetData(EsObject es) { if (es.variableExists("userId")) { this.userId = es.getInteger("userId"); } if (es.variableExists("userName")) { lblName.text = es.getString("userName"); } if (es.variableExists("avatar")) { this.avatarUrl = es.getString("avatar"); } if (es.variableExists("point")) { int point = es.getInteger("point"); lblPoint.text = point.ToString(); if (point > 0) { spPoint.spriteName = ""; } else { spPoint.spriteName = ""; } NGUITools.SetActive(spPoint.gameObject, true); } OnShowAvatar(); }
internal void ShowPreview(EsObject eso) { if (!eso.variableExists("next")) { next = -1; } else { next = eso.getInteger("next"); } if (!eso.variableExists("prev")) { previous = -1; } else { previous = eso.getInteger("prev"); } if (eso.variableExists("winner")) { winner = eso.getString("winner"); } if (eso.variableExists("bettings")) { InitUser(eso.getEsObjectArray("bettings")); } ShowOrHideButtonNext(); ShowOrHideButtonPrev(); }
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 InitUser(EsObject[] esoArr) { DestroyUser(); for (int i = 0; i < esoArr.Length; i++) { EsObject eso = esoArr[i]; PlayerBettingModel model = new PlayerBettingModel();; model.Player = GameModelChan.GetPlayer(eso.getString("userName")); if (model == null) { model = new PlayerBettingModel(); model.Player.username = eso.getString("userName"); } model.CardId = eso.getInteger("cardId"); if (winner == eso.getString("userName")) { model.IsWinner = true; } else { model.IsWinner = false; } model.ETypeLaying = (ETypeLayingBetting)eso.getInteger("gaNgoaiType"); model.ChipBetting = eso.getLong("value"); PlayerBettingView bettingView = PlayerBettingView.Create(model, tableUser.transform); listBettingPlayer.Add(bettingView); if (eso.getString("userName") == GameManager.Instance.mInfo.username) { bettingView.gameObject.name = "__0"; } } tableUser.repositionNow = true; // tableUser.Reposition(); SetCenterUITable(tableUser); GameManager.Instance.FunctionDelay(delegate() { foreach (PlayerBettingView pv in listBettingPlayer) { if (pv.model.IsWinner != null) { if (pv.model.IsWinner == true) { pv.iconChicken.gameObject.SetActive(true); } else { pv.lbMoney.gameObject.GetComponent <UILabel>().color = new Color(1f, 155f / 255f, 0f); ECardTexture texture1 = pv.gameObject.GetComponentInChildren <ECardTexture>(); texture1.card.SetColor(new Color(1f, 1f, 1f, 90f / 255f)); } } } }, 0.1f); }
public void InitUser(EsObject[] esoArr) { while (listBettingPlayer.Count > 0) { GameObject.Destroy(listBettingPlayer[0].gameObject); listBettingPlayer.RemoveAt(0); } for (int i = 0; i < esoArr.Length; i++) { EsObject eso = esoArr[i]; PlayerBettingModel model = new PlayerBettingModel(); model.Player = GameModelChan.GetPlayer(eso.getString("userName")); if (model.Player == null) { model.Player = new PlayerControllerChan(); model.Player.username = eso.getString("userName"); } if (!GameModelChan.game.dicUserBetting.ContainsKey(eso.getString("userName"))) { GameModelChan.game.dicUserBetting.Add(eso.getString("userName"), false); } model.CardId = eso.getInteger("cardId"); model.ETypeLaying = (ETypeLayingBetting)eso.getInteger("gaNgoaiType"); model.ChipBetting = eso.getLong("value"); PlayerBettingView bettingView = PlayerBettingView.Create(model, tableUser.transform); listBettingPlayer.Add(bettingView); if (eso.getString("userName") == GameManager.Instance.mInfo.username) { parent.model = model; ShowButonJoin(model); bettingView.gameObject.name = "__0"; } } tableUser.repositionNow = true; SetCenterUITable(tableUser); if (Array.Find <EsObject>(esoArr, eso => eso.getString("userName") == GameManager.Instance.mInfo.username) == null) { HideBothButton(); } GameManager.Instance.FunctionDelay(delegate() { foreach (PlayerBettingView view in listBettingPlayer) { if (GameModelChan.game.dicUserBetting.ContainsKey(view.model.Player.username) && GameModelChan.game.dicUserBetting[view.model.Player.username]) { view.iconChange.gameObject.SetActive(true); GameModelChan.game.dicUserBetting[view.model.Player.username] = false; } } }, 0.01f); }
public void SetData(EsObject es) { if (es.variableExists("result")) { lblResult.text = "Kết quả: " + es.getString("result"); } if (es.variableExists("gameId")) { gameId = es.getInteger("gameId"); } if (gameId <= 0) { //disable button view } if (es.variableExists("players")) { EsObject[] esObject = es.getEsObjectArray("players"); for (int i = 0; i < esObject.Length; i++) { GameObject obj = (GameObject)GameObject.Instantiate(popupUserPrefab); PopupUser user = obj.GetComponent <PopupUser>(); user.SetData(esObject[i]); obj.transform.parent = gridUser.transform; } } gridUser.Reposition(); }
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 SetData(EsObject es) { if (es.variableExists("id")) { this.userId = es.getInteger("id"); } if (es.variableExists("continuous")) { int state = es.getInteger("continuous"); switch (state) { case -1: avatar.color = Color.gray; break; case 1: NGUITools.SetActive(win.gameObject, true); break; default: break; } } if (es.variableExists("avatar")) { string urlavatar = es.getString("avatar"); if (string.IsNullOrEmpty(urlavatar)) { this.avatar.mainTexture = (Texture)Resources.Load("Images/Avatar/NoAvatar", typeof(Texture)); NGUITools.SetActive(this.avatar.gameObject, true); NGUITools.SetActive(defaultAvatar, false); } else { new AvatarCacheOrDownload(urlavatar, delegate(Texture image) { if (image != null) { this.avatar.mainTexture = image; NGUITools.SetActive(this.avatar.gameObject, true); NGUITools.SetActive(defaultAvatar, false); } }); } } }
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"); } }
void OnProcessPluginMessage(string command, string action, EsObject paremeters) { if (command == "error") { int id = paremeters.getInteger("error"); if (id == 5) { NotificationView.ShowMessage("Vui lòng chờ ván bài cũ của bạn kết thúc.\n\nTrước khi tạo bàn mới."); } } }
private void OnProcessPluginMessage(string command, string action, EsObject paremeters) { if (command == Fields.RESPONSE.COMMAND_TOURNAMENT) { EsObject[] esObject = paremeters.getEsObjectArray("tournaments"); for (int i = 0; i < esObject.Length; i++) { TournamentInfo info = new TournamentInfo(esObject[i]); GameObject obj = NGUITools.AddChild(gridTournament.gameObject, tournamentItemPrefab); obj.name = "Tournament" + info.tournamentId; TournamentItem item = obj.GetComponent <TournamentItem>(); item.UpdateInfo(info); tournamentItems.Add(item); } gridTournament.Reposition(); gridTournament.GetComponent <UICenterOnChild>().Recenter(); WaitingView.Instance.Close(); } if (command == "updateTournament") { if (paremeters.variableExists("tournamentId")) { int id = paremeters.getInteger("tournamentId"); TournamentItem item = this.tournamentItems.Find(x => x.info.tournamentId == id); if (item != null) { if (paremeters.variableExists("zoneId")) { item.info.zoneId = paremeters.getInteger("zoneId"); } if (paremeters.variableExists("roomId")) { item.info.roomId = paremeters.getInteger("roomId"); } } } NGUITools.SetActive(btnShow.gameObject, currentShow.info.roomId >= 0); } }
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"); } }
public static UserTournament Create(EsObject es, Transform parent, GameObject prefab) { GameObject obj = NGUITools.AddChild(parent.gameObject, prefab); UserTournament tour = obj.GetComponent <UserTournament>(); if (es.variableExists("userId")) { tour.userId = es.getInteger("userId"); } obj.name = "userTournament" + tour.userId; if (es.variableExists("userName")) { tour.userName = es.getString("userName"); } if (es.variableExists("timeRegister")) { tour.timeRegister = es.getString("timeRegister"); } if (es.variableExists("fullName")) { tour.fullName = es.getString("fullName"); } if (es.variableExists("level")) { tour.level = es.getInteger("level"); } if (es.variableExists("avatar")) { tour.avatarUrl = es.getString("avatar"); } if (es.variableExists("result")) { tour.result = es.getString("result"); } tour.SetData(); return(tour); }
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 HallInfo(EsObject es) { if (es.variableExists("childId")) { this.hallId = es.getInteger("childId"); } if (es.variableExists("roomName")) { this.roomName = es.getString("roomName"); } if (es.variableExists("zoneName")) { this.zoneName = es.getString("zoneName"); } if (es.variableExists("roomId")) { this.roomId = es.getInteger("roomId"); } if (es.variableExists("zoneId")) { this.zoneId = es.getInteger("zoneId"); } if (es.variableExists("description")) { this.decription = es.getString("description"); } if (es.variableExists("maximumPlayers")) { this.maximumPlayers = es.getInteger("maximumPlayers"); } if (es.variableExists("numberUsers")) { this.numberUsers = es.getInteger("numberUsers"); } if (es.variableExists("icon")) { this.icon = es.getString("icon"); } if (es.variableExists("logo")) { this.logo = es.getString("logo"); } if (es.variableExists("gameIndex")) { this.gameIndex = es.getInteger("gameIndex"); } if (es.variableExists("appId")) { this.gameId = es.getInteger("appId"); } }
public void SetData(EsObject es) { if (es.variableExists("id")) { this.roundId = es.getInteger("id"); } if (es.variableExists("name")) { this.roundName = es.getString("name"); } EsObject[] tables = es.getEsObjectArray("groups"); for (int i = 0; i < tables.Length; i++) { tableChampion[i].SetData(tables[i]); } }
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"); } }
public void SetData(EsObject es) { if (es.variableExists("id")) { this.tableId = es.getInteger("id"); } if (es.variableExists("name")) { tableName.text = es.getString("name"); } else { tableName.text = ""; } EsObject[] players = es.getEsObjectArray("players"); for (int i = 0; i < players.Length; i++) { userInTable[i].SetData(players[i]); } }
public void SetData(EsObject es) { if (es.variableExists("description")) { lbldecription.text = es.getString("description"); } if (es.variableExists("gameId")) { this.gameId = es.getInteger("gameId"); } if (gameId < 0) { btnView.gameObject.SetActive(false); } GameObject obj = (GameObject)GameObject.Instantiate(tablePrefab); PopupTable tableitem = obj.GetComponent <PopupTable>(); obj.transform.parent = gridTable.transform; tableitem.transform.localPosition = Vector3.zero; tableitem.transform.localScale = Vector3.one; tableitem.SetData(es); gridTable.Reposition(); }
public override void SetDataJoinLobby(EsObject obj) { SetDataChannelLobby(obj); if (obj.variableExists("gameDetails")) { EsObject gameDetails = obj.getEsObject("gameDetails"); if (gameDetails.variableExists("config")) { EsObject esConfig = gameDetails.getEsObject("config"); SetingConfig(esConfig); } if (gameDetails.variableExists("parent")) { parent = new RoomInfo(gameDetails.getEsObject("parent")); } if (gameDetails.variableExists(DEFINE_INVITED_USERS)) { invitedUsers = gameDetails.getStringArray(DEFINE_INVITED_USERS); } if (gameDetails.variableExists("roomMasterUsername")) { roomMasterUsername = gameDetails.getString("roomMasterUsername"); } if (gameDetails.variableExists("gameIndex")) { gameIndex = gameDetails.getInteger("gameIndex"); } if (gameDetails.variableExists("defaultInfo")) { EsObject defaultInfo = gameDetails.getEsObject("defaultInfo"); numberRobotAllowed = defaultInfo.getInteger("numRobotAllowed"); } } }
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; }
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(); }
// only needed if there are AS3 clients in the same room public static float getUnityPostionXfromAS3(EsObject data) { float targetX = data.getInteger(PluginTags.TARGET_X); return targetX / AS3_MULTIPLIER; }
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"; } }
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"); } } }
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"); } } }
// only needed if there are AS3 clients in the same room public static float getUnityPostionZfromAS3(EsObject data) { float targetY = data.getInteger(PluginTags.TARGET_Y); targetY = (AS3_PANEL_HEIGHT - targetY); return targetY / AS3_MULTIPLIER; }
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"); } }
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 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")); } }