コード例 #1
0
    void Start()
    {
        if (GameManager.PlayGoldOrChip != GOLD && GameManager.PlayGoldOrChip != CHIP)
        {
            GameManager.PlayGoldOrChip = GOLD;
        }
        GameManager.Server.DoRequestCommand(Fields.REQUEST.REQUEST_FULL);
        if (GameManager.Setting.IsFirstLogin)
        {
            GameManager.Setting.IsFirstLogin = false;
            NotificationView.ShowConfirm(
                Fields.MESSAGE.FIRST_LOGIN_NOTE, Fields.MESSAGE.FIRST_LOGIN_MESSAGE,
                delegate()
            {
                StoreGame.SaveInt(StoreGame.EType.CHANGE_INFORMATION, 1);
                ProfileView.Instance.CheckWhenStart();
            }
                , null, "CẬP NHẬT", "ĐỂ SAU"
                );
        }
        GetDataUserInfo();
        SetIcon();

        HeaderMenu.Instance.OnClickButtonBackCallBack = delegate()
        {
            GameManager.Server.DoJoinRoom(GameManager.Instance.hallRoom.zoneId, GameManager.Instance.hallRoom.roomId);
        };
    }
コード例 #2
0
    /// <summary>
    /// Gửi request kick người chơi
    /// </summary>
    void DoRequestKickPlayer(GameObject go)
    {
        if (GameModelChan.CurrentState >= GameModelChan.EGameState.dealClient)
        {
            NotificationView.ShowMessage("Bạn không thể đuổi người chơi khác trong khi ván bài đang diễn ra.");
            return;
        }

        UIContainerAnonymous anony = go.GetComponent <UIContainerAnonymous>();

        if (anony != null)
        {
            NotificationView.ShowConfirm("Xác nhận.", "Bạn có chắc rằng muốn đuổi người chơi " + ((EPlayerController)anony.intermediary).username + "\n\nRa khỏi bàn chơi không ?",
                                         delegate()
            {
                GameManager.Server.DoRequestPluginGame(Utility.SetEsObject(Fields.GAMEPLAY.PLAY, new object[] {
                    Fields.ACTION, "kickPlayer",
                    Fields.PLAYER.USERNAME, ((EPlayerController)anony.intermediary).username
                }));
            }, null);
        }
        else
        {
            Debug.LogError("Không tìm được người chơi");
        }
    }
コード例 #3
0
 private void gcmReceiverMessage(Dictionary <string, object> obj)
 {
     if (obj.ContainsKey("message"))
     {
         string title   = "Thông báo từ hệ thống";
         string message = obj ["message"].ToString();
         if (obj.ContainsKey("title"))
         {
             title = obj ["title"].ToString();
         }
         if (obj.ContainsKey("action"))
         {
             string action = obj ["action"].ToString();
             string url    = obj ["url"].ToString();
             NotificationView.ShowConfirm(title, message, delegate() {
                 Application.OpenURL(url);
                 Debug.Log("open url");
             }, null);
         }
         else
         {
             ServerMessagesView.MessageServer(title, message, 5f);
         }
     }
 }
コード例 #4
0
    void Start()
    {
        GameManager.Server.DoRequestCommand(Fields.REQUEST.REQUEST_FULL);

        if (GameManager.Setting.IsFirstLogin)
        {
            GameManager.Setting.IsFirstLogin = false;
            NotificationView.ShowConfirm(
                Fields.MESSAGE.FIRST_LOGIN_NOTE, Fields.MESSAGE.FIRST_LOGIN_MESSAGE,
                delegate()
            {
                StoreGame.SaveInt(StoreGame.EType.CHANGE_INFORMATION, 1);
                ProfileView.Instance.CheckWhenStart();
            }
                , null, "CẬP NHẬT", "ĐỂ SAU"
                );
        }

        listButton[0].GetComponentInChildren <NumberUserInChannel>().SetValue(2);
        SetIcon();
        HeaderMenu.Instance.OnClickButtonBackCallBack = delegate()
        {
            GameManager.Server.DoJoinRoom(GameManager.Instance.hallRoom.zoneId, GameManager.Instance.hallRoom.roomId);
        };
    }
コード例 #5
0
 public void remoteNotificationAtLauch(IDictionary obj)
 {
     if (obj.Contains("message"))
     {
         string title   = "Thông báo từ hệ thống";
         string message = obj ["message"].ToString();
         if (obj.Contains("title"))
         {
             title = obj ["title"].ToString();
         }
         if (obj.Contains("action"))
         {
             string action = obj ["action"].ToString();
             string url    = obj ["url"].ToString();
             NotificationView.ShowConfirm(title, message, delegate() {
                 Application.OpenURL(url);
                 Debug.Log("open url");
             }, null);
         }
         else
         {
             ServerMessagesView.MessageServer(title, message, 5f);
         }
     }
     EtceteraBinding.setBadgeCount(0);
 }
コード例 #6
0
    /// <summary>
    /// Remotes the notification.
    /// Dictionary co 3 key : badge la so hien thi o ngoai icon  , sound , alert la message duoc gui tu server
    /// </summary>
    ///
    /// <param name="obj">Object.</param>
    void remoteNotification(IDictionary obj)
    {
        //IDictionary aps = obj["aps"];

        if (obj.Contains("message"))
        {
            string title   = "Thông báo từ hệ thống";
            string message = obj ["message"].ToString();
            if (obj.Contains("title"))
            {
                title = obj ["title"].ToString();
            }
            if (obj.Contains("action"))
            {
                string action = obj ["action"].ToString();
                string url    = obj ["url"].ToString();
                NotificationView.ShowConfirm(title, message, delegate() {
                    Application.OpenURL(url);
                    Debug.Log("open url");
                }, null);
            }
            else
            {
                ServerMessagesView.MessageServer(title, message, 5f);
            }
        }
    }
コード例 #7
0
 // Use this for initialization
 void Start()
 {
     GameManager.Server.DoRequestCommand(Fields.REQUEST.REQUEST_FULL);
     HeaderMenu.Instance.OnClickButtonBackCallBack = delegate()
     {
         NotificationView.ShowConfirm("Lưu ý", "Bạn có chắc chắn muốn đăng xuất ? ", delegate() { GameManager.Server.DoLogOut(); }, null, "Đồng ý", "Hủy");
     };
 }
コード例 #8
0
 public static void MessageRecharge(string message)
 {
     if (GameManager.Setting.Platform.EnableRecharge)
     {
         NotificationView.ShowConfirm("Thông báo", message + "\n\nẤn \"Đồng ý\" để chuyển đến trang nạp tiền", delegate() { RechargeView.Create(); }, null);
     }
     else
     {
         NotificationView.ShowMessage(message);
     }
 }
コード例 #9
0
    IEnumerator DoRequestVersion()
    {
        if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer || Application.isEditor)
        {
            bool?   reRequest = null;
            WWWForm form      = new WWWForm();
            form.AddField("version", (GameSettings.Instance.CODE_VERSION_BUILD));
            form.AddField("offical_version", GameSettings.CurrentVersion);
            form.AddField("game_id", (int)GameManager.GAME);
            form.AddField("device", PlatformSetting.GetPlatform.ToString());
            form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
            ServerWeb.StartThreadHttp(ServerWeb.URL_GET_VERSION_GAME, form, delegate(bool isDone, WWW response, IDictionary json)
            {
                if (isDone)
                {
                    if (string.IsNullOrEmpty(response.error))
                    {
                        reRequest = false;
                        if (json["code"].ToString() == "1")
                        {
                            string url = json["link"].ToString();
                            GameManager.Setting.IsMustUpdate = url;
                            Common.MustUpdateGame();
                        }
                        else if (json["code"].ToString() == "2")
                        {
                            string newVersion = json["core_version"].ToString() + "." + json["build_version"].ToString() + "." + json["code_version_build"].ToString();
                            string url        = json["link"].ToString();

                            NotificationView.ShowConfirm("Cập nhật phiên bản mới", "Hiện tại chúng tôi đã có phiên bản mới v" + newVersion + "\n\n" + "Hãy cập nhật và cảm nhận những tính năng mới.",
                                                         delegate() { Application.OpenURL(url); },
                                                         null, "CẬP NHẬT", "ĐỂ SAU");
                        }
                    }
                    else
                    {
                        reRequest = true;
                    }
                }
            });
            while (reRequest == null)
            {
                yield return(new WaitForEndOfFrame());
            }
            if (reRequest == true)
            {
                yield return(new WaitForSeconds(2f));

                GameManager.Instance.StartCoroutine(DoRequestVersion());
            }
        }
    }
コード例 #10
0
 public void OnPreferPlayer()
 {
     if (enabled && hasSetData)
     {
         if (UIToggle.current.value)
         {
             UIToggle.current.value = false;
             NotificationView.ShowConfirm("Lưu ý", "Bạn có chắc chắn muốn ưu tiên người chơi " + player.username + " vào bàn chơi khi có người khác thoát ra? ", delegate()
             {
                 GameManager.Server.DoRequestPluginGame(Utility.SetEsObject("play", new object[] { Fields.ACTION, "changePriorityInWaitingQueue", "userName", player.username }));
             }, delegate() {
                 grandParent.SetActiveListToggle();
             }, "Chắc chắn", "Không");
         }
     }
 }
コード例 #11
0
    public virtual void DoRequestKickPlayer(GameObject go)
    {
        UIContainerAnonymous anony = go.GetComponent <UIContainerAnonymous>();

        if (anony != null)
        {
            NotificationView.ShowConfirm("Xác nhận.", "Bạn có chắc rằng muốn đuổi người chơi " + ((EPlayerController)anony.intermediary).username + "\n\nRa khỏi bàn chơi không ?",
                                         delegate()
            {
                GameManager.Server.DoRequestPluginGame(Utility.SetEsObject(Fields.GAMEPLAY.PLAY, new object[] {
                    Fields.ACTION, "kickPlayer",
                    Fields.PLAYER.USERNAME, ((EPlayerController)anony.intermediary).username
                }));
            }, null);
        }
        else
        {
            Debug.LogError("Không tìm được người chơi");
        }
    }
コード例 #12
0
 /// <summary>
 ///
 /// </summary>
 protected virtual void OnServerKickUser(ServerKickUserEvent e)
 {
     DoLogOut();
     if (e.Error == ErrorType.IdleTimeReached)
     {
         NotificationView.ShowConfirm("Thông báo", "Bạn đã bị ngắt kết nối đến máy chủ\n\ndo quá lâu không tương tác",
                                      delegate()
         {
             GameManager.Server.DoLogin(GameManager.Instance.mInfo.username, GameManager.Instance.mInfo.password, GameManager.Instance.deviceToken);
         }, null, "Kết nối lại", "Đóng");
     }
     else if (e.Error == ErrorType.UserKickedFromServer)
     {
         if (e.EsObject.variableExists("reason"))
         {
             //NotificationView.ShowMessage("Bạn đã bị thoát ra vì có người chơi khác\n\nđăng nhập vào tài khoản của bạn.");
             NotificationView.ShowMessage(e.EsObject.getString("reason"));
         }
     }
 }
コード例 #13
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 }));
        }
    }
コード例 #14
0
ファイル: HeaderMenu.cs プロジェクト: wefasdfaew2/GamePortal
 public void OnClickButtonLogout(GameObject go)
 {
     NotificationView.ShowConfirm("Lưu ý", "Bạn có chắc chắn muốn đăng xuất ? ", delegate() { GameManager.Server.DoLogOut(); }, null, "Đồng ý", "Hủy");
 }
コード例 #15
0
 private void OnClickKickUser(GameObject targetObject)
 {
     NotificationView.ShowConfirm("Lưu ý", "Bạn có chắc chắn muốn đuổi " + player.username + " ra khỏi bàn chơi ?", delegate() {
         GameManager.Server.DoRequestPluginGame(Utility.SetEsObject("play", new object[] { Fields.ACTION, "kickWaitingPlayer", "userName", player.username }));
     }, null, "Chắc chắn", "Không");
 }
コード例 #16
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);
            }
        }
    }
コード例 #17
0
 private void OnClickRemove(GameObject targetObject)
 {
     NotificationView.ShowConfirm("Xác Nhận", "Bạn có muốn xóa " + mUser.username + " người này ra khỏi danh sách bạn bè ?", Accept, null);
 }
コード例 #18
0
    IEnumerator DoRequestAllConfiguration(string message)
    {
        int getConfigurationCount = 0;

        WaitingView.Show(message);
        bool?   reRequest = null;
        WWWForm form      = new WWWForm();

        form.AddField(ServerWeb.PARAM_CONFIG_CODE_GAME, GameManager.GAME.ToString());
        form.AddField(ServerWeb.PARAM_CONFIG_CODE_PLATFORM, PlatformSetting.GetPlatform.ToString());
        form.AddField(ServerWeb.PARAM_CONFIG_CORE_VERSION, GameSettings.Instance.CORE_VERSION);
        form.AddField(ServerWeb.PARAM_CONFIG_BUILD_VERSION, GameSettings.Instance.BUILD_VERSION);
        form.AddField(ServerWeb.PARAM_CONFIG_CODE_REVISION, GameSettings.Instance.CODE_VERSION_BUILD);
        form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
        ServerWeb.StartThreadHttp(ServerWeb.URL_GET_ALL_CONFIGURATION, form, delegate(bool isDone, WWW response, IDictionary json)
        {
            if (isDone)
            {
                GameManager.Instance.FunctionDelay(delegate()
                {
                    if (string.IsNullOrEmpty(response.error))
                    {
                        WaitingView.Instance.Close();
                        reRequest = false;
                        if (json[Fields.RESPONSE.PHP_RESPONSE_CODE].ToString() == "0")
                        {
                            ArrayList items = (ArrayList)json[Fields.RESPONSE.PHP_RESPONSE_ITEMS];
                            foreach (Hashtable obj in items)
                            {
                                GameManager.Setting.Platform.AddOrUpdatePlatformConfig(obj);
                            }
                            if (GameManager.CurrentScene == ESceneName.ChannelChan)
                            {
                                //HeaderMenu.Instance.ActiveButtonRecharge();
                            }
                            if (GameManager.Setting.Platform.GetConfigByType(PlatformType.url_ping) != null)
                            {
                                ServerWeb.URL_PING = GameManager.Setting.Platform.GetConfigByType(PlatformType.url_ping).Value;
                            }

                            if (GameManager.Setting.Platform.GetConfigByType(PlatformType.realtime_server) != null)
                            {
                                CServer.HOST_NAME = GameManager.Setting.Platform.GetConfigByType(PlatformType.realtime_server).Value;
                            }

                            if (EventLoadConfig != null)
                            {
                                EventLoadConfig();
                            }
                        }
                    }
                    else
                    {
                        reRequest = true;
                    }
                }, 0.2f);
            }
        });
        while (reRequest == null)
        {
            yield return(new WaitForEndOfFrame());
        }
        if (reRequest == true)
        {
            getConfigurationCount++;
            if (getConfigurationCount < 3)
            {
                yield return(new WaitForSeconds(1f));

                GameManager.Instance.StartCoroutine(DoRequestAllConfiguration("Kết nối bị lỗi , Đang kiểm tra lại kết nối "));
            }
            else
            {
                NotificationView.ShowConfirm("Thông báo", "Không thể kết nối đến server của chúng tôi . Bấm đồng ý để tiếp tục kiểm tra lại ", delegate()
                {
                    getConfigurationCount = 0;
                    GameManager.Instance.StartCoroutine(DoRequestAllConfiguration("Kiểm tra kết nối đến server"));
                }, null);
            }
        }
    }
コード例 #19
0
    IEnumerator Start()
    {
        Debug.Log(GameManager.Setting.IsMustUpdate);

        if (!Common.IsRelease)
        {
            CServer.HOST_NAME = StoreGame.LoadString(StoreGame.EType.SAVE_SERVER);
        }

        if (!string.IsNullOrEmpty(GameManager.Setting.IsMustUpdate))
        {
            NotificationView.ShowConfirm("Thông báo", "Có bản cập nhật quan trọng. Bạn có muốn tải về?", OnOkUpdateVersion, OnCancelUpdateVersion);
            yield break;
        }
        else
        {
            if (Common.IsRelease && GameManager.Instance.currentRoom != null)
            {
#if UNITY_WEBPLAYER
                switch (GameSettings.Instance.TypeBuildFor)
                {
                case GameSettings.EBuildType.esimo:
                case GameSettings.EBuildType.web_esimo:
                    //UpdateCookieString();
                    //StartCoroutine(_LoginInWebPlayer());
                    break;

                case GameSettings.EBuildType.web_facebook:
                    while (string.IsNullOrEmpty(CServer.HOST_NAME))
                    {
                        yield return(new WaitForEndOfFrame());
                    }
                    WaitingView.Show("Đang lấy thông tin");
                    SocialCommon.Instance.LoginFaceBook(cbSavePass.value);
                    break;
                }
#endif
                GameManager.Instance.userNameLogin = StoreGame.Contains(StoreGame.EType.SAVE_USERNAME) ? StoreGame.LoadString(StoreGame.EType.SAVE_USERNAME) : "";
                GameManager.Instance.passwordLogin = StoreGame.Contains(StoreGame.EType.SAVE_PASSWORD) ? StoreGame.LoadString(StoreGame.EType.SAVE_PASSWORD) : "";
                if (!string.IsNullOrEmpty(GameManager.Instance.userNameLogin) && !string.IsNullOrEmpty(GameManager.Instance.passwordLogin))
                {
                    while (string.IsNullOrEmpty(CServer.HOST_NAME))
                    {
                        yield return(new WaitForEndOfFrame());
                    }
                    yield return(new WaitForSeconds(0.1f));

                    WaitingView.Show("Đang đăng nhập");
                    GameManager.Server.DoLogin();
                }
            }
            else if (Common.IsRelease)
            {
                if (StoreGame.Contains(StoreGame.EType.SAVE_USERNAME) && StoreGame.Contains(StoreGame.EType.SAVE_PASSWORD))
                {
                    if (!string.IsNullOrEmpty(StoreGame.LoadString(StoreGame.EType.SAVE_USERNAME)) && !string.IsNullOrEmpty(StoreGame.LoadString(StoreGame.EType.SAVE_PASSWORD)))
                    {
                        lableUsername.value = StoreGame.LoadString(StoreGame.EType.SAVE_USERNAME);
                        lablePassword.value = StoreGame.LoadString(StoreGame.EType.SAVE_PASSWORD);
                    }
                }
            }
        }
        AudioManager.Instance.PlayBackground();
    }
コード例 #20
0
ファイル: ViewProfile.cs プロジェクト: wefasdfaew2/GamePortal
 private void OnClickRemoveInvited(GameObject targetObject)
 {
     NotificationView.ShowConfirm("Xác Nhận", "Bạn đã gửi lời mời đến " + mUser.username + " hãy chờ " + mUser.username + " xác nhận.\n\nBạn có muốn hủy lời mời kết bạn này không?", Accept, null);
 }
コード例 #21
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");
            }
        }
    }
コード例 #22
0
    IEnumerator _DoConnection(CallBackFunction callback)
    {
        //Đặt biến không cho gửi kết nối nữa.
        mustThreadConnecting = true;

        es.Engine.Queueing = EsEngine.QueueDispatchType.External;
        Server server = new Server(CServer.SERVER_ID);

        //if (es.Engine.Servers.Contains(server) == false)
        server.AddAvailableConnection(new AvailableConnection(CServer.HOST_NAME, System.Convert.ToInt32(CServer.PORT), TYPE_CONNECT));
        es.Engine.AddServer(server);

        log4net.Config.BasicConfigurator.Configure();

#if UNITY_WEBPLAYER
        if (!Application.isEditor && Application.isWebPlayer)
        {
            if (!Security.PrefetchSocketPolicy(CServer.HOST_NAME, System.Convert.ToInt32(CServer.PORT), 999))
            {
                Debug.LogError("Security Exception. Policy file load failed!");
            }
        }
#endif

        //Set là chưa có thông tin phản hồi về kết nối
        bool?connectionResponseSuccessful = null;

        WaitingView.Show("Kết nối đến máy chủ");

        threadConnect = new System.Threading.Thread(delegate()
        {
            es.Engine.Connect();
            connectionResponseSuccessful = es.Engine.Connected;
        });
        threadConnect.Start();

        while (connectionResponseSuccessful == null)
        {
            yield return(new WaitForEndOfFrame());
        }

        if (isLogged)
        {
            WaitingView.Instance.Close();
        }

        if (!es.Engine.Connected)
        {
            WaitingView.Hide();
            NotificationView.ShowConfirm(
                "Lỗi kết nối TCP/IP.",
                "Không thể kết nối đến máy chủ.\n\n Bạn có muốn thực hiện lại hành động vừa rồi ?",
                delegate()
            {
                DoConnection(callback);
            }, null);
        }
        else
        {
            callback();
        }
        mustThreadConnecting = false;
    }