Ejemplo n.º 1
0
 private void Update()
 {
     if (m_isUnlockingPrivilege)
     {
         EActivateKeyResult unlockPrivilegeState = LegacyLogic.Instance.ServiceWrapper.GetUnlockPrivilegeState();
         if (unlockPrivilegeState != EActivateKeyResult.ACTIVATE_WAITING)
         {
             Debug.Log("UnlockContentManager: " + unlockPrivilegeState);
             String p_caption = LocaManager.GetText("ERROR_POPUP_MESSAGE_CAPTION");
             String text;
             if (unlockPrivilegeState == EActivateKeyResult.ACTIVATE_SUCCESSFUL)
             {
                 LegacyLogic.Instance.ServiceWrapper.UpdatePrivilegesRewards();
                 text      = LocaManager.GetText("ACTIVATE_KEY_SUCCESS_NEW_CONTENT");
                 p_caption = String.Empty;
                 foreach (UnlockContentEntry unlockContentEntry in m_entries)
                 {
                     unlockContentEntry.UpdateUnlockState();
                 }
                 SelectEntry(m_selectedEntry);
             }
             else if (unlockPrivilegeState == EActivateKeyResult.ACTIVATE_INVALID_KEY || unlockPrivilegeState == EActivateKeyResult.ACTIVATE_WRONG_PRIVILAGE)
             {
                 text = LocaManager.GetText("ACTIVATE_KEY_ERROR_INVALID_KEY");
             }
             else if (unlockPrivilegeState == EActivateKeyResult.ACTIVATE_KEY_ALREADY_IN_USE)
             {
                 text = LocaManager.GetText("ACTIVATE_KEY_ERROR_KEY_ALREADY_USED");
             }
             else
             {
                 text = LocaManager.GetText("CHEST_PROMOTION_KEY_FAIL_TEXT");
             }
             m_isUnlockingPrivilege = false;
             m_loadingAnim.SetVisible(false);
             SelectEntry(m_selectedEntry);
             PopupRequest.Instance.OpenRequest(PopupRequest.ERequestType.CONFIRM, p_caption, text, null);
         }
     }
 }
        public void Update()
        {
            if (m_startingRendezVous)
            {
                StartUpState startUpState = (StartUpState)RendezVousInvokes.LegacyRendezVousGetStartUpState();
                if (startUpState == StartUpState.SUCCESSFUL)
                {
                    m_startingRendezVous = false;
                    String userName = GetUserName();
                    String password = GetPassword();
                    GetCDKeyList();
                    if (m_keys.Count > 0)
                    {
                        RendezVousInvokes.LegacyRendezVousLogIn(userName, password, m_keys[0]);
                        m_connectingToRendezVous = true;
                        m_unlockingKeyNr         = -1;
                    }
                }
                else if (startUpState == StartUpState.FAILURE)
                {
                    m_startingRendezVous = false;
                    m_isOfflineMode      = true;
                }
            }
            if (m_connectingToRendezVous)
            {
                if (m_unlockingKeyNr == -1)
                {
                    LogInState logInState = (LogInState)RendezVousInvokes.LegacyRendezVousGetLogInState();
                    if (logInState == LogInState.SUCCESSFUL)
                    {
                        m_unlockingKeyNr = 0;
                        RendezVousInvokes.LegacyRendezVousActivateAnyKey(m_keys[m_unlockingKeyNr]);
                    }
                    else if (logInState == LogInState.FAILURE)
                    {
                        m_isOfflineMode          = true;
                        m_connectingToRendezVous = false;
                    }
                }
                else
                {
                    EActivateKeyResult unlockPrivilegeState = GetUnlockPrivilegeState();
                    if (unlockPrivilegeState != EActivateKeyResult.ACTIVATE_WAITING)
                    {
                        m_unlockingKeyNr++;
                        if (m_unlockingKeyNr < m_keys.Count)
                        {
                            RendezVousInvokes.LegacyRendezVousActivateAnyKey(m_keys[m_unlockingKeyNr]);
                        }
                        else
                        {
                            DoneLogin();
                        }
                    }
                }
            }
            if (m_isSettingAction)
            {
                SetActionState setActionState = (SetActionState)RendezVousInvokes.LegacyRendezVousGetActionsState();
                if (setActionState == SetActionState.SUCCESSFUL)
                {
                    if (OnActionCompleted != null && m_settingActionID >= 0)
                    {
                        ActionCompletedEventArgs e = new ActionCompletedEventArgs(m_settingActionID, true);
                        OnActionCompleted(this, e);
                    }
                    m_isSettingAction = false;
                    m_settingActionID = -1;
                }
                else if (setActionState == SetActionState.FAILURE)
                {
                    if (OnActionCompleted != null && m_settingActionID >= 0)
                    {
                        ActionCompletedEventArgs e2 = new ActionCompletedEventArgs(m_settingActionID, false);
                        OnActionCompleted(this, e2);
                    }
                    m_isSettingAction = false;
                    m_settingActionID = -1;
                }
            }
            List <IntPtr> list = new List <IntPtr>();

            foreach (IntPtr intPtr in overlappedMap.Keys)
            {
                if (UplayInvokes.UPLAY_HasOverlappedOperationCompleted(intPtr))
                {
                    list.Add(intPtr);
                }
            }
            foreach (IntPtr intPtr2 in list)
            {
                overlappedMap.Remove(intPtr2);
                Marshal.FreeHGlobal(intPtr2);
            }
            list.Clear();
            if (UplayInvokes.UPLAY_Update() == 0)
            {
                m_isForceQuit = true;
            }
            UPLAY_Event uplay_Event;

            while (UplayInvokes.UPLAY_GetNextEvent(out uplay_Event))
            {
                Debug.Log("Received uplay Event! : " + uplay_Event.type);
                if (uplay_Event.type == UPLAY_EventType.UPLAY_Event_UserAccountSharing)
                {
                    m_isRendezVousConnected = false;
                    m_isOfflineMode         = true;
                }
            }
        }