Exemplo n.º 1
0
    private void SlideScreen(Type screenType, object data, string sceneName, bool isBack, Action onSuccess)
    {
        var currentScreen = GetCurrentScreen();

        LoadObject(screenType, ScreenParent, obj =>
        {
            var uiRect           = GetComponent <RectTransform>();
            var screenRect       = obj.GetComponent <RectTransform>();
            var screenParentRect = ScreenParent.GetComponent <RectTransform>();

            ActiveObject(obj, data, null, () =>
            {
                screenRect.anchoredPosition = new Vector2(isBack ? -uiRect.sizeDelta.x : uiRect.sizeDelta.x, 0);
                var to = new Vector3(isBack ? uiRect.sizeDelta.x : -uiRect.sizeDelta.x, 0, 0);

                TweenUtil.MoveLocal(ScreenParent.gameObject, Vector3.zero, to, TweenType.Linear, 0.5f, () =>
                {
                    if (currentScreen != null)
                    {
                        DeactivateObject(currentScreen.GetType(), null);
                    }
                    screenParentRect.anchoredPosition = Vector2.zero;
                    screenRect.anchoredPosition       = Vector2.zero;
                    _currentScreen = obj.GetComponent <Screen>();

                    if (isBack)
                    {
                        _currentScreen.OnBack();
                    }
                    else
                    {
                        if (_lastScreenData != null)
                        {
                            _lastScreenData.IsSlide = true;
                            _screenHistory.Push(_lastScreenData);
                        }
                    }

                    _lastScreenData = new SwitchScreenData
                    {
                        ScreenType = screenType,
                        Data       = data,
                        SceneName  = sceneName
                    };

                    _onSwitchScreen.Execute(_currentScreen);
                    onSuccess.Execute();
                });
            });
        });
    }
Exemplo n.º 2
0
    public Rect getScreenDimensions(UI.Screen screen)
    {
        Rect    rect            = new Rect();
        Rect    fullScreen      = UI.Core.instance.layoutSystem.sizeOfUIScene;
        int     statusBarHeight = UI.Core.instance.layoutSystem.statusBarHeight;
        Vector2 sBar            = new Vector2(0, statusBarHeight);

        if (rounded.activeSelf)
        {
            if (screen == UI.Screen.left)
            {
                rect.min = fullScreen.min + sBar;
                rect.max = new Vector2(fullScreen.min.x + fullScreen.width * 0.33f, fullScreen.max.y);
            }
            else if (screen == UI.Screen.right)
            {
                rect.max = fullScreen.max;
                rect.min = new Vector2(fullScreen.max.x - fullScreen.width * 0.33f, fullScreen.min.y) + sBar;
            }
            else
            {
                rect.min = new Vector2(fullScreen.center.x - fullScreen.width * 0.25f, fullScreen.min.y) + sBar;
                rect.max = new Vector2(fullScreen.center.x + fullScreen.width * 0.25f, fullScreen.max.y);
            }
        }
        else
        {
            if (screen == UI.Screen.left)
            {
                rect.min = fullScreen.min + sBar;
                rect.max = new Vector2(fullScreen.min.x + fullScreen.width * ratioSide, fullScreen.max.y);
            }
            else if (screen == UI.Screen.right)
            {
                rect.max = fullScreen.max;
                rect.min = new Vector2(fullScreen.max.x - fullScreen.width * ratioSide, fullScreen.min.y) + sBar;
            }
            else
            {
                rect.min = new Vector2(fullScreen.center.x - fullScreen.width * ratioFront * 0.5f, fullScreen.min.y) + sBar;
                rect.max = new Vector2(fullScreen.center.x + fullScreen.width * ratioFront * 0.5f, fullScreen.max.y);
            }
        }
        return(rect);
    }
Exemplo n.º 3
0
    private void ActiveScreen(Type screenType, object data, string sceneName, bool isBack, Action onSuccess)
    {
        Action active = () =>
        {
            LoadObject(screenType, ScreenParent, obj =>
            {
                ActiveObject(obj, data, null, () =>
                {
                    _currentScreen = obj.GetComponent <Screen>();

                    if (isBack)
                    {
                        _currentScreen.OnBack();
                    }
                    else
                    {
                        if (_lastScreenData != null)
                        {
                            _screenHistory.Push(_lastScreenData);
                        }
                    }

                    _lastScreenData = new SwitchScreenData
                    {
                        ScreenType = screenType,
                        Data       = data,
                        SceneName  = sceneName
                    };

                    _onSwitchScreen.Execute(_currentScreen);
                    onSuccess.Execute();
                });
            });
        };

        if (_currentScreen != null)
        {
            DeactivateObject(_currentScreen.GetType(), active);
        }
        else
        {
            active();
        }
    }
Exemplo n.º 4
0
        private WidgetBase CopyAndAdd_Aux( Screen screen, WidgetBase widget )
        {
            WidgetBase o = widget.Copy();
            screen.Add( o );

            for ( int i = 0; i < widget.Children.Count; ++i )
            {
            WidgetBase oo = CopyAndAdd_Aux( screen, widget.Children[ i ] );
            oo.Parent( o );
            }

            return o;
        }
Exemplo n.º 5
0
 // CopyAndAdd
 public WidgetBase CopyAndAdd( Screen screen )
 {
     return CopyAndAdd_Aux( screen, this );
 }
Exemplo n.º 6
0
 /*! Return a transform representing the center of the screen.
  * This transform is placed at the center of a screen and (on the platform)
  * and is oriented inwards, i.e. towards the player. The transform can be
  * used to determine if a movement is "towards" or "away from" a certain screen.*/
 public Transform getCenterTransformForScreen(UI.Screen s)
 {
     return(screenCenters [s].transform);
 }
Exemplo n.º 7
0
        // AddScreen
        public void AddScreen( Screen screen )
        {
            ScreenControl screenControl = new ScreenControl();
            screenControl.SetNextScreen( screen );

            ScreenControls.Add( screenControl );
        }
Exemplo n.º 8
0
 // SetNextScreen
 public void SetNextScreen( Screen screen )
 {
     ScreenControls[ CurrentScreenControl ].SetNextScreen( screen );
 }
Exemplo n.º 9
0
        // Update
        public void Update( float frameTime )
        {
            if ( CurrentScreen == null )
            return;

            switch ( State )
            {
            // Init
            case E_ScreenState.Init:
            {
                CurrentScreen.Init();
                CurrentScreen.TimelineActive( "start", true, false );

                State = E_ScreenState.Start;
                Time = 0.0f;

                goto case E_ScreenState.Start; //break;
            }

            // Start
            case E_ScreenState.Start:
            {
                CurrentScreen.StartLoop( frameTime );

                if ( Time >= StartTimer )
                {
                    State = E_ScreenState.Update;
                    Time = 0.0f;
                }
                else
                    Time = MathHelper.Min( Time + frameTime, StartTimer );

                break;
            }

            // Update
            case E_ScreenState.Update:
            {
                CurrentScreen.Update( frameTime );
                Time += frameTime;

                break;
            }

            // End
            case E_ScreenState.End:
            {
                CurrentScreen.EndLoop( frameTime );

                if ( Time >= EndTimer )
                {
                    CurrentScreen.End();

                    // switch to the next screen
                    CurrentScreen = NextScreen;
                    NextScreen = null;

                    if ( CurrentScreen != null )
                    {
                        State = E_ScreenState.Init;
                        Update( frameTime );
                    }
                    else
                        State = E_ScreenState.None;
                }
                else
                    Time = MathHelper.Min( Time + frameTime, EndTimer );

                break;
            }
            }
        }
Exemplo n.º 10
0
        // SetNextScreen
        public void SetNextScreen( Screen nextScreen )
        {
            if ( CurrentScreen == null )
            {
            // initial screen
            CurrentScreen = nextScreen;
            State = E_ScreenState.Init;
            }
            else
            {
            // next screen
            NextScreen = nextScreen;
            State = E_ScreenState.End;
            Time = 0.0f;

            CurrentScreen.TimelineActive( "start", false, false );
            CurrentScreen.TimelineActive( "end", true, false );
            }
        }