IEnumerator UpdateFriendsData_Corutine(List <string> inFriends) { string jsonStr = JsonMapper.ToJson(inFriends); BaseCloudAction action = new QueryFriendsInfo(CloudUser.instance.authenticatedUserID, jsonStr); GameCloudManager.AddAction(action); // wait for authentication... while (action.isDone == false) { yield return(new WaitForSeconds(0.2f)); } if (action.isSucceeded == true) { //Debug.Log("frinds info is here " + action.result); ProcessFriendsDetails(action.result); Save(); } else { Debug.LogError("Can't obtain frinds info " + action.result); } }
IEnumerator FetchProductMessages_Corutine(string inMailboxName = null) { // construct special user needed for accessing global per product inbox... UnigueUserID product_user = new UnigueUserID("", "", PPIManager.ProductID); // Create action for fetching messages from global product inbox... BaseCloudAction action = new GetProductGlobalMessages(product_user, m_LastMessageIndexFromProductInbox, inMailboxName); GameCloudManager.AddAction(action); // wait for action finish... while (action.isDone == false) { yield return(new WaitForSeconds(0.2f)); } // end with error if action was not succesfully... if (action.isFailed == true) { Debug.LogError("Can't obtain messages " + action.result); yield break; } // try to process returned result and save Inbox if there are new messages... int lastMessageIndex = ProcessMessages(action.result, true); if (m_LastMessageIndexFromProductInbox < lastMessageIndex) { m_LastMessageIndexFromProductInbox = lastMessageIndex; Save(); OnInboxChanged(); } }
void OnAcceptButton(bool inside) { if (!inside) { return; } //check if we have enough money //if(true) //pro test not funds if (!ShopDataBridge.Instance.HaveEnoughMoney(m_BuyItemId, -1)) { //zobrazit not funds popup //GuiShopNotFundsPopup.Instance.DesiredItem = m_BuyItemId; //Owner.ShowPopup("NotFundsPopup", "", "", NoFundsResultHandler); Owner.ShowPopup("ShopMessageBox", TextDatabase.instance[02030091], TextDatabase.instance[02030092], null); } else { //TODO_DT - tady by se mohlo rozlisovat mezi asyc koupi a lokalni koupi. //spawn server request int guid = ShopDataBridge.Instance.GetShopItemGUID(m_BuyItemId); m_BuyCloudAction = new BuyAndFetchPPI(CloudUser.instance.authenticatedUserID, guid); GameCloudManager.AddAction(m_BuyCloudAction); //tohle se mi moc nelibi, vyvolavame wait box a result vlastne ani nepotrebujeme Owner.ShowPopup("ShopStatusBuy", TextDatabase.instance[02030020], TextDatabase.instance[02030096], BuyWaitResultHandler); //Debug.Log(" Starting buy request: time " + Time.time + " item " + m_BuyItemId); //pri lokalni koupi by stacilo poslat jen result success //CloseDialog(); //SendResult(E_PopupResultCode.Success); } }
void Delegate_Migrate(GUIBase_Widget inInstigator) { bool invalid = false; if (string.IsNullOrEmpty(m_Email) == true) { invalid = true; } if (invalid == false) { Match match = new Regex(EMAIL_PATTERN).Match(m_Email ?? ""); invalid = match.Success ? false : true; } if (invalid == false) { UserRequestMigrate action = new UserRequestMigrate(PrimaryKey, Password, m_Email); GameCloudManager.AddAction(action); PrimaryKey = string.Empty; Password = string.Empty; IViewOwner owner = Owner; owner.Back(); SendResult(E_PopupResultCode.Ok); owner.ShowPopup("MessageBox", TextDatabase.instance[00107032], TextDatabase.instance[m_FinalMessageID], InfoPopupConfirmation); } else { Owner.ShowPopup("MessageBox", TextDatabase.instance[00107030], TextDatabase.instance[00107040], null); } }
private IEnumerator GetCloudPPI_Coroutine() { //Debug.Log(Time.timeSinceLevelLoad + " GetPPIFromCloud Begin "); GetPlayerPersistantInfo action = new GetPlayerPersistantInfo(CloudUser.instance.authenticatedUserID); GameCloudManager.AddAction(action); // wait for authentication... while (action.isDone == false) { yield return(new WaitForSeconds(0.2f)); } if (action.isSucceeded == true) { //Debug.Log(Time.timeSinceLevelLoad + " GetPPIFromCloud End "); PlayerPersistantInfo PPIFromCloud = new PlayerPersistantInfo(); //Debug.LogWarning("Cloud PlayerPersistantInfo = " + action.result); if (PPIFromCloud.InitPlayerDataFromStr(action.result)) { SetPPIFromCloud(PPIFromCloud); yield break; } } // TODO Is this correct? Maybe null is better... // Debug.LogError("Cannot get PPI from cloud: using fake PPI"); // PPIFromCloud = new PlayerPersistantInfo(); Debug.LogError("Cannot get PPI from cloud" + action.status); }
// ========================================================================================================================= #region --- Create new user... public UsernameAlreadyExists CheckIfUserNameExist(string inUserName) //TODO: PRIMARY KEY - nemelo by se tu pouzvat primaryKey? { UsernameAlreadyExists action = new UsernameAlreadyExists(inUserName); GameCloudManager.AddAction(action); return(action); }
// ------ GuiPopupResearchWait.E_AsyncOpStatus GetActionStatus() { if (m_CheckEquipCloudAction == null) { if (/*(m_BuyCloudAction.isFailed == true) ||*/ (m_BuyCloudAction.isSucceeded == true)) { m_CheckEquipCloudAction = GuiShopUtils.ValidateEquip(); if (m_CheckEquipCloudAction != null) { GameCloudManager.AddAction(m_CheckEquipCloudAction); return(DeduceActionStatus(m_CheckEquipCloudAction)); } else { return(GuiPopupResearchWait.E_AsyncOpStatus.Finished); } } else { return(DeduceActionStatus(m_BuyCloudAction)); } } else { return(DeduceActionStatus(m_CheckEquipCloudAction)); } }
IEnumerator GetFriendListFromCloud_Corutine() { BaseCloudAction action = new GetUserData(CloudUser.instance.authenticatedUserID, CloudServices.PROP_ID_FRIENDS); GameCloudManager.AddAction(action); m_GetFriendListAction = action; // wait for authentication... while (action.isDone == false) { yield return(new WaitForSeconds(0.2f)); } if (action.isFailed == true) { Debug.LogError("Can't obtain frinds list " + action.result); } else { //Debug.Log("frinds list is here " + action.result); RegenerateFriendList(action.result); } m_GetFriendListAction = null; }
//.......................................................................................................................... public void RemoveFriend(string inFriendName) { // check preconditions... if (CloudUser.instance.isUserAuthenticated == false) { Debug.LogError("user is not authenticated, can't fetch friends list"); return; } int friendIndex = m_Friends.FindIndex(f => f.PrimaryKey == inFriendName); if (friendIndex < 0) { //Debug.Log("User with name " + inFriendName + " is not in friendlist"); return; } // remove friend from list... m_Friends.RemoveAt(friendIndex); // send reguest into cloud and ignore result. Friend was removed... GameCloudManager.AddAction(new CancelFriendship(CloudUser.instance.authenticatedUserID, inFriendName)); // notify recipient about change and save new friend list... OnFriendListChanged(); Save(); }
// ------ void OnAcceptButton(bool inside) { if (!inside) return; WeaponSettings.Upgrade upgrade = m_ResearchItem.GetUpgrade(m_UpgradeIndex); if (upgrade.GoldCost > 0 && ResearchSupport.Instance.HasPlayerEnoughFunds(upgrade.GoldCost, true) == false) { //zobrazit not funds popup /*GuiShopNotFundsPopup.Instance.DesiredItem = new ShopItemId((int)upgrade.ParentID, GuiShop.E_ItemType.Weapon); GuiShopNotFundsPopup.Instance.UpgradeID = m_UpgradeIndex; Owner.ShowPopup("NotFundsPopup", "", "");*/ Owner.ShowPopup("ShopMessageBox", TextDatabase.instance[02030091], TextDatabase.instance[02030092], null); } else { #if !TEMPORARY_UPGRADE_HACK int guid = upgrade.GetGUID(); m_UpgradeCloudAction = new BuyAndFetchPPI(CloudUser.instance.authenticatedUserID, guid); GameCloudManager.AddAction(m_UpgradeCloudAction); #else // TEMPORARY CODE ResearchSupport.Instance.GetPPI().InventoryList.TMP_CODE_AddWeaponUpgrade( (m_ResearchItem as ResearchItem).weaponID, m_ResearchItem.GetUpgrade(m_UpgradeIndex).ID ); #endif GuiPopupResearchWait popik = Owner.ShowPopup("ResearchWait", TextDatabase.instance[0113050], TextDatabase.instance[0113060], BuyWaitResultHandler) as GuiPopupResearchWait; popik.SetActionStatusDelegate(GetActionStatus); } }
void FixEquipList() { BaseCloudAction action = GuiShopUtils.ValidateEquip(); if (action != null) { //Debug.Log("FixEquipListAfterResearch"); GameCloudManager.AddAction(action); } }
IEnumerator FetchMessages_Corutine(bool inGlobalInbox, bool inRemoveMessagesFromServer = true) { BaseCloudAction action = new GetMessagesFromInbox(CloudUser.instance.authenticatedUserID, inGlobalInbox); GameCloudManager.AddAction(action); // wait for authentication... while (action.isDone == false) { yield return(new WaitForSeconds(0.2f)); } int lastMessageIndex = -1; if (action.isFailed == true) { Debug.LogError("Can't obtain messages " + action.result); } else { //Debug.Log("messages are here " + action.result); lastMessageIndex = ProcessMessages(action.result, inGlobalInbox); } Save(); if (lastMessageIndex > 0) { OnInboxChanged(); } if (lastMessageIndex <= 0 || inRemoveMessagesFromServer == false) { yield break; } // --- remove processed messages from inbox.. action = new RemoveMessagesFromInbox(CloudUser.instance.authenticatedUserID, inGlobalInbox, lastMessageIndex); GameCloudManager.AddAction(action); // wait for authentication... while (action.isDone == false) { yield return(new WaitForSeconds(0.2f)); } if (action.isFailed == true) { Debug.LogError("messages wasn't removed correctly " + action.result); } else { //Debug.Log("messages removed " + action.result); } }
public void UpdateFromCloud() { if (ApplicationDZ.loadedLevelName != Game.MainMenuLevelName) //update only in main menu { return; } FetchPlayerPersistantInfo action = new FetchPlayerPersistantInfo(CloudUser.instance.authenticatedUserID); GameCloudManager.AddAction(action); }
// ========================================================================================================================= static GameCloudManager GetInstance() { if (m_sInstance == null) { GameObject go = new GameObject("GameCloudManager"); m_sInstance = go.AddComponent <GameCloudManager>(); GameObject.DontDestroyOnLoad(m_sInstance); } return(m_sInstance); }
public UpdateMFAccountAndFetchPPI UpdateUser(string inPasswordHash, string inNickName, string inEmail, bool inIWantNews, GeoRegion inRegion) { UpdateMFAccountAndFetchPPI action = new UpdateMFAccountAndFetchPPI(m_AuthenticatedUserID, inNickName, inEmail, inIWantNews, NetUtils.GetRegionString(inRegion)); GameCloudManager.AddAction(action); return(action); }
IEnumerator PasswordRecoveryRequest_Coroutine() { if (string.IsNullOrEmpty(m_UserName) == true) { yield break; } string username = m_UserName; IViewOwner owner = Owner; owner.Back(); GuiPopupMessageBox popup = (GuiPopupMessageBox)owner.ShowPopup("MessageBox", TextDatabase.instance[0103044], TextDatabase.instance[0103043]); popup.SetButtonVisible(false); yield return(new WaitForSeconds(0.2f)); string primaryKey; { UserGetPrimaryKey action = new UserGetPrimaryKey(username); GameCloudManager.AddAction(action); while (action.isDone == false) { yield return(new WaitForEndOfFrame()); } primaryKey = action.primaryKey; } E_PopupResultCode result; { ForgotPassword action = new ForgotPassword(primaryKey); GameCloudManager.AddAction(action); while (action.isDone == false) { yield return(new WaitForEndOfFrame()); } result = action.isSucceeded == true ? E_PopupResultCode.Ok : E_PopupResultCode.Failed; } popup.ForceClose(); SendResult(result); }
// PRIVATE METHODS public IEnumerator CheckDailyRewards_Coroutine() { yield return(new WaitForSeconds(1.0f)); while (m_UserId != null) { if (Ftue.IsActive == true) { yield return(new WaitForSeconds(0.5f)); } else if (m_Menu == null || m_Menu.IsAnyPopupVisible() == true) { yield return(new WaitForSeconds(1.0f)); } else { GetDailyRewards rewards = new GetDailyRewards(m_UserId); GameCloudManager.AddAction(rewards); while (rewards.isDone == false) { yield return(new WaitForEndOfFrame()); } #if !FAKE_DAILY_REWARDS if (rewards.HasReward == true) #endif { FetchPlayerPersistantInfo ppi = new FetchPlayerPersistantInfo(m_UserId); GameCloudManager.AddAction(ppi); while (ppi.isDone == false) { yield return(new WaitForEndOfFrame()); } #if !FAKE_DAILY_REWARDS UserGuideAction_DailyRewards.HasInstant |= rewards.HasInstant; UserGuideAction_DailyRewards.HasConditional |= rewards.HasConditional; #else UserGuideAction_DailyRewards.HasInstant |= true; UserGuideAction_DailyRewards.HasConditional |= true; #endif } yield return(new WaitForSeconds(60.0f * 60)); // wait one hour } } }
public void SendRequestForSpawn() { GameState.State = ClientGameState.WaitingForSpawn; //check equip before spawn: BaseCloudAction action = GuiShopUtils.ValidateEquip(); if (action != null) { Debug.Log("Fixing Equip before spawn"); GameCloudManager.AddAction(action); } StartCoroutine(WaitForCloudManagerForSpawn()); }
IEnumerator UpdateJackpot_Coroutine(bool animate) { m_UpdatingJackpot = true; GetSlotmachineJackpot action = new GetSlotmachineJackpot(CloudUser.instance.authenticatedUserID); GameCloudManager.AddAction(action); while (action.isDone == false) { yield return(new WaitForSeconds(0.1f)); } int jackpot = 0; if (action.isSucceeded == true) { JsonData data = JsonMapper.ToObject(action.result); jackpot = int.Parse(data["count"].ToString()); } if (animate == false) { Jackpot = jackpot; } else if (Jackpot == 0 || jackpot <= Jackpot) { Jackpot = jackpot; yield return(new WaitForSeconds(JACKPOT_REFRESH_DELAY)); } else { int delta = jackpot - Jackpot; float delay = JACKPOT_REFRESH_DELAY / delta; float value = (float)Jackpot; while (Jackpot < jackpot) { value += delta / JACKPOT_REFRESH_DELAY * delay; Jackpot = Mathf.Min(Mathf.RoundToInt(value), jackpot); yield return(new WaitForSeconds(delay)); } } m_UpdatingJackpot = false; }
// ------ void OnAcceptButton(bool inside) { if (!inside) { return; } m_GetPPICloudAction = null; m_ResetCloudAction = new RefundItems(CloudUser.instance.authenticatedUserID, m_ResearchGUIDs); GameCloudManager.AddAction(m_ResetCloudAction); //tohle se mi moc nelibi, vyvolavame wait box a result vlastne ani nepotrebujeme GuiPopupResearchWait popik = Owner.ShowPopup("ResearchWait", TextDatabase.instance[0112015], TextDatabase.instance[0113040], ResetWaitResultHandler) as GuiPopupResearchWait; popik.SetActionStatusDelegate(GetActionStatus); }
// ------ GuiPopupResearchWait.E_AsyncOpStatus GetActionStatus() { if (m_GetPPICloudAction == null) { if (m_ResetCloudAction.isDone == true) { m_GetPPICloudAction = new FetchPlayerPersistantInfo(CloudUser.instance.authenticatedUserID); GameCloudManager.AddAction(m_GetPPICloudAction); return(DeduceActionStatus(m_GetPPICloudAction)); } else { return(DeduceActionStatus(m_ResetCloudAction)); } } else { if (m_CheckEquipCloudAction == null) { if (m_GetPPICloudAction.isDone == true) { m_CheckEquipCloudAction = GuiShopUtils.ValidateEquip(); if (m_CheckEquipCloudAction != null) { GameCloudManager.AddAction(m_CheckEquipCloudAction); return(DeduceActionStatus(m_CheckEquipCloudAction)); } else { return(GuiPopupResearchWait.E_AsyncOpStatus.Finished); } } else { return(DeduceActionStatus(m_GetPPICloudAction)); } } else { return(DeduceActionStatus(m_CheckEquipCloudAction)); } } }
protected override void OnMenuShowMenu() { // menu background { GuiUniverse.Instance.Show(); GuiUniverse.Instance.Enable(); } #if (!UNITY_EDITOR) && (UNITY_ANDROID || UNITY_IPHONE) // if (uLink.Network.isServer == false) // { // StartCoroutine(CheckForNewMajorRank()); // } #endif GameCloudManager.AddAction(new UpdateSwearWords(CloudUser.instance.authenticatedUserID)); Game.AskForReview(); }
public void SendMessage(string inRecipient, BaseMessage inMessage) { // ................................... // check preconditions... if (string.IsNullOrEmpty(inRecipient) == true) { Debug.LogError("Invalid recipient " + inRecipient); return; } if (inMessage == null || inMessage.isValid == false) { Debug.LogError("Invalid message " + inMessage); return; } // ................................... inMessage.m_SendTime = CloudDateTime.UtcNow; // ................................... // convert message to JSON string... string message = JsonMapper.ToJson(inMessage); // ................................... // create send message action and send it via GameCloudManager //Debug.Log("SendMessage: " + message); if (inMessage is FriendRequest) { SendMessage action = new SendFriendRequestMessage(CloudUser.instance.authenticatedUserID, inRecipient, message); GameCloudManager.AddAction(action); } else { bool globalMailbox = (inMessage.m_Mailbox == E_Mailbox.Global); SendMessage action = new SendMessage(CloudUser.instance.authenticatedUserID, inRecipient, message, globalMailbox); GameCloudManager.AddAction(action); } // ................................... // Save out going message into outbox... m_Outbox.Add(inMessage); Save(); }
// PRIVATE MEMBERS IEnumerator Close_Coroutine() { m_CloseButton.IsDisabled = true; m_SpinButton.IsDisabled = true; if (m_NeedsFetchPPI == true) { m_NeedsFetchPPI = false; FetchPlayerPersistantInfo action = new FetchPlayerPersistantInfo(CloudUser.instance.authenticatedUserID); GameCloudManager.AddAction(action); while (action.isDone == false) { yield return(new WaitForEndOfFrame()); } } Owner.Back(); }
//.......................................................................................................................... public void AcceptFriendRequest(string inFriendName) { //Debug.Log("AcceptFriendRequest " + inFriendName); // check preconditions... if (CloudUser.instance.isUserAuthenticated == false) { Debug.LogError("user is not authenticated, can't Accept Friend Request"); return; } PendingFriendInfo fInfo = m_PendingFriends.Find(f => (f.PrimaryKey == inFriendName && f.IsItRequest == true)); if (fInfo == null) { Debug.LogError("Can't accept friend which is not in pending list"); return; } GameCloudManager.AddAction(new SendAcceptFriendCommand(CloudUser.instance.authenticatedUserID, inFriendName, fInfo.CloudCommand)); m_PendingFriends.Remove(fInfo); OnPendingFriendListChanged(); Save(); FriendInfo friend = new FriendInfo() { PrimaryKey = fInfo.PrimaryKey, Username = fInfo.Username, Nickname = fInfo.Nickname, OnlineStatus = E_OnlineStatus.Offline }; m_Friends.Add(friend); // force redownload friend list... RetriveFriendListFromCloud(true); }
void OnApplicationPause(bool pause) { if (pause == true) { InputManager.FlushInput(); SaveSettings(); } if (pause == false) { //Pro Tapjoy a SponsorPay: kdyz se vracime do applikace a je zobrazene menu, updatuj ppi (aby hrac videl pridane goldy). if (GuiFrontendMain.IsVisible || GuiFrontendIngame.IsVisible) { if (CloudUser.instance != null && CloudUser.instance.isUserAuthenticated) { //Debug.Log("On application pause false, fetching ppi"); FetchPlayerPersistantInfo action = new FetchPlayerPersistantInfo(CloudUser.instance.authenticatedUserID); GameCloudManager.AddAction(action); } } } }
// ------ void OnAcceptButton(bool inside) { if (!inside) { return; } int guid = m_ResearchItem.GetGUID(); m_BuyCloudAction = new BuyAndFetchPPI(CloudUser.instance.authenticatedUserID, guid); GameCloudManager.AddAction(m_BuyCloudAction); //tohle se mi moc nelibi, vyvolavame wait box a result vlastne ani nepotrebujeme GuiPopupResearchWait popik = Owner.ShowPopup("ResearchWait", TextDatabase.instance[0113050], TextDatabase.instance[0113060], BuyWaitResultHandler) as GuiPopupResearchWait; popik.SetActionStatusDelegate(GetActionStatus); //Debug.Log(" Starting buy request: time " + Time.time + " item " + m_BuyItemId); //pri lokalni koupi by stacilo poslat jen result success //SendResult(E_PopupResultCode.Success); }
IEnumerator CheckGuestAccount_Coroutine(string primaryKey, string password) { GetPublicUserData getUserAccountType = new GetPublicUserData(primaryKey, CloudServices.PROP_ID_ACCT_KIND); GameCloudManager.AddAction(getUserAccountType); while (!getUserAccountType.isDone) { yield return(new WaitForEndOfFrame()); } E_PopupResultCode migrateResult = E_PopupResultCode.Cancel; if (!getUserAccountType.isFailed && !string.IsNullOrEmpty(getUserAccountType.result) && getUserAccountType.result == E_UserAcctKind.Guest.ToString()) { m_MigrationOffered = true; bool migrateFinished = false; GuiPopupMigrateGuest migratePopup = (GuiPopupMigrateGuest)ShowPopup("MigrateGuest", null, null, (popup, result) => { migrateResult = result; migrateFinished = true; }); migratePopup.Usage = GuiPopupMigrateGuest.E_Usage.LoginMenu; migratePopup.PrimaryKey = primaryKey; migratePopup.Password = password; while (!migrateFinished) { yield return(new WaitForEndOfFrame()); } migratePopup.HideView(this); } StartLogin(migrateResult == E_PopupResultCode.Cancel); }
IEnumerator AddNewFriend_Coroutine() { string username = Username; string primaryKey = PrimaryKey; string nickname = Nickname; string message = Message; IViewOwner owner = Owner; owner.Back(); GuiPopupMessageBox popup = (GuiPopupMessageBox)owner.ShowPopup("MessageBox", TextDatabase.instance[02040204], TextDatabase.instance[00103043]); popup.SetButtonVisible(false); yield return(new WaitForSeconds(0.2f)); if (string.IsNullOrEmpty(primaryKey) == true) { UserGetPrimaryKey action = new UserGetPrimaryKey(username); GameCloudManager.AddAction(action); while (action.isDone == false) { yield return(new WaitForEndOfFrame()); } primaryKey = action.primaryKey; } GameCloudManager.friendList.AddNewFriend(primaryKey, username, nickname, message); popup.ForceClose(); SendResult(E_PopupResultCode.Ok); }
protected override void OnViewUpdate() { if (IsVisible) { if (ShopDataBridge.Instance.IsIAPInProgress()) { switch (ShopDataBridge.Instance.GetIAPState()) { case InAppAsyncOpState.Waiting: return; case InAppAsyncOpState.Finished: //IAP success, fetch ppi with new golds FetchPlayerPersistantInfo action = new FetchPlayerPersistantInfo(CloudUser.instance.authenticatedUserID); GameCloudManager.AddAction(action); //Debug.Log("IAP finished: " + BuyIAPItem ); CloseDialog(E_PopupResultCode.Success, 02030048); return; case InAppAsyncOpState.Failed: CloseDialog(E_PopupResultCode.Failed, 02030049); return; case InAppAsyncOpState.Cancelled: CloseDialog(E_PopupResultCode.Cancel, 02030050); return; case InAppAsyncOpState.CannotVerify: CloseDialog(E_PopupResultCode.Failed, 02030072); return; } } } base.OnViewUpdate(); }