void SendMessageGetGoldDaily() { SubServerDetail _serverDetail = GetGoldScreenController.instance.GetServerDetail(); OneHitAPI.GetGoldDaily(_serverDetail, (_messageReceiving, _error) => { if (_messageReceiving != null) { DataManager.instance.dailyRewardData.RecieveReward(_messageReceiving, (_caseCheck) => { if (_caseCheck == -2) { DataManager.instance.dailyRewardData.hadCheckSv = true; ShowEffCanNotGetReward(); } else if (_caseCheck == 1) { DataManager.instance.dailyRewardData.hadCheckSv = true; GetGoldScreenController.instance.RefreshMyGoldInfo(false); if (HomeManager.instance != null && HomeManager.instance.myCallbackManager != null && HomeManager.instance.myCallbackManager.onLoadDataGoldGemFinished != null) { HomeManager.instance.myCallbackManager.onLoadDataGoldGemFinished(); } } }); RefreshData(); } else { #if TEST Debug.LogError("GetGoldDaily Error: " + _error); #endif } } ); }
public void LoadDataGoldGemFromServer() { OneHitAPI.GetGoldGemById(DataManager.instance.userData.databaseId, DataManager.instance.userData.userId, (_messageReceiving, _error) => { if (_messageReceiving != null) { DataManager.instance.userData.gold = _messageReceiving.readLong(); #if TEST Debug.Log(">>>Recieving Data GetGoldGemById: Gold: " + DataManager.instance.userData.gold); #endif if (HomeManager.instance != null) { if (HomeManager.instance.myCallbackManager != null && HomeManager.instance.myCallbackManager.onLoadDataGoldGemFinished != null) { HomeManager.instance.myCallbackManager.onLoadDataGoldGemFinished(); } HomeManager.instance.CheckShowRemindRating(); } HomeManager.getGoldAndGemInfoAgain = false; } else { #if TEST Debug.LogError("Lỗi GetGoldGemById. Error code: " + _error); #endif } }); }
void CallBackLoginFb() { Debug.Log("Login FB successful!"); // AccessToken class will have session details var aToken = Facebook.Unity.AccessToken.CurrentAccessToken; Debug.Log("UserID: " + aToken.UserId); LoadingCanvasController.instance.Show(-1, true); OneHitAPI.LoginWithFacebookAccount(DataManager.instance.userData.userId, aToken.TokenString, (_messageReceiving, _error) => { LoadingCanvasController.instance.Hide(); if (_messageReceiving != null) { sbyte _caseCheck = _messageReceiving.readByte(); switch (_caseCheck) { case -1: // Lỗi kết nối đến database. PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString(MyLocalize.kSystemError) , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); break; case 1: // thành công DataManager.instance.userData.GetMoreUserData(_messageReceiving); #if TEST Debug.Log(">>> ReceiveLogin (Thành công) : " + DataManager.instance.userData.userId + " - " + DataManager.instance.userData.gold); #endif SetUpChangeScreenChooseGame(); break; default: #if TEST Debug.LogError(">>> Trả caseCheck tào lao: " + _caseCheck); #endif PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString(MyLocalize.kSystemError) , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); break; } } else { PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString(MyLocalize.kConnectionError) , _error.ToString() , MyLocalize.GetString(MyLocalize.kOk)); } }); }
public IEnumerator DoActionGetFirstDataOnAndroid() { #if TEST Debug.Log(">>> Get Sub Server Detail!"); #endif bool _isFinished = false; yield return(Yielders.EndOfFrame); OneHitAPI.GetSplashData_Android((short)DataManager.instance.currentLanguage, Application.identifier, (_mess, _error) => { if (_mess != null) { long _featureVersion = _mess.readLong(); // nhỏ hơn giá trị này --> thông báo update #if TEST Debug.Log(">>> Version: " + _featureVersion + " - " + MyConstant.featureVersionCore); #endif if (MyConstant.featureVersionCore < _featureVersion) { DataManager.instance.haveNewVersion = true; } DataManager.instance.packageNameUpdate = _mess.readString(); // ==> setup vào myconstance.linkApp DataManager.instance.announcement = _mess.readString(); // ------------- GoldDaily ------------- // InitGoldDailyData(_mess); // ------------------------------------- // // ------------- List IP For Onehit ------------- // InitListIPForOnehit(_mess); // ---------------------------------------------- // // ------------- List Sub Server ------------- // InitListSubServer(_mess); // ------------------------------------------ // // ------------- List IAP Product ------------- // InitIAPProductData(_mess); // ------------------------------------------ // DataManager.instance.getFirstDataSuccessfull = true; } else { #if TEST Debug.LogError(">>> TestGetSplashData_Android Error Code: " + _error); #endif } _isFinished = true; }); yield return(new WaitUntil(() => _isFinished)); }
public void DoAction() { Debug.Log(">>>>> press here"); OneHitAPI.LoginWithFacebookAccount(0, "EAAbYZC5sZAkmQBAOazBAc5VKewZBWgOiBRKIuvXisd9SdZCJfTHiJo5tZCq16Ac49WDww1ertw80lbjm9nKgtx63LNJ0rAradirDa7lFVo5TI7KYvpOYLGOckU2Jf9qo8ZCrA2JbANOWS5blSsMZBACtqZCdR08lIDZCgOAZAbX3TG2SHxBfEvZB9avUmJ8qxq3hz8ZD", (_messageReceiving, _error) => { sbyte _caseCheck = _messageReceiving.readByte(); sbyte _databaseid = _messageReceiving.readByte(); ////////////////////////////////////////////////////////////// long _facebookid = _messageReceiving.readLong(); string _token_for_business = _messageReceiving.readString(); Debug.LogError(_caseCheck + " - " + _databaseid + " - " + _facebookid + " - " + _token_for_business); }); }
public void Login_OnButtonPlayAsGuestClicked() { MyAudioManager.instance.PlaySfx(GameInformation.instance.globalAudioInfo.sfx_Click); LoadingCanvasController.instance.Show(-1, true); OneHitAPI.LoginWithDeviceID(DataManager.instance.userData.userId, (_messageReceiving, _error) => { LoadingCanvasController.instance.Hide(); if (_messageReceiving != null) { sbyte _caseCheck = _messageReceiving.readByte(); switch (_caseCheck) { case -1: // Lỗi kết nối đến database. PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString(MyLocalize.kSystemError) , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); break; case 1: // thành công DataManager.instance.userData.GetMoreUserData(_messageReceiving); #if TEST Debug.Log(">>> ReceiveLogin (Thành công) : " + DataManager.instance.userData.userId + " - " + DataManager.instance.userData.gold); #endif SetUpChangeScreenChooseGame(); break; default: #if TEST Debug.LogError(">>> Trả caseCheck tào lao: " + _caseCheck); #endif PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString(MyLocalize.kSystemError) , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); break; } } else { PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString(MyLocalize.kConnectionError) , _error.ToString() , MyLocalize.GetString(MyLocalize.kOk)); } }); }
public void LoadEmailInfoFromServer() { if (DataManager.instance.userData.databaseId != UserData.DatabaseType.DATABASEID_BIGXU || !string.IsNullOrEmpty(DataManager.instance.userData.emailShow)) { getEmailInfoAgain = false; return; } OneHitAPI.BigxuAccount_GetEmailSecurity((_messageReceiving, _error) => { if (_messageReceiving != null) { sbyte _caseCheck = _messageReceiving.readByte(); if (_caseCheck == 1) { string _emailShow = _messageReceiving.readString(); DataManager.instance.userData.emailShow = _emailShow; #if TEST Debug.Log(">>> GetEmailSecurity thành công: " + _emailShow); #endif if (HomeManager.instance != null) { if (HomeManager.instance.myCallbackManager != null && HomeManager.instance.myCallbackManager.onLoadEmailInfoFinished != null) { HomeManager.instance.myCallbackManager.onLoadEmailInfoFinished(); } } HomeManager.getEmailInfoAgain = false; } else { #if TEST Debug.LogError(">>> GetEmailSecurity thất bại (0): " + _caseCheck); #endif } } else { #if TEST Debug.LogError(">>> GetEmailSecurity thất bại (1): " + _error); #endif } }); }
public void OnBtnChangePasswordClicked() { MyAudioManager.instance.PlaySfx(GameInformation.instance.globalAudioInfo.sfx_Click); PopupManager.Instance.CreatePopupChangePassword( (_currentPass, _newPass) => { // byte caseCheck (1 : đổi thành công) LoadingCanvasController.instance.Show(-1, true); OneHitAPI.BigxuAccount_ChangePassword(_currentPass, _newPass, (_messageReceiving, _error) => { LoadingCanvasController.instance.Hide(); if (_messageReceiving != null) { sbyte _caseCheck = _messageReceiving.readByte(); if (_caseCheck == 1) { // #if TEST // Debug.Log (">>> Đổi pass thành công"); // #endif DataManager.instance.userData.password = _newPass; PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kMessage) , MyLocalize.GetString("RegisAndLogin/ChangePasswordSuccessful") , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); } else { // #if TEST // Debug.LogError (">>> Đổi pass thất bại: " + _caseCheck); // #endif PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kMessage) , MyLocalize.GetString("RegisAndLogin/ChangePasswordFailed") , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); } } else { PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString(MyLocalize.kConnectionError) , _error.ToString() , MyLocalize.GetString(MyLocalize.kOk)); } }); }, null); }
void GetListAppFromServer(System.Action _onFinished = null) { OneHitAPI.GetListCampagneInstallAndroid((_messageReceiving, _error) => { if (_messageReceiving != null) { short _numberCampagne = _messageReceiving.readShort(); List <InstallAppDetail> _newListInstallApp = new List <InstallAppDetail>(); bool _canAddToList = false; for (int i = 0; i < _numberCampagne; i++) { InstallAppDetail _detail = new InstallAppDetail(_messageReceiving); _canAddToList = true; for (int j = 0; j < DataManager.instance.installAppData.listAppDone.Count; j++) { if (DataManager.instance.installAppData.listAppDone[j].IsEqual(_detail)) { _canAddToList = false; break; } } if (_canAddToList) { _newListInstallApp.Add(_detail); } } DataManager.instance.installAppData.listCurrentAppDetail = _newListInstallApp; // for(int i = 0; i < 1000; i++){ // DataManager.instance.installAppData.listCurrentAppDetail.Add(DataManager.instance.installAppData.listCurrentAppDetail[0]); // } DataManager.instance.installAppData.nextTimeToGetDataFromSever = System.DateTime.Now.AddHours(1); if (currentState == State.Show) { if (_onFinished != null) { _onFinished(); } } } else { #if TEST Debug.LogError("GetListCampagneInstallAndroid is Error: " + _error); #endif } }); }
public void OnBtnVerifyEmailClicked() { MyAudioManager.instance.PlaySfx(GameInformation.instance.globalAudioInfo.sfx_Click); PopupManager.Instance.CreatePopupVerifyEmail( (_email) => { LoadingCanvasController.instance.Show(-1, true); OneHitAPI.BigxuAccount_SetEmailSecurity(_email, (_messageReceiving, _error) => { LoadingCanvasController.instance.Hide(); if (_messageReceiving != null) { sbyte _caseCheck = _messageReceiving.readByte(); if (_caseCheck == 1) { string _emailShow = _messageReceiving.readString(); #if TEST Debug.Log(">>> Verify Email thành công: " + _emailShow); #endif DataManager.instance.userData.emailShow = _emailShow; iconWarningVerifyEmail.gameObject.SetActive(false); RefreshEmailInfo(); PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kMessage) , MyLocalize.GetString("RegisAndLogin/VerifyEmailSuccessful") , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); } else { PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kMessage) , MyLocalize.GetString("RegisAndLogin/VerifyEmailFailed") , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); } } else { PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString(MyLocalize.kConnectionError) , _error.ToString() , MyLocalize.GetString(MyLocalize.kOk)); } }); }, null); }
// IEnumerator DoActionShowEffWinGold(Vector2 _startPoint, Vector2 _endPoint, int _numGold){ // Vector2 _newStartPoint = Vector2.zero; // for(int i = 0; i < _numGold; i++){ // _newStartPoint.x = Random.Range(_startPoint.x - 0.2f, _startPoint.x + 0.2f); // _newStartPoint.y = Random.Range(_startPoint.y - 0.2f, _startPoint.y + 0.2f); // GoldObjectController _gold = LeanPool.Spawn(goldPrefab, _newStartPoint, Quaternion.identity).GetComponent<GoldObjectController>(); // effectPoolManager.AddObject(_gold); // _gold.InitData(sortingLayerInfo_GoldObject, 1); // StartCoroutine(_gold.DoActionMoveAndSelfDestruction(_endPoint, 0.5f, LeanTweenType.easeInBack, GameInformation.instance.globalAudioInfo.sfx_Gold)); // if(_numGold > 1){ // yield return Yielders.Get(0.06f); // } // } // } // IEnumerator DoActionShowPopupWinGold(float _timeDelay, long _goldAdd){ // yield return Yielders.Get(_timeDelay); // PanelBonusGoldInGameController _tmpPanelGoldBonus = LeanPool.Spawn(panelBonusGoldPrefab.gameObject, showEffPanelGoldBonusEffPlaceHolder.position, Quaternion.identity, transform).GetComponent<PanelBonusGoldInGameController>(); // effectPoolManager.AddObject(_tmpPanelGoldBonus); // _tmpPanelGoldBonus.transform.position = showEffPanelGoldBonusEffPlaceHolder.position; // _tmpPanelGoldBonus.Show(_goldAdd); // RefreshMyGoldInfo(); // } #region On Button Clicked public void OnButtonSpinClicked() { if (mIsPlaying) { return; } if (tweenWheelForever != null) { return; } MyAudioManager.instance.PlaySfx(GameInformation.instance.globalAudioInfo.sfx_Click); if (DataManager.instance.userData.gold < currentBet) { PopupManager.Instance.CreateToast(MyLocalize.GetString("Global/NotEnoughMoney")); return; } callbackGetBetWin = CallbackGetBetWin; tweenWheelForever = LeanTween.rotateAround(wheel.gameObject, Vector3.forward, 360f, 0.5f).setEase(LeanTweenType.easeInSine).setOnComplete(() => { tweenWheelForever = LeanTween.rotateAround(wheel.gameObject, Vector3.forward, 360f, 0.3f).setLoopCount(-1); }); DataManager.instance.userData.gold -= currentBet; RefreshMyGoldInfo(); // BetToWinTool _tmp = new BetToWinTool(currentBet,listBetWinValue.ToArray()); // _tmp.ProcessWeight(); // _tmp.Trace(); OneHitAPI.BetToWin(currentBet, GameInformation.instance.luckyWheelInfo.listDetail, listBetWinValue , (_mess, _error) => { if (tweenWheelForever != null) { LeanTween.cancel(tweenWheelForever.uniqueId); tweenWheelForever = null; } if (callbackGetBetWin != null) { callbackGetBetWin(_mess, _error); } }); }
public void LoadAllTablesFromSever(SubServerDetail _serverDetail, System.Action _onSuccess = null, System.Action <int> _onError = null) { short _totalTables = (short)numTableDefault; for (int i = 0; i < _serverDetail.listRoomDetail.Count; i++) { if (DataManager.instance.miniGameData.currentMiniGameDetail.myInfo.gameId == _serverDetail.listRoomDetail[i].gameId) { _totalTables = _serverDetail.listRoomDetail[i].numberTable; break; } } panelLoadingListTable.SetActive(true); OneHitAPI.GetListTableByGameID(DataManager.instance.miniGameData.currentMiniGameDetail.myInfo.gameId, 0, _totalTables, _serverDetail, (_messageReceiving, _error) => { panelLoadingListTable.SetActive(false); SetUpTableData(true, _serverDetail, _messageReceiving, _error, _onSuccess, _onError); }); }
void LoadGoldFromServer() { OneHitAPI.GetGoldGemById(DataManager.instance.userData.databaseId, DataManager.instance.userData.userId, (_messageReceiving, _error) => { if (_messageReceiving != null) { DataManager.instance.userData.gold = _messageReceiving.readLong(); #if TEST Debug.Log(">>>Recieving Data GetGoldGemById: Gold: " + DataManager.instance.userData.gold); #endif realMyGold = DataManager.instance.userData.gold; RefreshMyGoldInfo(true); } else { #if TEST Debug.LogError("Lỗi GetGoldGemById. Error code: " + _error); #endif } }); }
public void OnBtnSpinClicked() { if (actionSpin != null) { return; } ResetResultIndexCards(); callbackGetBetWin = CallbackGetBetWin; // CHEAT(); StartSpin(); // StartCoroutine(SpinCheat()); OneHitAPI.BetToWin(currentBet, GameInformation.instance.slotPokerInfo.listDetail, listBetWinValue , (_mess, _error) => { if (callbackGetBetWin != null) { callbackGetBetWin(_mess, _error); } }); }
void LoadDataFromServer() { panelLoading.gameObject.SetActive(true); OneHitAPI.GetTopGold((_messageReceiving, _error) => { if (HomeManager.instance != null) { panelLoading.gameObject.SetActive(false); } if (_messageReceiving != null) { long _tmpDeltaTimeUpdateTop = _messageReceiving.readLong(); sbyte _numberTop = _messageReceiving.readByte(); if (_numberTop > 0) { List <UserData> _listTopGold = new List <UserData>(); for (int i = 0; i < _numberTop; i++) { UserData _userData = new UserData(); _userData.InitData(); _userData.GetMoreUserData(_messageReceiving); _listTopGold.Add(_userData); } // 36134 - 1/1/1970 7:00:36 AM System.DateTime _start = new System.DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc); long _currentMillisecondsLastUpdate = MyConstant.currentTimeMilliseconds - _tmpDeltaTimeUpdateTop; DataManager.instance.leaderboardData.lastTimeUpdateTop = _start.AddMilliseconds(_currentMillisecondsLastUpdate).ToLocalTime(); DataManager.instance.leaderboardData.nextTimeToGetNewList = System.DateTime.Now.AddHours(1); DataManager.instance.leaderboardData.topGold = _listTopGold; DataManager.instance.leaderboardData.SortListTopGoldAgain(); // Debug.Log(_tmpDeltaTimeUpdateTop + " - " + DataManager.instance.leaderboardData.lastTimeUpdateTop); } if (HomeManager.instance != null) { if (currentState == State.Show) { System.DateTime _lastTimeUpdatedTop = DataManager.instance.leaderboardData.lastTimeUpdateTop; txtLastTimeUpdated.text = "Updated at: " + string.Format("{0:00}/{1:00}/{2} - {3:00}:{4:00}", _lastTimeUpdatedTop.Day, _lastTimeUpdatedTop.Month, _lastTimeUpdatedTop.Year, _lastTimeUpdatedTop.Hour, _lastTimeUpdatedTop.Minute); if (DataManager.instance.leaderboardData.topGold.Count > 0) { CreatePanels(); } else { txtEmpty.gameObject.SetActive(true); } } } } else { if (HomeManager.instance != null) { if (currentState == State.Show) { if (DataManager.instance.leaderboardData.topGold.Count > 0) { CreatePanels(); } else { txtEmpty.gameObject.SetActive(true); } } } } }); }
public void OnButtonRegisterClicked() { MyAudioManager.instance.PlaySfx(GameInformation.instance.globalAudioInfo.sfx_Click); string _userName = fieldUserName.text; if (!_userName.IsAvailableUserNameAndPass()) { PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString(MyLocalize.kUserNameIsInvalid) , string.Empty , MyLocalize.GetString(MyLocalize.kOk)); return; } string _pass = fieldPass.text; if (!_pass.IsAvailableUserNameAndPass()) { PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString(MyLocalize.kPassIsInvalid_01) , string.Empty , MyLocalize.GetString(MyLocalize.kOk)); return; } LoadingCanvasController.instance.Show(-1, true); OneHitAPI.RegisterLocalAccount(_userName, _pass, (_messageReceiving, _error) => { LoadingCanvasController.instance.Hide(); if (_messageReceiving != null) { sbyte _caseCheck = _messageReceiving.readByte(); switch (_caseCheck) { case -1: // Lỗi kết nối đến database. PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString(MyLocalize.kSystemError) , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); break; case -2: // UserName đã tồn tại. PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString(MyLocalize.kUsernameAlreadyExists) , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); break; case -3: // Lỗi không xác định của đăng ký. PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString(MyLocalize.kUnauthorizedError) , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); break; case -4: // Password quá dài. PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString(MyLocalize.kPassIsTooLong) , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); break; case 1: sbyte _databaseIdRecieve = _messageReceiving.readByte(); // --> không cần thiết string _userNameRecieve = _messageReceiving.readString(); // --> không cần thiết string _passRecieve = _messageReceiving.readString(); // --> không cần thiết DataManager.instance.userData.databaseId = UserData.DatabaseType.DATABASEID_BIGXU; DataManager.instance.userData.userId = _messageReceiving.readLong(); DataManager.instance.userData.username = fieldUserName.text; DataManager.instance.userData.password = fieldPass.text; DataManager.instance.userData.nameShowInGame = DataManager.instance.userData.username; DataManager.instance.userData.avatarid = _messageReceiving.readByte(); DataManager.instance.userData.gold = _messageReceiving.readLong(); DataManager.instance.userData.timeCreateAccount = _messageReceiving.readLong(); // DataManager.instance.userData.lastTimePlay = _messageReceiving.readLong (); #if TEST Debug.Log(">>> ReceiveRegister: (Thành công) : " + DataManager.instance.userData.userId); #endif HomeManager.instance.ChangeScreen(UIType.ChooseGame); break; default: #if TEST Debug.LogError(">>> Trả caseCheck tào lao: " + _caseCheck); #endif break; } } else { PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString(MyLocalize.kConnectionError) , _error.ToString() , MyLocalize.GetString(MyLocalize.kOk)); } }); }
public void SendMessageToServer(SubServerDetail _serverDetail, System.Action <List <RewardDetail> > _onSucceed, System.Action _onFinished, bool _sendInSilent = false) { if (isDone) { return; } #if UNITY_ANDROID OneHitAPI.IAP_Android(_serverDetail, screenPurchase, productId, tokenPurchase, (_messageReceiving, _error) => { if (_messageReceiving != null) { sbyte _caseCheck = _messageReceiving.readByte(); if (_caseCheck == 1 || _caseCheck < -100) { if (_caseCheck == 1) { long _goldAdd = _messageReceiving.readLong(); DataManager.instance.userData.gold = _messageReceiving.readLong(); if (_onSucceed != null) { IAPProductDetail _productDetail = DataManager.instance.IAPProductData.GetProductDetail(productId); if (_productDetail == null) { #if TEST Debug.LogError(">>> productDetail is null in data: " + productId); #endif } List <RewardDetail> _tmplistRewardDetail = new List <RewardDetail>(); RewardDetail _rewardDetail = new RewardDetail(IItemInfo.ItemType.Gold, _goldAdd); _tmplistRewardDetail.Add(_rewardDetail); _onSucceed(_tmplistRewardDetail); } } else { #if TEST Debug.LogError(">>> IAP_Android Trường hợp check case = " + _caseCheck); #endif } isDone = true; } else { // #if TEST // Debug.LogError(">>> IAP_Android can not Purchase: " + _caseCheck); // #endif // private static final byte STATUS_PURCHASE_OK=1; // private static final byte STATUS_REFUND=-122; // private static final byte STATUS_ERROR_PURCHASE_PROCESSED_DaXuLyRoi=-125; // private static final byte STATUS_DATABASE_ERROR_1=-21; // private static final byte STATUS_VERIFY_PURCHASE_GOOGLE_API_ERROR=-22; // private static final byte STATUS_ERROR_GOLD_MAIN=-23; // private static final byte STATUS_VALIDATE_ERROR=-24; // private static final byte STATUS_PLAYER_ERROR=-25; if (_caseCheck == -22) { string _tmp = _messageReceiving.readString(); #if TEST Debug.LogError(">>> Error IAP_Android: STATUS_VERIFY_PURCHASE_GOOGLE_API_ERROR - " + _tmp); #endif } if (!_sendInSilent) { PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString("Error/IAP_CanNotPurchase") , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); } else { #if TEST Debug.LogError(">>> Error IAP_Android: " + MyLocalize.GetString("Error/IAP_CanNotPurchase") + " - " + _caseCheck); #endif } } } else { // #if TEST // Debug.LogError(">>> IAP_Android Error Code: " + _error); // #endif /* 1/ Thông báo : lỗi network --> show nut refresh * 2/ Thông báo : hông được clear dữ liệu + nếu tắt ứng dụng ngay lúc này thì : lần kết nối sau sẽ tự động cộng tiền khi có kết nối với server */ if (!_sendInSilent) { PopupManager.Instance.CreatePopupDialog(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString("Error/IAP_PurchaseUnsuccessful") , _error.ToString() , MyLocalize.GetString(MyLocalize.kTryAgain) , MyLocalize.GetString(MyLocalize.kOk) , () => { SendMessageToServer(_serverDetail, _onSucceed, _onFinished); } , () => { // IAP_Warning_CloseConnectToSv PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kWarning) , MyLocalize.GetString("System/IAP_Warning_CloseConnectToSv") , string.Empty , MyLocalize.GetString(MyLocalize.kOk)); }); } else { #if TEST Debug.LogError(">>> Error IAP_Android: " + MyLocalize.GetString("Error/IAP_PurchaseUnsuccessful") + " - " + _error); #endif } } if (_onFinished != null) { _onFinished(); } }); #elif UNITY_IOS //TODO: Chưa làm cho IOS Debug.Log("Chưa làm"); #endif }
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args) { Debug.Log("Purchase OK: " + args.purchasedProduct.definition.id); Debug.Log("Receipt: " + args.purchasedProduct.receipt); // var unifiedReceipt = JsonUtility.FromJson<UnifiedReceipt>(args.purchasedProduct.receipt); // if (unifiedReceipt != null && !string.IsNullOrEmpty(unifiedReceipt.Payload)) // { // var purchaseReceipt = JsonUtility.FromJson<UnityChannelPurchaseReceipt>(unifiedReceipt.Payload); // Debug.LogFormat( // "UnityChannel receipt: storeSpecificId = {0}, transactionId = {1}, orderQueryToken = {2}", // unifiedReceipt.Store, unifiedReceipt.TransactionID, purchaseReceipt.orderQueryToken); // } //Cheat for Editor #if UNITY_EDITOR purchasingProductId = string.Empty; SubServerDetail _serverDetail = GetGoldScreenController.instance.GetServerDetail(); LoadingCanvasController.instance.Show(-1f, true); OneHitAPI.TESTIAP(_serverDetail, (_messageReceiving, _error) => { LoadingCanvasController.instance.Hide(); if (_messageReceiving != null) { bool _isSuccess = _messageReceiving.readBoolean(); if (_isSuccess) { DataManager.instance.userData.gold = _messageReceiving.readLong(); GetGoldScreenController.instance.RefreshMyGoldInfo(false); } else { #if TEST Debug.LogError("TESTIAP false"); #endif } } else { #if TEST Debug.LogError("Error code: " + _error); #endif } }); // ApplyIAPPackage (args.purchasedProduct.definition.id); return(PurchaseProcessingResult.Complete); #endif #if UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX CrossPlatformValidator validator = new CrossPlatformValidator(GooglePlayTangle.Data(), AppleTangle.Data(), Application.identifier); string receipt = args.purchasedProduct.receipt; try { // On Google Play, result has a single product ID. // On Apple stores, receipts contain multiple products. var result = validator.Validate(receipt); foreach (IPurchaseReceipt productReceipt in result) { ApplyIAPPackage(productReceipt.productID, productReceipt); } } catch (IAPSecurityException e) { PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString("Error/IAP_FailedToVerifyReceipt") , string.Empty , MyLocalize.GetString(MyLocalize.kOk)); if (onPurchaseFailed != null) { onPurchaseFailed(PurchaseFailureReason.SignatureInvalid); } } #endif purchasingProductId = string.Empty; return(PurchaseProcessingResult.Complete); }
public void RecieveReward(System.Action _onRecieveRewardSuccessfully, System.Action _onClearData) { LoadingCanvasController.instance.Show(1f); OneHitAPI.Forward_Bonus_AndroidInstall_Commit(packageName, (_messageReceiving, _error) => { LoadingCanvasController.instance.Hide(); if (_messageReceiving != null) { sbyte _caseCheck = _messageReceiving.readByte(); // (nếu 1 thì đọc tiếp) bool _tmpFlag = false; if (_caseCheck == 1) { int _goldAdd = _messageReceiving.readInt(); long _goldResult = _messageReceiving.readLong(); DataManager.instance.userData.gold = _goldResult; RewardDetail _reward = new RewardDetail(IItemInfo.ItemType.Gold, _goldAdd); PopupManager.Instance.CreatePopupReward(_reward); if (_onRecieveRewardSuccessfully != null) { _onRecieveRewardSuccessfully(); } _tmpFlag = true; } else { switch (_caseCheck) { case -1: // nhiệm vụ không còn tồn tại (clear data) PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kWarning) , MyLocalize.GetString("Error/InstallApp_Error_1") , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); _tmpFlag = true; break; case -2: // lỗi không load được database tracking cài đặt PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kWarning) , MyLocalize.GetString("Error/InstallApp_Error_2") , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); break; case -3: // đã nhận thưởng rồi (clear data) PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kWarning) , MyLocalize.GetString("Error/InstallApp_Error_3") , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); _tmpFlag = true; break; case -4: // nhiệm vụ hết hạn (clear data) PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kWarning) , MyLocalize.GetString("Error/InstallApp_Error_4") , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); _tmpFlag = true; break; case -5: // không lấy được thông tin người chơi (user này chưa đăng ký) PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kWarning) , MyLocalize.GetString("Error/InstallApp_Error_5") , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); break; default: #if TEST Debug.LogError("Forward_Bonus_AndroidInstall_Commit other error from sever: " + _caseCheck); #endif break; } } if (_tmpFlag) { currentState = State.Done; if (myOriginalDetail != null) { myOriginalDetail.currentState = State.Done; } if (_onClearData != null) { _onClearData(); } } } else { #if TEST Debug.LogError("RecieveReward InstallApp Reward error: " + _error); #endif } }); }
public override void InitData() { if (!isInitializedListAchievement) { listPanelAchievement = new List <UserDetail_PanelAchievementOption_Controller> (); for (int i = 0; i < DataManager.instance.achievementData.listAchievementDetail.Count; i++) { UserDetail_PanelAchievementOption_Controller _achievementInfo = ((GameObject)Instantiate(prefabAchievementOption, myAchievementDetailContent, false)).GetComponent <UserDetail_PanelAchievementOption_Controller> (); _achievementInfo.InitData(DataManager.instance.achievementData.listAchievementDetail[i]); listPanelAchievement.Add(_achievementInfo); } isInitializedListAchievement = true; } else { for (int i = 0; i < listPanelAchievement.Count; i++) { listPanelAchievement[i].InitData(DataManager.instance.achievementData.listAchievementDetail[i]); } } if (DataManager.instance.userData.databaseId == UserData.DatabaseType.DATABASEID_FACEBOOK) { listAvatar[0].texture = GameInformation.instance.otherInfo.avatarDefault; DataManager.instance.userData.LoadAvatarFromLink(CoreGameManager.instance, listAvatar[0].rectTransform.rect.width, listAvatar[0].rectTransform.rect.height, (_avatar) => { listAvatar[0].texture = _avatar; }); } avatarIdSaved = DataManager.instance.userData.avatarid; LoadUserInfo(); if (DataManager.instance.userData.databaseId == UserData.DatabaseType.DATABASEID_BIGXU) { panelButtonsConfigAccount.gameObject.SetActive(true); txtBtn_FieldChangePass.text = MyLocalize.GetString("RegisAndLogin/Field_ChangePassword"); txtBtn_FieldVerifyEmail.text = MyLocalize.GetString("RegisAndLogin/Field_VerifyEmail"); panelContainEmail.gameObject.SetActive(true); if (string.IsNullOrEmpty(DataManager.instance.userData.emailShow)) { iconWarningVerifyEmail.gameObject.SetActive(true); iconWarningVerifyEmail.Play(); } else { iconWarningVerifyEmail.gameObject.SetActive(false); } } else { panelContainEmail.gameObject.SetActive(false); panelButtonsConfigAccount.gameObject.SetActive(false); } RefreshEmailInfo(); HomeManager.instance.myCallbackManager.onLoadEmailInfoFinished += CheckRefreshEmailInfo; onPressBack = () => { HomeManager.instance.ChangeScreen(myLastType); if (avatarIdSaved != DataManager.instance.userData.avatarid) { OneHitAPI.ChooseAvatar(DataManager.instance.userData.databaseId, DataManager.instance.userData.userId, DataManager.instance.userData.avatarid, null); } }; CoreGameManager.instance.RegisterNewCallbackPressBackKey(onPressBack); }
/*public void OnButtonFakeIpClicked () * { * // --- FOR TEST --- // * NetworkGlobal.instance.ipOneHit = "192.168.1.5"; * NetworkGlobal.instance.ipRealTime = "192.168.1.5"; * // ---------------- // * }*/ public void Login_OnButtonLoginClicked() { MyAudioManager.instance.PlaySfx(GameInformation.instance.globalAudioInfo.sfx_Click); string _userName = login_fieldUserName.text.Trim(); if (_userName.Length < 3 || _userName.Length > 25) { PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kWarning) , MyLocalize.GetString("RegisAndLogin/Username_Error_0") , string.Empty , MyLocalize.GetString(MyLocalize.kOk)); return; } if (!_userName.IsAvailableUserNameAndPass()) { PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kWarning) , MyLocalize.GetString(MyLocalize.kUserNameIsInvalid) , string.Empty , MyLocalize.GetString(MyLocalize.kOk)); return; } string _pass = login_fieldPass.text.Trim(); if (_pass.Length < 3 || _pass.Length > 25) { PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kWarning) , MyLocalize.GetString("RegisAndLogin/Password_Error_0") , string.Empty , MyLocalize.GetString(MyLocalize.kOk)); return; } if (!_pass.IsAvailableUserNameAndPass()) { PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kWarning) , MyLocalize.GetString("RegisAndLogin/PassIsInvalid_01") , string.Empty , MyLocalize.GetString(MyLocalize.kOk)); return; } LoadingCanvasController.instance.Show(-1, true); OneHitAPI.LoginWithLocalAccount(DataManager.instance.userData.userId, _userName, _pass, (_messageReceiving, _error) => { LoadingCanvasController.instance.Hide(); if (_messageReceiving != null) { sbyte _caseCheck = _messageReceiving.readByte(); switch (_caseCheck) { case -1: // Lỗi kết nối đến database. PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString(MyLocalize.kSystemError) , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); break; case -9: // sai password đối với bigxu account PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString("RegisAndLogin/PassIsInvalid_00") , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); break; case -8: // username không tồn tại đối với bigxu account PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString("RegisAndLogin/UserDoesnotExist") , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); break; case 1: // thành công DataManager.instance.userData.password = _pass; DataManager.instance.userData.GetMoreUserData(_messageReceiving); #if TEST Debug.Log(">>> ReceiveLogin (Thành công) : " + DataManager.instance.userData.userId + " - " + DataManager.instance.userData.gold); #endif SetUpChangeScreenChooseGame(); break; default: #if TEST Debug.LogError(">>> Trả caseCheck tào lao: " + _caseCheck); #endif PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString(MyLocalize.kSystemError) , _caseCheck.ToString() , MyLocalize.GetString(MyLocalize.kOk)); break; } } else { PopupManager.Instance.CreatePopupMessage(MyLocalize.GetString(MyLocalize.kError) , MyLocalize.GetString(MyLocalize.kConnectionError) , _error.ToString() , MyLocalize.GetString(MyLocalize.kOk)); } }); }
public void SendMessageSearchParent(short _parentSessionId) { // panelConfirm.InitData(parentInfo); // panelConfirm.Show(); SubServerDetail _serverDetail = GetGoldScreenController.instance.GetServerDetail(); OneHitAPI.InviteFriend_SearchParentInfo(_serverDetail, _parentSessionId, (_messageReceiving, _error) => { if (_messageReceiving != null) { sbyte _caseCheck = _messageReceiving.readByte(); if (_caseCheck == 1) { // byte databaseid // long userid // byte avatarid // String nameShow // ***nếu databaseid là facebook thì đọc thêm kiểu long : facebookid --> lấy avatar // ***nếu databaseid là google thì đọc thêm kiểu string : link_icon UserData.DatabaseType _databaseId = (UserData.DatabaseType)_messageReceiving.readByte(); long _userid = _messageReceiving.readLong(); sbyte _avatarid = _messageReceiving.readByte(); string _nameShow = _messageReceiving.readString(); long _facebookId = -1; if (_databaseId == UserData.DatabaseType.DATABASEID_FACEBOOK) { _facebookId = _messageReceiving.readLong(); } else if (_databaseId == UserData.DatabaseType.DATABASEID_GOOGLE) { string _linkIcon = _messageReceiving.readString(); } else { #if TEST Debug.LogError("DatabaseID khác : " + _databaseId); #endif } parentInfo = new UserData(); parentInfo.InitData(); parentInfo.sessionId = _parentSessionId; parentInfo.databaseId = (UserData.DatabaseType)_databaseId; parentInfo.userId = _userid; parentInfo.avatarid = _avatarid; parentInfo.nameShowInGame = _nameShow; parentInfo.facebookId = _facebookId; PopupManager.Instance.CreatePopupConfirmInviteFriend(parentInfo , MyLocalize.GetString(MyLocalize.kYes) , MyLocalize.GetString(MyLocalize.kNo) , () => { if (parentInfo.sessionId == DataManager.instance.userData.sessionId) { PopupManager.Instance.CreateToast(MyLocalize.GetString("InviteFriend/InvalidCode")); } else { GlobalRealTimeSendingAPI.SendMessageSetParent(parentInfo.sessionId); } }, null); } else { parentInfo = new UserData(); PopupManager.Instance.CreateToast(MyLocalize.GetString("InviteFriend/CouldNotFound")); } } else { #if TEST Debug.LogError("InviteFriend_SearchParentInfo Error: " + _error); #endif } } ); }