Beispiel #1
0
 public override void OnEnter()
 {
     AuthManager.BeginProcess();
     result = ProcessResult.Running;
     cmd    = AuthCheckCommand.Next;
     NetworkUtility.CheckInternet((bool internet) =>
     {
         cmd = internet ? AuthCheckCommand.Next : AuthCheckCommand.Exit;
         AuthManager.FinishProcess(!internet, !internet ? new System.Exception("No internet connection") : null);
         result = ProcessResult.Completed;
     });
 }
Beispiel #2
0
        // RUN AUTH METHOD ----
        private IEnumerator I_ExecuteMethod()
        {
            if (SelectedMethod != null)
            {
                bool Method_Retry = false;
                AuthRunning = true;
                DisplayLayout(true);
                IAuthCustomUI customUI = SelectedMethod as IAuthCustomUI;

                if (customUI != null)
                {
                    customUI.DisplayUI(auth.CurrentUser != null && auth.CurrentUser.IsAnonymous);
                }

                IAuthCustomNavigation customNavigation = SelectedMethod as IAuthCustomNavigation;

                SelectedMethod.OnEnter();

                ProcessResult tres = ProcessResult.None;
                do
                {
                    if (Method_Retry)
                    {
                        SelectedMethod.OnEnter();
                        Method_Retry = false;
                    }

                    tres = SelectedMethod.GetResult();
                    bool goback = (customNavigation != null) ? customNavigation.GoBack() : Input.GetKey(KeyCode.Escape);

                    if (customUI != null && tres == ProcessResult.None && goback)
                    {
                        customUI.HideUI();

                        if (OnAuthCancelled != null)
                        {
                            OnAuthCancelled.Invoke();
                        }

                        fsm.MoveNext(AuthCheckCommand.GoBack);

                        break;
                    }

                    if (tres == ProcessResult.Failure)
                    {
                        Logger.LogWarning("Got Error during process of Method " + SelectedMethod.GetException(), this);
                        yield return(new WaitForSeconds(0.5f));

                        Logger.LogWarning("Retrying...", this);
                        Method_Retry = true;
                    }

                    yield return(new WaitForEndOfFrame());
                } while (tres != ProcessResult.Completed);

                if (tres == ProcessResult.Completed)
                {
                    if (customUI != null)
                    {
                        customUI.HideUI();
                    }

                    SelectedMethod.OnFinish();

                    if (OnAuthCompleted != null)
                    {
                        OnAuthCompleted.Invoke();
                    }

                    AuthCheckCommand cmd = auth.CurrentUser != null ? AuthCheckCommand.Next : AuthCheckCommand.Exit;

                    fsm.MoveNext(cmd);
                }
            }

            AuthRunning    = false;
            SelectedMethod = null;
            Logger.Log("Auth Execution Finished", this, true);
            yield return(0);
        }