Пример #1
0
 void Start()
 {
     for (int i = 0; i < betting.Length; i++)
     {
         if (i > ((ChannelPhom)GameManager.Instance.selectedChannel).bettingValues.Length - 1)
         {
             GameObject.Destroy(betting[i].gameObject);
             betting[i] = null;
         }
         else
         {
             if (((ChannelPhom)GameManager.Instance.selectedChannel).bettingValues[i] == ChannelPhom.CHANNEL_BILLIONAIRE_BETTING_OTHER_VALUE)
             {
                 betting[i].gameObject.transform.FindChild("Label").gameObject.GetComponent <UILabel>().text = "Khác";
                 Utility.AddCollider(betting[i].gameObject);
             }
             else
             {
                 betting[i].gameObject.transform.FindChild("Label").gameObject.GetComponent <UILabel>().text = string.Format("{0:0,0}", ((ChannelPhom)GameManager.Instance.selectedChannel).bettingValues[i]).Replace(",", ".");
                 Utility.AddCollider(betting[i].gameObject);
                 if (CommonPhom.ValidateChipToBetting(((ChannelPhom)GameManager.Instance.selectedChannel).bettingValues[i]) == false)
                 {
                     betting[i].collider.enabled = false;
                     Color c = betting[i].GetComponentInChildren <UILabel>().color;
                     c.a = 100 / 255f;
                     betting[i].GetComponentInChildren <UILabel>().color = c;
                 }
             }
         }
     }
     HeaderMenu.Instance.OnClickButtonBackCallBack = delegate()
     {
         GameManager.LoadScene(ESceneName.LobbyPhom);
     };
 }
Пример #2
0
    public void DoJoinLobby(GameObject go)
    {
        if (CommonPhom.ValidateChipToBetting(lobby.betting) == false)
        {
            int rule = CommonPhom.RULE_CHIP_COMPARE_BETTING;
            Common.MessageRecharge("Số tiền của bạn phải lớn hơn hoặc bằng " + rule + " lần tiền cược.");
            return;
        }

        GetComponent <CUIHandle>().StopImpact(2f);

        if (lobby.numberUserInRoom == lobby.maxNumberPlayer)
        {
            NotificationView.ShowMessage("Bàn chơi đã đầy. Xin vui lòng tìm bàn chơi khác.", 2f);
            return;
        }

        GameManager.Instance.selectedLobby = lobby;

        if (lobby.isPassword)
        {
            NotificationView.ShowDialog("Nhập mật khẩu để truy cập bàn chơi", ProcessInputPassword);
        }
        else
        {
            ProcessInputPassword("");
        }
    }
Пример #3
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
            LobbyRowPhom.List.Clear();
            EsObject[] children = paremeters.getEsObjectArray("children");

            //UIDragScrollView panel = parentListLobby.transform.parent.gameObject.GetComponent<UIDragScrollView>();

            foreach (EsObject obj in children)
            {
                LobbyPhom lobby = new LobbyPhom(obj);
                LobbyRowPhom.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");
            UIDragScrollView panel = parentListLobby.transform.parent.gameObject.GetComponent <UIDragScrollView>();
            //LobbyRow row =
            LobbyRowPhom.Create(panelLobbyRow, parentListLobby.transform, new LobbyPhom(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");
            LobbyRowPhom row = LobbyRowPhom.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");
            LobbyRowPhom row = LobbyRowPhom.List.Find(o => o.lobby.gameId == es.getInteger("gameId"));
            LobbyRowPhom.Remove(row);
            parentListLobby.repositionNow     = true;
            parentListUseOnline.repositionNow = true;
            //parentListLobby.transform.parent.GetComponent<UIDragScrollView>().RestrictWithinBounds(false);
            #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
            UserOnlineRowPhom.List.Clear();

            UIDragScrollView panel    = parentListUseOnline.transform.parent.gameObject.GetComponent <UIDragScrollView>();
            EsObject[]       children = paremeters.getEsObjectArray("users");
            foreach (EsObject obj in children)
            {
                if (obj.getString(Fields.PLAYER.USERNAME) == GameManager.Instance.mInfo.username)
                {
                    continue;
                }
                UserOnlineRowPhom.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)
                {
                    //UIDragScrollView panel = parentListUseOnline.transform.parent.gameObject.GetComponent<UIDragScrollView>();
                    UserOnlineRowPhom.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 = UserOnlineRowPhom.List.Find(o => o.user.username == es.getString(Fields.PLAYER.USERNAME));
                if (row != null)
                {
                    UserOnlineRowPhom.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
            {
                LobbyPhom lobby = LobbyRowPhom.List.Find(lb => lb.lobby.gameId == gameId).lobby;
                GameManager.Instance.selectedLobby = new LobbyPhom(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 LobbyPhom(gameId);
                    GameManager.Server.DoJoinGame(password);
                }, null);
            }
        }
        else if (command == "tryCreateGame")
        {
            bool allowCreateRoom = paremeters.getBoolean("allowCreateGame");
            if (allowCreateRoom)
            {
                if (CommonPhom.ValidateChipToBetting(((ChannelPhom)GameManager.Instance.selectedChannel).bettingValues[0]))
                {
                    GameManager.LoadScene(ESceneName.CreateRoomPhom);
                }
                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 LobbyPhom(gameId);
                    GameManager.Server.DoJoinGame(password);
                }, null);
            }
        }
    }