Ejemplo n.º 1
0
        private GameObject CreateTargetScreen(SlideScreen targetScreen)
        {
            var generated = targetScreen.CreateScreen(centerCanvas.gameObject);

            switch (targetScreen.MoveInDirection)
            {
            case Direction.Left:
                generated.GetComponent <SlideScreen>().InitialPosition = rightCanvas.position;
                break;

            case Direction.Right:
                generated.GetComponent <SlideScreen>().InitialPosition = leftCanvas.position;
                break;

            case Direction.Up:
                generated.GetComponent <SlideScreen>().InitialPosition = downCanvas.position;
                break;

            case Direction.Down:
                generated.GetComponent <SlideScreen>().InitialPosition = upCanvas.position;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(generated);
        }
Ejemplo n.º 2
0
        private void ExecuteSequence(SlideScreen targetScreen, Vector3 currentScreenMoveTo)
        {
            sequence = DOTween.Sequence()
                       .Append(targetScreen.transform.DOMove(centerCanvas.transform.position, slideDuration).SetEase(ease))
                       .Join(Current.transform.DOMove(currentScreenMoveTo, slideDuration).SetEase(ease)).OnComplete(() =>
            {
                OnEndSequence(targetScreen);
            });

            sequence.Play();
        }
Ejemplo n.º 3
0
        private void OnEndSequence(SlideScreen targetScreen)
        {
            targetScreen.OnEndSlide();
            if (Current.IsLeaveToScene)
            {
                instantiated.Add(Current);
            }
            else
            {
                Destroy(Current.gameObject);
            }

            Current  = targetScreen;
            sequence = null;
        }
Ejemplo n.º 4
0
 private void Start()
 {
     Current = initialScreen;
     initialScreen.GetComponent <RectTransform>().sizeDelta = gameObject.GetComponent <RectTransform>().GetSize();
     if (!isRememberStack)
     {
         screenStack = new Stack <string>();
     }
     else
     {
         screenStack = SlideScreenStacker.Instance.GetStackReference(sceneName);
         var preserved = slideDuration;
         slideDuration = 0;
         Backward();
         slideDuration = preserved;
     }
 }
Ejemplo n.º 5
0
        private bool DoSlide(SlideScreen targetScreen, bool isBackward)
        {
            Vector3 currentScreenMoveTo;

            try
            {
                if (isBackward)
                {
                    switch (Current.MoveInDirection)
                    {
                    case Direction.Left:
                        currentScreenMoveTo             = rightCanvas.transform.position;
                        targetScreen.transform.position = leftCanvas.transform.position;
                        break;

                    case Direction.Right:
                        currentScreenMoveTo             = leftCanvas.transform.position;
                        targetScreen.transform.position = rightCanvas.transform.position;
                        break;

                    case Direction.Up:
                        currentScreenMoveTo             = downCanvas.transform.position;
                        targetScreen.transform.position = upCanvas.transform.position;
                        break;

                    case Direction.Down:
                        currentScreenMoveTo             = upCanvas.transform.position;
                        targetScreen.transform.position = downCanvas.transform.position;
                        break;

                    default:
                        return(false);
                    }
                }
                else
                {
                    switch (targetScreen.MoveInDirection)
                    {
                    case Direction.Left:
                        currentScreenMoveTo             = leftCanvas.transform.position;
                        targetScreen.transform.position = rightCanvas.transform.position;
                        break;

                    case Direction.Right:
                        currentScreenMoveTo             = rightCanvas.transform.position;
                        targetScreen.transform.position = leftCanvas.transform.position;
                        break;

                    case Direction.Up:
                        currentScreenMoveTo             = upCanvas.transform.position;
                        targetScreen.transform.position = downCanvas.transform.position;
                        break;

                    case Direction.Down:
                        currentScreenMoveTo             = downCanvas.transform.position;
                        targetScreen.transform.position = upCanvas.transform.position;
                        break;

                    default:
                        return(false);
                    }
                }
            }
            catch (NullReferenceException ex)
            {
                UnityConsole.Log(ex.ToString());
                return(false);
            }

            ExecuteSequence(targetScreen, currentScreenMoveTo);

            return(true);
        }