示例#1
0
    /// <summary>
    /// Resumes the normal simulation and exits the replay mode, showing all UI elements again
    /// </summary>
    public override void Resume()
    {
        lastFrameCount = physicsWorld.frameCount;
        tracking       = true;

        Resources.FindObjectsOfTypeAll <Canvas>()[0].enabled = true;

        contactPoints.Clear(null);
    }
示例#2
0
        public void Clear()
        {
            logs.Clear();

            if (onLogUpdate != null)
            {
                onLogUpdate.OnNext(Unit.Default);
            }
        }
示例#3
0
        public void Clear()
        {
            apiInfoHistory.Clear();
            apiInfos.Clear();

            if (onUpdateInfo != null)
            {
                onUpdateInfo.OnNext(Unit.Default);
            }
        }
        public void Clear()
        {
            requestInfoHistory.Clear();
            webRequestInfos.Clear();

            if (onUpdateInfo != null)
            {
                onUpdateInfo.OnNext(Unit.Default);
            }
        }
示例#5
0
        private void SetupSubmissionEvents()
        {
            // Setup options menu events
            options_add.SetEvent(_ => Show(account_create));
            options_update.SetEvent(v => Show(password_update));
            options_tx.SetEvent(v => Show(transfer));
            options_delete.SetEvent(v => Show(account_delete));

            // Other events
            account_delete.RegisterSelectListener((v, i, s) =>
            {
                Hide(v);
                if (i == 1)
                {
                    Show("delete_stall");
                    Promise deletion   = Promise.AwaitPromise(interactor.DeleteUser());
                    deletion.Subscribe = p =>
                    {
                        Hide("delete_stall");
                        if (bool.Parse(p.Value))
                        {
                            controller.Popup(GetIntlString("SE_delete_success"), 2500, ConsoleColor.Green, () => manager.LoadContext(new WelcomeContext(manager, interactor)));
                        }
                        else
                        {
                            controller.Popup(GetIntlString("SE_delete_failure"), 1500, ConsoleColor.Red);
                        }
                    };
                }
            });

            account_create.SubmissionsListener = inputView =>
            {
                if (inputView.SelectedField == 1)
                {
                    Show(accountTypes); // Show account type selection menu
                }
                else
                {
                    CreateAccount();
                }
            };

            success.RegisterSelectListener((v, i, s) => HandleLogout());

            options_exit.SetEvent(v => Show("exit_prompt"));

            options_view.SetEvent(v =>
            {
                if (accountChange)
                {
                    RefreshAccountList();
                }
                if (!accountsGetter.HasValue)
                {
                    Show("data_fetch");
                }
                accountsGetter.Subscribe = p =>
                {
                    accountsGetter.Unsubscribe();
                    Hide("data_fetch");

                    Show(GenerateList(p.Value.Split('&').ForEach(Support.FromBase64String), ViewAccountListener));
                };
            });

            password_update.SubmissionsListener = v =>
            {
                bool hasError = v.Inputs[0].Text.Length == 0;
                if (hasError)
                {
                    // Notify user, as well as mark the errant input field
                    v.Inputs[0].SelectBackgroundColor = ConsoleColor.Red;
                    v.Inputs[0].BackgroundColor       = ConsoleColor.DarkRed;
                    controller.Popup(GetIntlString("ERR_empty"), 3000, ConsoleColor.Red);
                }
                if (v.Inputs[1].Text.Length == 0)
                {
                    v.Inputs[1].SelectBackgroundColor = ConsoleColor.Red;
                    v.Inputs[1].BackgroundColor       = ConsoleColor.DarkRed;
                    if (!hasError)
                    {
                        controller.Popup(GetIntlString("ERR_empty"), 3000, ConsoleColor.Red);
                    }
                    return; // No need to continue, we have notified the user. There is no valid information to operate on past this point
                }
                if (!v.Inputs[0].Text.Equals(v.Inputs[1].Text))
                {
                    controller.Popup(GetIntlString("SU_mismatch"), 3000, ConsoleColor.Red);
                    return;
                }
                Show("update_stall");
                Task <Promise> t = interactor.UpdatePassword(v.Inputs[0].Text);
                Promise.AwaitPromise(t).Subscribe = p =>
                {
                    Hide("update_stall");
                    Hide("password_update");
                    v.Inputs[0].ClearText();
                    v.Inputs[1].ClearText();
                    v.SelectedField = 0;
                };
            };

            transfer.SubmissionsListener = v =>
            {
                switch (v.SelectedField)
                {
                case 0:
                    if (accountChange)
                    {
                        accountsGetter = Promise.AwaitPromise(interactor.ListUserAccounts());
                    }
                    Show("data_fetch");
                    accountsGetter.Subscribe = p =>
                    {
                        accountsGetter.Unsubscribe();
                        Hide("data_fetch");

                        Show(GenerateList(p.Value.Split('&').ForEach(Support.FromBase64String), sel => v.Inputs[0].Text = acc1 = (sel as ButtonView).Text, true));
                    };
                    break;

                case 1:
                    Show("data_fetch");
                    Promise remoteUserGetter = Promise.AwaitPromise(interactor.ListUsers());
                    remoteUserGetter.Subscribe = p =>
                    {
                        remoteUserGetter.Unsubscribe();
                        Hide("data_fetch");

                        Show(GenerateList(p.Value.Split('&').ForEach(Support.FromBase64String), sel => v.Inputs[1].Text = user = (sel as ButtonView).Text, true));
                    };
                    break;

                case 2:
                    if (user == null)
                    {
                        controller.Popup(GetIntlString("SE_user_noselect"), 2000, ConsoleColor.Red);
                    }
                    else
                    {
                        Show("data_fetch");
                        Promise remoteAccountsGetter = Promise.AwaitPromise(interactor.ListAccounts(user));
                        remoteAccountsGetter.Subscribe = p =>
                        {
                            remoteAccountsGetter.Unsubscribe();
                            Hide("data_fetch");

                            Show(GenerateList(p.Value.Split('&').ForEach(Support.FromBase64String), sel => v.Inputs[2].Text = acc2 = (sel as ButtonView).Text, true));
                        };
                    }
                    break;

                case 3:
                case 4:
                    Show("verify_stall");
                    bool error = false;
                    if (acc1 == null)
                    {
                        controller.Popup(GetIntlString("SE_account_noselect"), 1500, ConsoleColor.Red);
                        error = true;
                        v.Inputs[0].BackgroundColor       = ConsoleColor.Red;
                        v.Inputs[0].SelectBackgroundColor = ConsoleColor.DarkRed;
                    }
                    if (acc2 == null)
                    {
                        if (!error)
                        {
                            controller.Popup(GetIntlString("SE_account_noselect"), 1500, ConsoleColor.Red);
                        }
                        error = true;
                        v.Inputs[2].BackgroundColor       = ConsoleColor.Red;
                        v.Inputs[2].SelectBackgroundColor = ConsoleColor.DarkRed;
                    }
                    if (user == null)
                    {
                        if (!error)
                        {
                            controller.Popup(GetIntlString("SE_account_nouser"), 1500, ConsoleColor.Red);
                        }
                        error = true;
                        v.Inputs[1].BackgroundColor       = ConsoleColor.DarkRed;
                        v.Inputs[1].SelectBackgroundColor = ConsoleColor.Red;
                    }
                    userDataGetter           = Promise.AwaitPromise(interactor.UserInfo());
                    userDataGetter.Subscribe = p =>
                    {
                        userDataGetter.Unsubscribe();
                        var account = AccountLookup("SE_balance_toohigh");
                        if (account == null)
                        {
                            accountsGetter = Promise.AwaitPromise(interactor.AccountInfo(acc1));
                        }
                        accountsGetter.Subscribe = result =>
                        {
                            accountsGetter.Unsubscribe();
                            var resultData = p.Value.Split('&');
                            Hide("verify_stall");
                            decimal d;
                            if (result.Value.StartsWith("ERROR") || !Account.TryParse(result.Value, out var act))
                            {
                                controller.Popup(GetIntlString("GENERIC_error"), 1500, ConsoleColor.Red);
                            }
                            else if ((d = decimal.Parse(v.Inputs[3].Text)) > act.balance && (!bool.Parse(resultData[1]) || !acc1.Equals(acc2)))
                            {
                                controller.Popup(GetIntlString("SE_balance_toohigh").Replace("$0", act.balance.ToString()), 3000, ConsoleColor.Red);
                            }
                            else
                            {
                                Promise txPromise = Promise.AwaitPromise(interactor.CreateTransaction(acc1, user, acc2, d, v.Inputs[4].Text.Length == 0 ? null : v.Inputs[4].Text));
                                accountChange = true;
                                accountDataCache.Clear();
                                txPromise.Subscribe = txResult =>
                                {
                                    if (txResult.Value.StartsWith("ERROR"))
                                    {
                                        controller.Popup(GetIntlString("GENERIC_error"), 1500, ConsoleColor.Red);
                                    }
                                    else
                                    {
                                        controller.Popup(GetIntlString("SE_tx_success"), 2000, ConsoleColor.Green, () => Hide("transfer"));
                                    }
                                };
                            }
                        };
                    };
                    break;
                }
            };

            exit_prompt.RegisterSelectListener((v, i, s) =>
            {
                if (i == 0)
                {
                    Hide("exit_prompt");
                }
                else
                {
                    HandleLogout();
                }
            });
        }
示例#6
0
        private IEnumerator LoadSceneCore(IObserver <SceneInstance> observer, Scenes identifier, LoadSceneMode mode)
        {
            var sceneInstance = loadedscenes.GetValueOrDefault(identifier);

            if (sceneInstance == null)
            {
                var scenePath = ScenePaths.GetValueOrDefault(identifier);

                UnityAction <Scene, LoadSceneMode> sceneLoaded = (s, m) =>
                {
                    if (s.IsValid())
                    {
                        sceneInstance = new SceneInstance(identifier, FindSceneObject(s), s);

                        switch (m)
                        {
                        case LoadSceneMode.Single:
                            loadedscenes.Clear();
                            cacheScenes.Clear();
                            break;
                        }

                        // 初期状態は非アクティブ.
                        sceneInstance.Disable();

                        if (onLoadScene != null)
                        {
                            onLoadScene.OnNext(sceneInstance);
                        }
                    }
                };

                SetEnabledForCapturedComponents(false);

                SceneManager.sceneLoaded += sceneLoaded;

                AsyncOperation op = null;

                try
                {
                    op = SceneManager.LoadSceneAsync(scenePath, mode);
                }
                catch (Exception e)
                {
                    Debug.LogException(e);

                    SceneManager.sceneLoaded -= sceneLoaded;

                    if (onLoadError != null)
                    {
                        onLoadError.OnNext(Unit.Default);
                    }

                    observer.OnError(e);

                    yield break;
                }

                while (!op.isDone)
                {
                    yield return(op);
                }

                SceneManager.sceneLoaded -= sceneLoaded;

                var scene = sceneInstance.GetScene();

                if (scene.HasValue)
                {
                    var rootObjects = scene.Value.GetRootGameObjects();

                    // UniqueComponentsを回収.
                    CollectUniqueComponents(rootObjects);

                    loadedscenes.Add(identifier, sceneInstance);

                    yield return(new WaitForEndOfFrame());

                    if (onLoadSceneComplete != null)
                    {
                        onLoadSceneComplete.OnNext(sceneInstance);
                    }

                    // ISceneEvent発行.
                    foreach (var rootObject in rootObjects)
                    {
                        var targets = UnityUtility.FindObjectsOfInterface <ISceneEvent>(rootObject);

                        foreach (var target in targets)
                        {
                            yield return(target.OnLoadSceneAsObservable().ToYieldInstruction());
                        }
                    }
                }

                SetEnabledForCapturedComponents(true);

                // シーンの初期化処理.
                if (sceneInstance.Instance != null)
                {
                    yield return(sceneInstance.Instance.Initialize().ToYieldInstruction());
                }
            }
            else
            {
                // 初期状態は非アクティブ.
                sceneInstance.Disable();
            }

            observer.OnNext(sceneInstance);
            observer.OnCompleted();
        }