public void FetchPPIDataFromCloudAsyncOpFinished(CloudServices.AsyncOpResult res) { if (res.m_Res) { PlayerPersistantInfo PPIFromCloud = new PlayerPersistantInfo(); if (PPIFromCloud.InitPlayerDataFromStr(res.m_ResultDesc)) { // Debug.Log("Server: got user data from cloud for : " + UserName); CopyPlayerData(PPIFromCloud); IsValid = true; EnforceDataValidity(); //Debug.Log("Updated Score: " + Name + " exp" + Score.Experience + " money " + Score.Money + " experience old " + Experience); return; } } PlayerData.Params.Experience = 0; PlayerData.Params.Money = 0; PlayerData.Params.Gold = 0; Debug.LogWarning("FetchPPIDataFromCloudAsyncOpFinished(): error getting PPI from cloud for user : "******"(" + Name + ")"); }
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); }
// ========================================================================================================================= // === internal gui delegates ============================================================================================== void Delegate_OnFriendAction(string inFriendName, E_FriendAction inAction) { switch (inAction) { case E_FriendAction.Select: break; case E_FriendAction.ShowStats: { PlayerPersistantInfo ppi = null; List <PlayerPersistantInfo> ppis = new List <PlayerPersistantInfo>(); foreach (var friend in m_Friends) { PlayerPersistantInfo temp = new PlayerPersistantInfo(); temp.Name = friend.Nickname; temp.PrimaryKey = friend.PrimaryKey; temp.InitPlayerDataFromStr(JsonMapper.ToJson(friend.PPIData)); ppis.Add(temp); if (friend.PrimaryKey == inFriendName) { ppi = temp; } } if (ppi != null) { GuiScreenPlayerStats.UserPPIs = ppis.ToArray(); GuiScreenPlayerStats.UserPPI = ppi; m_Owner.Owner.ShowScreen("PlayerStats"); } } break; case E_FriendAction.SendMail: m_Owner.Owner.ShowPopup("SendMail", inFriendName, null); break; case E_FriendAction.Chat: if (GuiScreenChatFriends.StartChat(inFriendName) == true) { m_Owner.Owner.ShowScreen("Chat:1", true); } break; case E_FriendAction.Remove: { string text = string.Format(TextDatabase.instance[02040235], GuiBaseUtils.FixNameForGui(inFriendName)); m_Owner.Owner.ShowPopup("ConfirmDialog", TextDatabase.instance[02040234], text, (inPopup, inResult) => { if (inResult == E_PopupResultCode.Ok) { GameCloudManager.friendList.RemoveFriend(inFriendName); } }); } break; default: break; } }