Пример #1
0
    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);
        }
    }
Пример #2
0
    private void Server_EventPluginMessageOnProcess(string command, string action, EsObject eso)
    {
        if (command == "getHandRobot")
        {
            if (eso.variableExists("players"))
            {
                foreach (EsObject obj in eso.getEsObjectArray("players"))
                {
                    string username        = obj.getString("userName");
                    PlayerControllerChan p = GameModelChan.GetPlayer(username);
                    if (obj.getIntegerArray("hand").Length != p.mCardHand.Count)
                    {
                        Debug.LogWarning("Số lượng card không phù hợp giũa client và server: " + p.username);
                    }
                    else
                    {
                        if (p.mCardHand.FindAll(c => c.CardId == -1).Count == 0)
                        {
                            return;
                        }

                        foreach (int cardId in obj.getIntegerArray("hand"))
                        {
                            ECard card = p.mCardHand.Find(c => c.CardId == cardId);
                            if (card == null)
                            {
                                p.mCardHand.Find(c => c.CardId == -1).CardId = cardId;
                            }
                        }
                    }
                }
            }
        }
    }
Пример #3
0
    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();
    }
Пример #4
0
 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");
     }
 }
Пример #5
0
 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();
 }
Пример #6
0
 private void OnProcessPluginMessage(string command, string action, EsObject parameters)
 {
     if (command == Fields.REQUEST.COMMAND_GETGENERAL)
     {
         EsObject[] esObject = parameters.getEsObjectArray("users");
         for (int i = 0; i < esObject.Length; i++)
         {
         }
     }
 }
Пример #7
0
 void OnProcessPluginMessage(string command, string action, EsObject paremeters)
 {
     if (command == Fields.RESPONSE.FULL_UPDATE)
     {
         EsObject[] children = paremeters.getEsObjectArray("children");
         listChannel.Clear();
         foreach (EsObject obj in children)
         {
             listChannel.Add(new ChannelPhom(obj));
         }
         OnDrawListChannel();
     }
 }
Пример #8
0
 void OnProcessPluginMessage(string command, string action, EsObject paremeters)
 {
     Debug.Log("Response request.Command:" + command + ",parameters:" + paremeters);
     if (command == Fields.RESPONSE.FULL_UPDATE)
     {
         EsObject[] children = paremeters.getEsObjectArray("children");
         listChannel.Clear();
         foreach (EsObject obj in children)
         {
             listChannel.Add(new ChannelTLMN(obj));
         }
         OnDrawListChannel();
     }
 }
Пример #9
0
 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]);
     }
 }
Пример #10
0
 private void OnPluginProcess(string command, string action, EsObject parameters)
 {
     if (command == Fields.RESPONSE.FULL_UPDATE)
     {
         if (parameters.variableExists("children"))
         {
             EsObject[] children = parameters.getEsObjectArray("children");
             for (int i = 0; i < children.Length; i++)
             {
                 GameObject obj = NGUITools.AddChild(gridHall.gameObject, hallPrefab);
                 obj.name = "hall" + i;
                 obj.GetComponent <HallItem>().SetData(children[i]);
             }
             gridHall.Reposition();
         }
     }
 }
Пример #11
0
 public void CreateItem(EsObject es)
 {
     if (es.variableExists("groupName"))
     {
         this.lblTitle.text = es.getString("groupName");
     }
     EsObject[] esObject = es.getEsObjectArray("matchs");
     for (int i = 0; i < esObject.Length; i++)
     {
         GameObject          item           = (GameObject)GameObject.Instantiate(popUpItem);
         PopupTournamentItem tournamentitem = item.GetComponent <PopupTournamentItem>();
         item.transform.parent = gridTournament.transform;
         tournamentitem.SetData(esObject[i]);
         item.name = "match" + i;
         tournamentitem.transform.localScale    = Vector3.one;
         tournamentitem.transform.localPosition = Vector3.zero;
     }
     gridTournament.Reposition();
 }
Пример #12
0
 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]);
     }
 }
Пример #13
0
 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);
     }
 }
Пример #14
0
 void handleGamesFoundEvent(EsObject esob)
 {
     EsObject[] esobs = esob.getEsObjectArray(LobbyConstants.GAMES_FOUND);
     for (int ii = 0; ii < LobbyConstants.NUM_ROWS; ii++)
     {
         AvailGame ag = playerGrid[ii];
         if (ii < esobs.Length)
         {
             EsObject obj = esobs[ii];
             ag.name = obj.getString(LobbyConstants.PLAYER_NAME);
             ag.gameId = obj.getInteger(LobbyConstants.ID);
         }
         else
         {
             ag.clear();
         }
     }
 }
 private void handleUserListResponse(EsObject esob)
 {
     //Debug.Log("handleUserListResponse");
     EsObject[] players = esob.getEsObjectArray(PluginTags.USER_STATE);
     getPlayerSpawnController().SpawnRemotePlayers(players, _userName);
 }
Пример #16
0
    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");
            }
        }
    }
Пример #17
0
    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);
            }
        }
    }
Пример #18
0
 public void handleMoveEvent(EsObject obj) {
     // only happens if it's good
     EsObject[] changedChips = obj.getEsObjectArray(GameConstants.CHANGED_CHIPS, null);
     if (changedChips != null) {
         // update the board
         for (int ii = 0; ii < changedChips.Length; ii++)
         {
             addOrUpdateOneChip(changedChips[ii]);
         }
     }
 }
Пример #19
0
 public void handleStartGame(EsObject obj) {
     inGame = true;
     showReturnToLobbyButton = false;
     EsObject[] chips = obj.getEsObjectArray(GameConstants.CHANGED_CHIPS);
         //for (EsObject chipObj : chips) {
     for (int ii = 0; ii < chips.Length; ii++)
     {
         addOrUpdateOneChip(chips[ii]);
     }
 }
Пример #20
0
    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();
    }