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();
    }
Example #2
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();
 }
Example #3
0
 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();
 }
 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");
     }
 }
Example #5
0
    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.getBoolean(DEFINE_USING_TYPE_RULE),

            esConfig.getBoolean(DEFINE_USING_U_TRON_RULE),
            esConfig.getBoolean(DEFINE_USING_U_XUONG_RULE),
            esConfig.getBoolean(DEFINE_USING_XAO_KHAN_RULE),
            esConfig.getBoolean(DEFINE_USING_DEN_CHONG_RULE),
            esConfig.getBoolean(DEFINE_USING_CHOT_CHONG_RULE));

        if (esConfig.variableExists(DEFINE_LOBBY_PASWORD))
        {
            config.password = esConfig.getString(DEFINE_LOBBY_PASWORD);
        }
        this.config = config;
    }
Example #6
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]);
     }
 }
Example #7
0
    protected virtual void OnPluginMessage(PluginMessageEvent e)
    {
        EsObject eso     = e.Parameters;
        string   command = eso.getString(Fields.COMMAND);
        string   action  = string.Empty;

        if (eso.variableExists(Fields.ACTION))
        {
            action = eso.getString(Fields.ACTION);
        }

        Debug.Log(this.GetType().ToString() + ": " + "time :" + System.DateTime.Now.ToString() + "eso :" + eso);

        if (command == "joinGame" || listWaitingGameplay.Count > 0)
        {
            Debug.LogWarning("CServer -> Gameplay chờ command : " + command);
            if (command == "joinGame")
            {
                ProcessGeneral(command, action, eso);
                listWaitingGameplay.Add(null);
            }
            else
            {
                listWaitingGameplay.Add(new CommandEsObject(e, command, action, eso));
            }
        }
        else
        {
            ProcessPluginMessage(e, command, action, eso);
        }
    }
Example #8
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;
                            }
                        }
                    }
                }
            }
        }
    }
Example #9
0
    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);
                    }
                });
            }
        }
    }
Example #10
0
    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);
    }
Example #11
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]);
     }
 }
Example #12
0
    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");
        }
    }
Example #13
0
    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"));
        }
    }
Example #14
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);
     }
 }
Example #15
0
    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();
    }
Example #16
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");
     }
 }
Example #17
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);
        }
    }
Example #18
0
    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"));
        }
    }
Example #19
0
    public void SetDataOutGoing(EsObject eso)
    {
        content       = eso.getString("content");
        sender        = GameManager.Instance.mInfo.id;
        sender_name   = GameManager.Instance.mInfo.username;
        receiver_name = eso.getString("receiver_name");

        if (eso.variableExists("time_sent"))
        {
            time_sent = System.DateTime.Parse(eso.getString("time_sent"));
        }
        else
        {
            time_sent = System.DateTime.Now;
        }
        read = true;
    }
Example #20
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();
         }
     }
 }
Example #21
0
    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;
    }
Example #22
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();
 }
Example #23
0
    private void OnClickListenerSubmit(GameObject targetObject)
    {
        ETypeLayingBetting types = ETypeLayingBetting.None;

        if (cbLarge.value && cbSmall.value)
        {
            types = ETypeLayingBetting.RongHep;
        }
        else if (cbLarge.value && !cbSmall.value)
        {
            types = ETypeLayingBetting.Rong;
        }
        else if (!cbLarge.value && cbSmall.value)
        {
            types = ETypeLayingBetting.Hep;
        }
        if (cardId == -1 || (cardId == parent.model.CardId && parent.model.ChipBetting == Convert.ToInt64(lbChipBet.text) && types == ETypeLayingBetting.None))
        {
            NotificationView.ShowMessage("Bạn chưa chọn luật hoặc quân ù hoặc chưa đổi mức tiền", 3f);
            return;
        }
        PlayerBettingModel model = new PlayerBettingModel();

        model.CardId      = cardId;
        model.ETypeLaying = types;
        model.ChipBetting = Convert.ToInt64(lbChipBet.text);
        if (esObj != null && esObj.variableExists("textNotification"))
        {
            NotificationView.ShowConfirm("Chú ý", esObj.getString("textNotification"), delegate()
            {
                GameManager.Server.DoRequestPluginGame(Utility.SetEsObject(Fields.GAMEPLAY.PLAY, new object[] { Fields.ACTION, Fields.REQUEST.GA_NGOAI, "gaNgoaiType", (int)model.ETypeLaying, "value", model.ChipBetting, "cardId", model.CardId }));
            }, delegate()
            {
            }, "Tiếp tục", "Hủy bỏ");
        }
        else
        {
            GameManager.Server.DoRequestPluginGame(Utility.SetEsObject(Fields.GAMEPLAY.PLAY, new object[] { Fields.ACTION, Fields.REQUEST.GA_NGOAI, "gaNgoaiType", (int)model.ETypeLaying, "value", model.ChipBetting, "cardId", model.CardId }));
        }
    }
Example #24
0
    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");
            }
        }
    }
Example #25
0
    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);
    }
    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);
            }
        }
    }
Example #27
0
    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");
        }
    }
        public static Quaternion getPlayerRotation(EsObject data)
        {
            if (data.variableExists(PluginTags.POSITION_X))
            {
                return new Quaternion(Convert.ToSingle(data.getFloat(PluginTags.ROTATION_X)),
                                        Convert.ToSingle(data.getFloat(PluginTags.ROTATION_Y)),
                                        Convert.ToSingle(data.getFloat(PluginTags.ROTATION_Z)),
                                        Convert.ToSingle(data.getFloat(PluginTags.ROTATION_W))
                                        );
            }
            else
            {
                // only needed if there are AS3 clients in the same room, or for user enters room
                return new Quaternion(0, 0, 0, 1);
            }

        }
Example #29
0
    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");
        }
    }
Example #30
0
 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");
         }
     }
 }
Example #31
0
 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 static Vector3 getPlayerPosition(EsObject data)
 {
     if (data.variableExists(PluginTags.POSITION_X))
     {
         return new Vector3(Convert.ToSingle(data.getFloat(PluginTags.POSITION_X)),
                                     //Convert.ToSingle(data.getFloat(PluginTags.POSITION_Y)) + 1.0f,
                                     1.0f,
                                     Convert.ToSingle(data.getFloat(PluginTags.POSITION_Z))
                                     );
     }
     else
     {
         // only needed if there are AS3 clients in the same room, or for user enters room
         return new Vector3(getUnityPostionXfromAS3(data), 1.0f, getUnityPostionZfromAS3(data));
     }
 }