Example #1
0
    void SetData(LobbyTLMN lobby)
    {
        this.lobby = lobby;
        //UpdateIndex(List.Count + 1);
        UpdateIndex(lobby.gameIndex);
        numberPlayer.SetValue(lobby.numberUserInRoom);
        lbBetting.text = Utility.Convert.Chip(lobby.betting);
        lbName.text    = lobby.nameLobby;
        lbRule.text    = lobby.config.isAdvanceGame ? "Xếp hạng" : "Đếm lá";

        UpdateImageLock(lobby);

        // transform.FindChild("bgNumber").GetComponent<UISprite>().spriteName = lobby.gameIndex < 10 ? "bgmbtab1" : lobby.gameIndex < 100 ? "bgmbtab2" : "bgmbtab3";
    }
Example #2
0
    public static LobbyRowTLMN Create(UIPanel panel, Transform parent, LobbyTLMN lobby)
    {
        GameObject obj = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Channel/LobbyRowTLMN"));

        obj.name = string.Format("Lobby_{0:0000}", lobby.gameIndex);

        obj.transform.parent        = parent;
        obj.transform.localPosition = new Vector3(0f, 0f, -1f);
        obj.transform.localScale    = new Vector3(0.95f, 0.9f, 1f);
        LobbyRowTLMN row = obj.GetComponent <LobbyRowTLMN>();

        row.SetData(lobby);
        List.Add(row);
        SetSize(panel, row);
        return(row);
    }
Example #3
0
    public void UpdateData(EsObject obj)
    {
        if (obj.variableExists("config"))
        {
            this.lobby = new LobbyTLMN(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);
    }
Example #4
0
    void UpdateImageLock(LobbyTLMN lobby)
    {
        UIButton bt = gameObject.GetComponent <UIButton>();

        if (lobby.isPassword == true)
        {
            spriteStatus.spriteName = LOCK;
        }
        else
        {
            if (lobby.gamePlaying)
            {
                spriteStatus.spriteName = PLAYING;
            }
            else
            {
                spriteStatus.spriteName = WAITING;
            }
        }
    }
    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);
            }
        }
    }