void Awake() { CUIHandle.AddClick(btCreateRoom, CLickButtonCreate); CUIHandle.AddClick(btQuickplay, ClickButtonQuick); CUIHandle.AddClick(btFilter, OnClickButtonFilter); GameManager.Server.EventPluginMessageOnProcess += OnProcessPluginMessage; GameManager.Server.EventJoinRoom += OnAfterJoinRoom; GameManager.Server.EventPublicMessage += OnPublicMessage; GameManager.Server.EventLoadSence += OnJoinGame; //GameManager.Instance.applicationStart.EventLoadAnnounce += OnLoadAnnounceDone; GameManager.Server.EventAdsChanged += CallBackAdsChangeHandler; //BroadcastView.Instance.ShowInLobby(GameManager.Setting.BroadcastMessage); Debug.Log("Channel selected:" + GameManager.Instance.selectedChannel.roomId + "," + GameManager.Instance.selectedChannel.zoneId);; Debug.Log("Channel chan:" + GameManager.Instance.channelRoom.roomId + "," + GameManager.Instance.channelRoom.zoneId); HeaderMenu.Instance.OnClickButtonBackCallBack = delegate() { WaitingView.Show("Đang thoát"); Debug.Log("Channel current selected:" + GameManager.Instance.channelRoom.roomId + "," + GameManager.Instance.channelRoom.zoneId); GameManager.Server.DoJoinRoom(GameManager.Instance.channelRoom.zoneId, GameManager.Instance.channelRoom.roomId); }; // get name channel showNameChannel(); controller.OnTabbarSelectEvent += OnTabbarSelectHandler; containerFilter.GetComponent <LobbyFilter>().FilterCallBack += FilterHandler; containerFilter.GetComponent <LobbyFilter>().CancelFilterCallBack += CancelFilterHandler; }
private void DoCreateGame(int betting, int timePlay) { WaitingView.Show("Đang tạo phòng"); int rulePlaying = 0; Debug.Log("DoCreateGame"); EsObject gameConfig = new EsObject(); string roomName = txtRoomName.value; if (string.IsNullOrEmpty(roomName)) { roomName = "Bàn chơi của " + GameManager.Instance.mInfo.username; } gameConfig.setString(LobbyChan.DEFINE_LOBBY_NAME, roomName); gameConfig.setString(LobbyChan.DEFINE_LOBBY_PASWORD, txtPassword.value.Trim()); gameConfig.setInteger(LobbyChan.DEFINE_BETTING, betting); if (!cbGaNhai.value && !cbNuoiGa.value) { showGa = (int)LobbyChan.EGaRule.none; } gameConfig.setInteger(LobbyChan.DEFINE_USING_NUOI_GA, showGa); //true nuoi ga false ga nhai gameConfig.setBoolean(LobbyChan.DEFINE_USING_AUTO_BAT_BAO, true); //true gameConfig.setBoolean(LobbyChan.DEFINE_USING_AUTO_U, true); //true rulePlaying = ruleMain[0].value ? 1 : ruleMain[1].value ? 2 : ruleMain[2].value ? 3 : 1; gameConfig.setInteger(LobbyChan.DEFINE_RULE_FULL_PLAYING, rulePlaying); gameConfig.setStringArray(LobbyChan.DEFINE_INVITED_USERS, new string[0]); gameConfig.setInteger(LobbyChan.DEFINE_PLAY_ACTION_TIME, timePlay);// defalt 20s GameManager.Server.DoRequestPlugin(Utility.SetEsObject(Fields.RESPONSE.CREATE_GAME, new object[] { "config", gameConfig })); }
void Start() { this.SetData(); InitCountDownTime(); if (GameManager.Instance.currentTournamentInfo.isRegister) { NGUITools.SetActive(TableTournament, true); NGUITools.SetActive(RegisterForm, false); WaitingView.Show("Đang lấy dữ liệu"); GameManager.Server.DoRequestPlugin(Utility.SetEsObject(Fields.REQUEST.COMMAND_GETGENERAL, new object[] { "id", this.tournamentInfo.tournamentId })); } else { if (GameManager.Instance.currentTournamentInfo.remainStartTime > 0) { NGUITools.SetActive(TableTournament, false); NGUITools.SetActive(RegisterForm, true); } else { NGUITools.SetActive(TableTournament, true); NGUITools.SetActive(RegisterForm, false); WaitingView.Show("Đang lấy dữ liệu"); GameManager.Server.DoRequestPlugin(Utility.SetEsObject(Fields.REQUEST.COMMAND_GETGENERAL, new object[] { "id", this.tournamentInfo.tournamentId })); } } }
void ProcessAfterRecharge(bool isDone, WWW response, IDictionary json) { if (isDone && json.Contains("code")) { if (json.Contains("code") && json["code"].ToString() == "1") { serial.value = ""; cardCode.value = ""; } else { if (string.IsNullOrEmpty(json["message"].ToString())) { NotificationView.ShowMessage("Có lỗi trong quá trình nạp thẻ. Bạn vui lòng thử lại!"); } else { NotificationView.ShowMessage(json["message"].ToString()); } WaitingView.Hide(); } } else { NotificationView.ShowMessage("Thông tin thẻ nạp không hợp lệ!"); WaitingView.Hide(); } flag = false; //WaitingView.Hide(); }
void OnClickCreate(GameObject go) { int numBetting = 0; for (int i = 0; i < betting.Length; i++) { if (betting[i] == null) { continue; } if (betting[i].value == true && ((ChannelPhom)GameManager.Instance.selectedChannel).bettingValues[i] == ChannelPhom.CHANNEL_BILLIONAIRE_BETTING_OTHER_VALUE) { numBetting = Convert.ToInt32(txtBetting.value) * 10000; break; } else if (betting[i].value) { numBetting = ((ChannelPhom)GameManager.Instance.selectedChannel).bettingValues[i]; } } if (GameManager.Instance.mInfo.chip < numBetting * CommonPhom.RULE_CHIP_COMPARE_BETTING || numBetting < 0) { NotificationView.ShowMessage("Mức tiền cược phải nhỏ hơn " + CommonPhom.RULE_CHIP_COMPARE_BETTING + " lần số chip của bạn, hoặc mức cược đang nhỏ hơn 0", 3f); } else { WaitingView.Show("Đang tạo bàn"); DoCreateGame(numBetting); } }
void OnAfterJoinRoom(JoinRoomEvent e) { if (cbSavePass.value) { if (IsClickButtonLogin) { StoreGame.SaveString(StoreGame.EType.SAVE_USERNAME, lableUsername.value); StoreGame.SaveString(StoreGame.EType.SAVE_PASSWORD, lablePassword.value); } } //else //{ // StoreGame.Remove(StoreGame.EType.SAVE_ACCESSTOKEN); // StoreGame.Remove(StoreGame.EType.SAVE_USERNAME); // StoreGame.SaveString(StoreGame.EType.SAVE_PASSWORD, lablePassword.text); //} //OK Next Scene if (GameManager.Instance.selectedLobby.gameId != 0) { return; } WaitingView.Hide(); NotificationView.Instance.HideMessageView(); GameManager.LoadScene(ESceneName.HallSceen); }
public void DoLogin() { WaitingView.Show("Đang đăng nhập"); LoginRequest loginRequest = new LoginRequest(); if (string.IsNullOrEmpty(GameManager.Instance.accessToken)) { loginRequest.Password = GameManager.Instance.passwordLogin; } loginRequest.UserName = GameManager.Instance.userNameLogin; if (!string.IsNullOrEmpty(GameManager.Instance.accessToken)) { loginRequest.EsObject = Utility.SetEsObject(null, new object[] { "isLogin2Phase", true, "accessToken", GameManager.Instance.accessToken }); } else { loginRequest.EsObject = Utility.SetEsObject(null, new object[] { "isLogin2Phase", true, }); } DoRequest(loginRequest); }
private void DoCreateGame(int betting) { WaitingView.Show("Đang tạo bàn"); Debug.Log("DoCreateGame"); EsObject gameConfig = new EsObject(); string roomName = txtRoomName.value; if (string.IsNullOrEmpty(roomName)) { roomName = "Bàn chơi của " + GameManager.Instance.mInfo.username; } gameConfig.setInteger(LobbyTLMN.DEFINE_GAME_TYPE_TLMN, ruleMain[0].value ? (int)LobbyTLMN.GameConfig.GameTypeLTMN.DEM_LA : (int)LobbyTLMN.GameConfig.GameTypeLTMN.XEP_HANG); gameConfig.setString(LobbyTLMN.DEFINE_LOBBY_NAME, roomName); gameConfig.setString(LobbyTLMN.DEFINE_LOBBY_PASWORD, txtPassword.value.Trim()); gameConfig.setInteger(LobbyTLMN.DEFINE_BETTING, betting); gameConfig.setBoolean(LobbyTLMN.DEFINE_USING_CHATCHONG_RULE, ruleSub[0].value); gameConfig.setBoolean(LobbyTLMN.DEFINE_USING_TYPE_RULE, ruleMain[0].value);//True Cơ bản, False Nâng Cao gameConfig.setStringArray(LobbyTLMN.DEFINE_INVITED_USERS, new string[0]); GameManager.Server.DoRequestPlugin(Utility.SetEsObject(Fields.RESPONSE.CREATE_GAME, new object[] { "config", gameConfig })); }
void onLoginExitoso(string message) { WaitingView.Show("Đang đăng nhập"); if (onLogin != null) { onLogin(true, JsonMapper.ToObject(message)); } }
void ProcessInputPassword(string inputDialog) { if (PlaySameDevice.IsCanJoinGameplay) { WaitingView.Show("Đang vào phòng"); GameManager.Server.DoJoinGame(inputDialog.Trim()); } }
public void RegisterHeaderMenu() { HeaderMenu.Instance.OnClickButtonBackCallBack = delegate() { WaitingView.Show("Đang thoát"); GameManager.Instance.currentTournamentInfo = null; GameManager.Server.DoJoinRoom(GameManager.Instance.channelRoom.zoneId, GameManager.Instance.channelRoom.roomId); }; }
public void Execute() { WaitingView.Show("Chờ xử lý"); AttributeRechargeCard attribute = Utility.EnumUtility.GetAttribute <AttributeRechargeCard>(model.ETypeCard); ServerWeb.StartThread(ServerWeb.URL_SEND_RECHARGE, new object[] { "username", GameManager.Instance.mInfo.username, "txtSoSeri", serial.value, "txtSoPin", cardCode.value, "select_method", attribute.text_id }, ProcessAfterRecharge); flag = false; }
void OnShowDetail(GameObject obj) { if (tableId > 0) { WaitingView.Show("Vui lòng đợi"); GameManager.Server.DoRequestPlugin(Utility.SetEsObject(Fields.REQUEST.COMMAND_MATCH_LIST, new object[] { "groupId", tableId, "tournamentId", GameManager.Instance.currentTournamentInfo.tournamentId })); } }
void OnClick() { WaitingView.Show("Đang vào phòng"); GameManager.Instance.hallRoom.gameId = this.info.gameId; GameManager.Server.DoRequestPlugin(Utility.SetEsObject("getLevel", new object[] { "appId", GameManager.Instance.hallRoom.gameId })); GameManager.Server.DoJoinRoom(info.zoneId, info.roomId); }
public override void OnSelectTabbarAtIndex(int index) { if (tabbarPanel [index].gameObject.GetComponent <ProfileTabInfo> () != null) { tabbarPanel [index].gameObject.GetComponent <ProfileTabInfo> ().initUserInfo(); } else if (tabbarPanel [index].gameObject.GetComponent <ProfileTabSettingView> () != null) { tabbarPanel [index].gameObject.GetComponent <ProfileTabSettingView> ().initInformation(); } else if (tabbarPanel [index].gameObject.GetComponent <ProfileTabMessageView> () != null) { tabbarPanel[index].gameObject.GetComponent <ProfileTabMessageView>().gridMessageSystem.Reposition(); tabbarPanel[index].gameObject.GetComponent <ProfileTabMessageView>().gridInvited.Reposition(); tabbarPanel[index].gameObject.GetComponent <ProfileTabMessageView>().gridFriend.Reposition(); if (!hadRequestMessage && GameManager.Instance.mInfo.messages.Count == 0) { WaitingView.Show("Đang tải dữ liệu"); if (!hadRequestMessage) { GameManager.Server.DoRequestCommand(Fields.REQUEST.GET_MESSAGE); hadRequestMessage = true; } if (!hadRequestBuddies) { hadRequestBuddies = true; GameManager.Server.DoRequestCommand(Fields.REQUEST.GET_BUDDIES); } } else { if (StoreGame.Contains(StoreGame.EType.SEND_FRIEND_MESSAGE)) { tabbarPanel[index].gameObject.GetComponent <ProfileTabMessageView>().OnResponseMessageHandler(); } else { tabbarPanel[index].gameObject.GetComponent <ProfileTabMessageView>().reLoadListMessageFriendWhenSelectTabMessage(); } } numberTabMessage.gameObject.SetActive(index != 1); } else if (tabbarPanel [index].gameObject.GetComponent <ProfileTabFriend> () != null) { tabbarPanel[index].gameObject.GetComponent <ProfileTabFriend>().tableFriend.Reposition(); if (!hadRequestBuddies && GameManager.Instance.mInfo.buddies.Count == 0) { WaitingView.Show("Đang tải dữ liệu"); hadRequestBuddies = true; GameManager.Server.DoRequestCommand(Fields.REQUEST.GET_BUDDIES); } } }
void OnRegister(GameObject obj) { if (!cbPolicy.value) { NotificationView.ShowMessage("Bạn phải đồng ý với điều khoản!"); return; } WaitingView.Show("Đăng đăng ký"); GameManager.Server.DoRequestPlugin(Utility.SetEsObject(Fields.REQUEST.COMMAND_REGISTERTOURNAMENT, new object[] { "id", tournamentInfo.tournamentId })); }
/// <summary> /// Logged messages are sent through this callback function. /// </summary> /// <param name="message">The message itself.</param> /// <param name="stackTrace">A trace of where the message came from.</param> /// <param name="type">The type of message: error/exception, warning, or assert.</param> void HandleLog(string message, string stackTrace, LogType type) { ConsoleMessage entry = new ConsoleMessage(message, stackTrace, type); entries.Add(entry); if (entries.Count > LIMIT_LINE) { entries.RemoveAt(0); } if (GameManager.CurrentScene == ESceneName.GameplayChan && type == LogType.Exception) { WaitingView.Show("Có l?i x?y ra. Vui lòng d?i!"); GameManager.Server.DoRequestGameCommand("refreshGame"); } entriesConsole.Add(entry); if (entriesConsole.Count > LIMIT_LINE_CONSOLE) { entriesConsole.RemoveAt(0); } if (type == LogType.Error && !message.StartsWith("Coroutine couldn't be started because the the game object")) { StoreGame.ClearLog(); for (int i = 0; i < entries.Count; i++) { StoreGame.SaveLog(StoreGame.EType.DEBUG_LOG, entries[i].message); } //SaveLogToFile(); //for test string url = ServerWeb.URL_REQUEST_ERROR; string data = ConvertStringToJson(StoreGame.LoadString(StoreGame.EType.DEBUG_LOG)); WWWForm form = new WWWForm(); form.AddField("app_id", GameManager.GAME.ToString()); form.AddField("game_version", GameSettings.CurrentVersion); if (GameManager.CurrentScene != ESceneName.LoginScreen) { form.AddField("user_id", GameManager.Instance.mInfo.id); form.AddField("username", GameManager.Instance.mInfo.username); } form.AddField("scene", GameManager.CurrentScene.ToString()); form.AddField("error", ""); form.AddField("detail", ""); form.AddField("environment", Common.GetDevice); form.AddField("debug_log", data); form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier); if (!listSendError.Contains(form)) { listSendError.Add(form); ServerWeb.StartThread(url, form, null); } } }
IEnumerator _ProressAfterLoginFacebook(bool isDone, WWW textResponse, IDictionary json) { if (isDone) { WaitingView.Hide(); switch (json["code"].ToString()) { case "1": WaitingView.Show("Đang đăng nhập"); GameManager.Instance.accessToken = json["accessToken"].ToString(); GameManager.Instance.userNameLogin = json["username"].ToString(); GameManager.Server.DoLogin(); break; case "-1": reLoginFaceBook(); break; case "-2": if (Application.isWebPlayer) { GameManager.Instance.UpdateCookieString(); while (GameManager.Instance.Cookie.Length == 0) { yield return(new WaitForEndOfFrame()); } string[] arr = GameManager.Instance.Cookie.Split(';'); Array.ForEach(arr, c => { if (c.Contains("PHPSESSID")) { cookie = c; } }); } else { cookie = textResponse.responseHeaders[ServerWeb.PHP_COOKIE]; } if (GameObject.Find("LoginScreen Code") != null) { GameObject.Find("LoginScreen Code").gameObject.GetComponent <LoginScreenView>().formRegister.GetComponent <RegisterView>().SessionId = cookie; GameObject.Find("LoginScreen Code").gameObject.GetComponent <LoginScreenView>().formRegister.GetComponent <RegisterView>().iUsername.value = json["suggestUser"].ToString(); if (GameObject.Find("LoginScreen Code").gameObject.GetComponent <LoginScreenView>().IsFormRegisterHide) { GameObject.Find("LoginScreen Code").gameObject.GetComponent <LoginScreenView>().ShowFormRegister(); } } //RegisterView.Create(cookie, json["suggestUser"].ToString()); break; } } }
protected virtual void OnLeaveRoom(LeaveRoomEvent e) { Debug.Log(this.GetType().ToString() + ": " + "LeaveRoomEvent !!! Zone:" + e.ZoneId + " Room:" + e.RoomId); if (EventLeaveRoom != null) { //Debug.Log(LogEvent(EventLeaveRoom)); EventLeaveRoom(e); } WaitingView waiting = GameObject.FindObjectOfType <WaitingView>(); if (waiting) { waiting.Close(); } }
void _ChangeInformation() { //string[] array = txtFullname.value.Split(" ".ToCharArray(), StringSplitOptions.None); string[] array = txtFullname.value.Trim().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); User user = GameManager.Instance.mInfo; user.firstName = user.lastName = user.middleName = ""; if (array.Length > 2) { user.lastName = array[0]; user.firstName = array[array.Length - 1]; user.middleName = ""; for (int i = 1; i < array.Length - 1; i++) { user.middleName += array[i] + " "; } } else if (array.Length == 1) { user.firstName = array[0]; } else if (array.Length == 2) { user.lastName = array[0]; user.firstName = array[array.Length - 1]; } string birthday = txtDay.value + "/" + txtMonth.value + "/" + txtYear.value; user.brithday = Utility.Convert.StringToTime(birthday, "vi-VN"); user.address = txtAddress.value; user.gender = cbMale.value ? "male" : "female"; String json = convertUserInfoToJson(user); WWWForm form = new WWWForm(); form.AddField(ServerWeb.PARAM_TYPE, ServerWeb.TYPE_CHANGE_INFO); form.AddField(ServerWeb.PARAM_DATA, json); form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier); WaitingView.Show("Đang lưu thông tin"); ServerWeb.StartThread(ServerWeb.URL_CHANGE_INFORMATION, form, ProcessAfterChangeInformation); }
private void reLoginFaceBook() { WaitingView.Show("Đang lấy thông tin từ Facebook"); #if UNITY_WEBPLAYER FacebookWeb.login("email,publish_actions,publish_stream"); #else CallLogin(); #endif //#if UNITY_ANDROID // FacebookAndroid.logout(); // FacebookAndroid.loginWithPublishPermissions(FB_PERMISSION); //#elif UNITY_IPHONE // FacebookBinding.logout(); // FacebookBinding.loginWithReadPermissions(FB_PERMISSION); // WaitingView.Show("Chờ phản hồi từ Facebook"); // FacebookWeb.login("email,publish_actions,publish_stream"); //#endif }
void Awake() { CUIHandle.AddClick(imageAds.GetComponent <CUIHandle>(), OnClickAds); CUIHandle.AddClick(btCreateRoom, CLickButtonCreate); CUIHandle.AddClick(btQuickplay, ClickButtonQuick); GameManager.Server.EventPluginMessageOnProcess += OnProcessPluginMessage; GameManager.Server.EventJoinRoom += OnAfterJoinRoom; GameManager.Server.EventLoadSence += OnJoinGame; GameManager.Server.EventPublicMessage += OnPublicMessage; GameManager.Instance.applicationStart.EventLoadAnnounce += OnLoadAnnounceDone; HeaderMenu.Instance.ReDraw(); HeaderMenu.Instance.OnClickButtonBackCallBack = delegate() { WaitingView.Show("Đang thoát"); Debug.Log("Channel current selected:" + GameManager.Instance.channelRoom.roomId + "," + GameManager.Instance.channelRoom.zoneId); GameManager.Server.DoJoinRoom(GameManager.Instance.channelRoom.zoneId, GameManager.Instance.channelRoom.roomId); }; }
void Awake() { this.tournamentInfo = GameManager.Instance.currentTournamentInfo; CUIHandle.AddClick(btnRegister, OnRegister); CUIHandle.AddClick(btnBack, OnClickBack); GameManager.Server.EventPluginMessageOnProcess += OnProcessPluginMessage; GameManager.Server.EventJoinRoom += OnAfterJoinRoom; if (GameManager.CurrentScene == ESceneName.Tournament) { HeaderMenu.Instance.OnClickButtonBackCallBack = delegate() { WaitingView.Show("Đang thoát"); GameManager.Instance.currentTournamentInfo = null; GameManager.Server.DoJoinRoom(GameManager.Instance.currentRoomGiaiDau.zoneId, GameManager.Instance.currentRoomGiaiDau.roomId); }; } GameManager.Instance.displayTournamentMenu = true; HeaderMenu.Instance.ReDraw(); }
/// <summary> /// Sự kiện xảy ra khi bạn logout ứng dụng /// </summary> public void DoLogOut() { StoreGame.Remove(StoreGame.EType.DEBUG_LOG); //REMOVE DEBUG_LOG StoreGame.SaveString(StoreGame.EType.BOOL_SEND_LOG_TO_SERVER, "false"); //REMOVE DEBUG_LOG WaitingView.Hide(); if (Application.loadedLevelName == ESceneName.LoginScreen.ToString()) { Disconnect(); return; } //DoLeaveCurrentRoom(); LogOutRequest logOutRequest = new LogOutRequest(); DoRequest(logOutRequest); #region BUILD WEB ESIMO COMMENT VAO KHI BUILD CHO FACEBOOK #if UNITY_WEBPLAYER switch (GameSettings.Instance.TypeBuildFor) { case GameSettings.EBuildType.esimo: case GameSettings.EBuildType.web_esimo: Application.ExternalEval("window.location = \"/site/logout\""); break; } #endif #endregion StoreGame.Remove(StoreGame.EType.SAVE_USERNAME); StoreGame.Remove(StoreGame.EType.SAVE_PASSWORD); StoreGame.Remove(StoreGame.EType.SAVE_ACCESSTOKEN); if (es.Engine.Connected) { es.Engine.Close(); } if ((FB.IsLoggedIn || !string.IsNullOrEmpty(FB.AccessToken)) && !Application.isWebPlayer) { FB.Logout(); } Disconnect(); GameManager.LoadScene(ESceneName.LoginScreen); }
private void OnAfterJoinRoom(JoinRoomEvent e) { WaitingView.Hide(); //lưu lại thông tin channel select to back button GameManager.Instance.channelRoom = new RoomInfo(e.ZoneId, e.RoomId); switch (e.RoomName.ToLower()) { case "phom": GameManager.LoadScene(ESceneName.ChannelPhom); break; case "tlmn": GameManager.LoadScene(ESceneName.ChannelTLMN); break; case "chan": GameManager.LoadScene(ESceneName.ChannelChan); break; default: Debug.LogError("Cannot find any game"); break; } }
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; }
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"); } } }
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(); }
// Use this for initialization void Start() { WaitingView.Show("Đang lấy dữ liệu. Vui lòng đợi"); GameManager.Server.DoRequestCommand(Fields.REQUEST.COMMAND_TOURNAMENT); gridTournament.GetComponent <UICenterOnChild>().onCenter = ShowDetail; }
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); } } }