Example #1
0
    /// <summary>
    /// 直接スクリーンを呼ぶ.Backでは用いない
    /// </summary>
    IObservable <T> MoveScreen <T> (string screenName, TransitionStyle transitionStyle = TransitionStyle.Null, Action <T> action = null)
        where T : ScreenPresenter
    {
        // screenの情報取得
        var screenEntity = screenSettings.screens.Find(x => x.name == screenName);
        // windowを取得
        var windowName = screenSettings.windows.Find(x => x.id == screenEntity.windowId).name;

        // screen生成
        if (CurrentWindow != null)
        {
            if (CurrentWindow.GetType().Name == windowName)
            {
                return(CurrentWindow.MoveScreen <T> (screenName, transitionStyle));
            }
        }
        var subject = new AsyncSubject <T> ();

        // 別ウインドウの場合
        // ウインドウを表示
        OpenWindow(windowName).Subscribe(x => {
            // スクリーンを表示
            x.MoveScreen(screenName, transitionStyle, action)
            .Subscribe(s => {
                subject.OnNext(s);
                subject.OnCompleted();
            });
        });
        return(subject);
    }
Example #2
0
    /// <summary>
    /// スクリーン遷移 型安全でないためここから呼ぶのは非推奨
    /// </summary>
    public IObservable <T> MoveScreen <T> (string screenType, TransitionStyle transitionStyle = TransitionStyle.Null, Action <T> action = null)
        where T : ScreenPresenter
    {
        OnScreenWillChange();
        var previewScreen = CurrentScreen;

        if (previewScreen != null)
        {
            previewScreen.OnMoveOut();
            beforeScreenStack.Push(previewScreen);
            previewScreen.gameObject.SetActive(false);
        }

        // 生成
        var transition = MoveTransition(screenType, transitionStyle, action);

        transition.Subscribe(
            x => CurrentScreen = x,
            () => {
            OnScreenChanged();
            //// 前のスクリーンを非表示にする
            //if (previewScreen != null)
            //{
            //    previewScreen.gameObject.SetActive(false);
            //}
        });
        return(transition);
    }
Example #3
0
    // トランジション
    IObservable <T> MoveTransition <T> (string screenType, TransitionStyle transitionStyle, Action <T> action = null)
        where T : ScreenPresenter
    {
        var        subject = new AsyncSubject <T> ();
        GameObject obj     = Instantiate(ResourcesManager.Instance.GetScreen(screenType), screenContainer) as GameObject;
        var        canvas  = obj.GetComponent <Canvas> ();
        T          screen  = obj.GetComponent <T> ();
        var        effect  = TransitionFactory.Create(transitionStyle);

        Action <Unit> setParam = _ => {
            if (action != null)
            {
                action(screen);
            }
        };

        canvas.enabled = false; // 生成して非表示にしておく
        effect.AnimateIn()
        .SelectMany(_ => screen.Initialize())
        .Do(setParam)
        .SelectMany(_ => screen.OnBeforeMoveIn())
        .Do(_ => canvas.enabled = true)
        .SelectMany(_ => Observable.WhenAll(effect.AnimateOut(), screen.OnMoveIn()))
        .SelectMany(_ => screen.OnEndMoveIn())
        .Subscribe(_ => {}, () => {
            subject.OnNext(screen);
            subject.OnCompleted();
        });
        return(subject);
    }
Example #4
0
    // キャッシュを削除してルートへ飛ぶ
    public IObservable <T> GoRootScreen <T> (string windowName, TransitionStyle transitionStyle = TransitionStyle.Null, Action <T> action = null)
        where T : ScreenPresenter
    {
        var windowEntity = screenSettings.windows.Find(x => x.name == windowName);
        // トップのスクリーンを取得
        var rootScreen = screenSettings.screens.Find(x => x.windowId == windowEntity.id);

        var transition = MoveScreen(rootScreen.name, transitionStyle, action);

        transition.Subscribe(_ => ClearWindowCache());

        return(transition);
    }
Example #5
0
        public static ITransition Create(TransitionStyle style)
        {
            switch (style)
            {
            case TransitionStyle.Fade:
                return(new TransitionFade());

            case TransitionStyle.Null:
                return(TransitionNull);

            default:
                return(TransitionNull);
            }
        }
Example #6
0
 // スクリーン遷移
 public IObservable <T> MoveScreen <T> (TransitionStyle transitionStyle = TransitionStyle.Null, Action <T> action = null)
     where T : ScreenPresenter
 {
     return(MoveScreen(typeof(T).Name, transitionStyle, action: action));
 }
Example #7
0
    IEnumerator MoveTransitionCoroutine <T> (string screenType, IObserver <T> observer, TransitionStyle transitionStyle = TransitionStyle.Null, Action <T> action = null)
        where T : ScreenPresenter
    {
        var effect = TransitionFactory.Create(transitionStyle);

        yield return(effect.AnimateIn().ToYieldInstruction());

        // 生成
        GameObject obj    = Instantiate(ResourcesManager.Instance.GetScreen(screenType), screenContainer) as GameObject;
        T          screen = obj.GetComponent <T> ();


        // 初期化
        yield return(screen.Initialize().ToYieldInstruction());

        // モデルの注入
        if (action != null)
        {
            action(screen);
        }
        // 遷移
        yield return(screen.OnBeforeMoveIn().ToYieldInstruction());

        //Debug.LogError ("BeforeMoveIn終了");
        yield return(Observable.WhenAll(
                         screen.OnMoveIn(),
                         effect.AnimateOut()
                         ).ToYieldInstruction());

        yield return(screen.OnEndMoveIn().ToYieldInstruction());

        // 副作用
        CurrentScreen = screen;
        observer.OnNext(screen);
        observer.OnCompleted();
    }
Example #8
0
 public IObservable <ScreenPresenter> MoveScreen(string screenName, TransitionStyle transitionStyle = TransitionStyle.Null)
 {
     return(MoveScreen <ScreenPresenter> (screenName, transitionStyle));
 }
Example #9
0
 /// <summary>
 /// ScreenChangeButton用
 /// </summary>
 public IObservable <ScreenPresenter> GoRootScreen(string windowName, TransitionStyle transitionStyle = TransitionStyle.Null)
 {
     return(GoRootScreen <ScreenPresenter> (windowName, transitionStyle));
 }