コード例 #1
0
    private void TriggerViewAnimation(IView view, string trigger)
    {
        IAnimatedView av = view as IAnimatedView;

        if (av == null)
        {
            return;
        }

        if (av.Animators == null || av.Animators.Length == 0)
        {
            return;
        }

        if (string.IsNullOrEmpty(trigger))
        {
            Debug.LogWarning("Missing trigger name on view: " + view.Name);
            return;
        }

        for (int i = 0; i < av.Animators.Length; i++)
        {
            av.Animators[i].SetTrigger(trigger);
        }
    }
コード例 #2
0
        protected virtual void Awake()
        {
            Transform thisTransform = transform;

            if (thisTransform.childCount == 0)
            {
                Debug.LogError($"{this} MUST have 1 child view GameObject. ViewController's transform path: {gameObject.GetFullPath()}");
                return;
            }

            view = thisTransform.GetChild(0).GetComponent <View>();
            _animatedViewInterface = view as IAnimatedView;
            if (_animatedViewInterface != null)
            {
                _animatedViewInterface.SetViewController(this);
            }

            ViewDidLoad();

            if (_visibleWhenFirstLoaded || _animatedViewInterface == null)
            {
                return;
            }

            _animatedViewInterface.Hide(false);
        }
コード例 #3
0
 public SpawnAnimator(IAnimatedView view,
                      Core.Coordinate spawnCoordinate,
                      Core.BlockData blockData)
 {
     this.view            = view;
     this.spawnCoordinate = spawnCoordinate;
     this.blockData       = blockData;
 }
コード例 #4
0
 public MoveAnimator(IAnimatedView view,
                     Coordinate from,
                     Coordinate to)
 {
     this.view = view;
     this.from = from;
     this.to   = to;
 }
コード例 #5
0
    public void ShowView(IAnimatedView view, ShowMode mode = ShowMode.ReplaceTop)
    {
        if (currentView == null)
        {
            // we assume this is the first time we are showing a view, so just to be safe hide the other views...
            for (int i = 0; i < views.Length; i++)
            {
                SetViewActive(views[i], false);
            }
        }

        if (view == currentView)
        {
            return;
        }

        if (transitionPending)
        {
            if (Debug.isDebugBuild)
            {
                Debug.Log("Show(view) request was queue due to pending transition: " + view.Name);
            }

            // store to call when the pending transition is done, this over-writes with the latest request on purpose
            nextView         = view;
            nextViewShowMode = mode;
            return;
        }
        else
        {
            nextView = null;
        }

        if (Debug.isDebugBuild)
        {
            Debug.Log("Beginning view transition: " + view.Name);
        }

        if (mode == ShowMode.ReplaceTop && viewStack.Count > 1)
        {
            viewStack.Pop();
        }

        viewStack.Push(view);

        googleAnalytics.LogScreen(view.Name);

        // Fire the view change event immediately after the view is pushed onto
        // the stack. This updates the InPreview and InLibrary properties
        // without waiting for the view to actually transition.
        if (ViewChanged != null)
        {
            ViewChanged();
        }

        StartCoroutine(TransitionView(currentView, view, corssfadePercentage));
    }
コード例 #6
0
 public void BackUntilButPush(IAnimatedView backUntilView, IAnimatedView pushView)
 {
     while (viewStack.Count > 0)
     {
         if (viewStack.Pop() == backUntilView)
         {
             break;
         }
     }
     viewStack.Push(backUntilView);
     ShowView(pushView, ShowMode.PushView);
 }
コード例 #7
0
    public void BackUntil(IAnimatedView view)
    {
        while (viewStack.Count > 0)
        {
            if (viewStack.Pop() == view)
            {
                break;
            }
        }

        ShowView(view, ShowMode.PushView);
    }
コード例 #8
0
    private void ShowViewImmediate(IAnimatedView view)
    {
        // this is a SUPER special case where we want to pop the view on immediately with no animation
        currentView = viewStack.Peek();         // this should be the share choice dialog
        currentView.LeavingPercent(1.0f);
        currentView.OutOfView(view);
        SetViewActive(currentView, false);
        viewStack.Pop();         // pop off the share choice dialog

        currentView = viewStack.Peek();
        viewStack.Push(view);
        SetViewActive(view, true);
        view.EnteringPercent(1.0f);
        view.InView(currentView);
        currentView = view;
    }
コード例 #9
0
    public void BackUntilPopped(IAnimatedView view)
    {
        while (viewStack.Count > 0)
        {
            if (viewStack.Pop() == view)
            {
                break;
            }
        }

        if (viewStack.Count > 0)
        {
            StartCoroutine(TransitionView(currentView, viewStack.Peek(), corssfadePercentage));
        }
        else
        {
            Debug.LogWarning("BackUntilPopped('" + view.Name + "') stack was empty after popping. replacing with default view");
            ShowView(defaultView, ShowMode.ReplaceTop);
        }
    }
コード例 #10
0
 public DestroyAnimator(IAnimatedView view,
                        Coordinate blockCoordinate)
 {
     this.view            = view;
     this.blockCoordinate = blockCoordinate;
 }
コード例 #11
0
    IEnumerator TransitionView(IAnimatedView oldView, IAnimatedView newView, float crossfadePercent = 0.0f)
    {
        // crossfade delay
        transitionPending = true;
        float startTime      = Time.time;
        float newStartTime   = startTime;
        float newEndTime     = startTime;
        bool  oldViewDone    = true;
        bool  newViewStarted = false;

        if (oldView != null)
        {
            newStartTime = startTime + (1 - crossfadePercent) * oldView.OutTime;
            TriggerViewAnimation(oldView, oldView.OutTrigger);
            oldViewDone = false;
            oldView.LeavingView(newView);
        }

        if (newView != null)
        {
            newEndTime = newStartTime + newView.InTime;
        }

        while (true)
        {
            float ellapsed = Time.time - startTime;

            if (!oldViewDone)
            {
                float p = Mathf.Clamp01(ellapsed / oldView.OutTime);

                oldView.LeavingPercent(p);

                if (p == 1.0f)
                {
                    oldView.OutOfView(newView);
                    SetViewActive(oldView, false);
                    oldViewDone = true;
                }
            }

            if (!newViewStarted && Time.time >= newStartTime)
            {
                SetViewActive(newView, true);
                newView.EnteringView(oldView);
                TriggerViewAnimation(newView, newView.InTrigger);
                newViewStarted = true;
                currentView    = newView;
            }

            if (newViewStarted)
            {
                float p = Mathf.Clamp01((Time.time - newStartTime) / newView.InTime);
                newView.EnteringPercent(p);
                if (p == 1.0f)
                {
                    newView.InView(oldView);
                    break;
                }
            }

            yield return(null);
        }

        transitionPending = false;

        DumpViewStack();

        if (nextView != null)
        {
            // special case for Back show mode for now...
            if (nextViewShowMode == ShowMode.Back)
            {
                Back();
            }
            else
            {
                ShowView(nextView, nextViewShowMode);
            }
        }
    }
コード例 #12
0
    void Awake()
    {
        if (sprayCam == null)
        {
            sprayCam = FindObjectOfType <SprayCam>();
        }

        if (editViewObject == null)
        {
            throw new MissingReferenceException("Edit view reference is missing on: " + this);
        }

        if (listViewObject == null)
        {
            throw new MissingReferenceException("List view reference is missing on: " + this);
        }

        if (viewViewObject == null)
        {
            throw new MissingReferenceException("View view reference is missing on: " + this);
        }

        if (savingViewObject == null)
        {
            throw new MissingReferenceException("Saving view reference is missing on: " + this);
        }

        if (deleteViewObject == null)
        {
            throw new MissingReferenceException("Delete view reference is missing on: " + this);
        }

        if (clearViewObject == null)
        {
            throw new MissingReferenceException("Clear view reference is missing on: " + this);
        }

        if (saveCompleteViewObject == null)
        {
            throw new MissingReferenceException("Save Complete view reference is missing on: " + this);
        }

        if (timeToTidayViewObject == null)
        {
            throw new MissingReferenceException("Time to Tidy view reference is missing on: " + this);
        }

        if (googleViewObject == null)
        {
            throw new MissingReferenceException("Google view reference is missing on: " + this);
        }

        if (shareChoiceObject == null)
        {
            throw new MissingReferenceException("Share Choice view reference is missing on: " + this);
        }

        if (uploadingViewObject == null)
        {
            throw new MissingReferenceException("Uploading view reference is missing on: " + this);
        }

        // this is getting stupid....
        if (uploadFailedObject == null)
        {
            throw new MissingReferenceException("Upload Failed view reference is missing on: " + this);
        }

        if (authConfirmObject == null)
        {
            throw new MissingReferenceException("Auth Confirm view reference is missing on: " + this);
        }

        if (accountProhibitedObject == null)
        {
            throw new MissingReferenceException("Account Prohibited view reference is missing on: " + this);
        }

        if (aboutViewObject == null)
        {
            throw new MissingReferenceException("About wiew reference is missing on: " + this);
        }

        if (facebookShareBackgroundObject == null)
        {
            throw new MissingReferenceException("Share Background view reference is missing on: " + this);
        }

        if (blankShareBackgroundObject == null)
        {
            throw new MissingReferenceException("Blank Background view reference is missing on: " + this);
        }

        if (contactsPermissionErrorObject == null)
        {
            throw new MissingReferenceException("Contacts Error view reference is missing on: " + this);
        }

        if (noGyroObject == null)
        {
            throw new MissingReferenceException("No gyro view reference is missing on: " + this);
        }

        if (badConnectionObject == null)
        {
            throw new MissingReferenceException("Bad Connection view reference is missing on: " + this);
        }

        if (driveAuthFailedObject == null)
        {
            throw new MissingReferenceException("Drive Auth Failed view reference is missing on: " + this);
        }


        editView = editViewObject.GetComponent <IAnimatedView>();
        if (editView == null)
        {
            throw new MissingComponentException("Edit view object is missing a component that implements IAnimatedView on: " + this);
        }

        listView = listViewObject.GetComponent <IAnimatedView>();
        if (listView == null)
        {
            throw new MissingComponentException("List view object is missing a component that implements IAnimatedView on: " + this);
        }

        viewView = viewViewObject.GetComponent <IAnimatedView>();
        if (viewView == null)
        {
            throw new MissingComponentException("View view object is missing a component that implements IAnimatedView on: " + this);
        }

        savingView = savingViewObject.GetComponent <IAnimatedView>();
        if (savingView == null)
        {
            throw new MissingComponentException("Saving view object is missing a component that implements IAnimatedView on: " + this);
        }

        deleteView = deleteViewObject.GetComponent <IAnimatedView>();
        if (deleteView == null)
        {
            throw new MissingComponentException("Delete view object is missing a component that implements IAnimatedView on: " + this);
        }

        clearView = clearViewObject.GetComponent <IAnimatedView>();
        if (clearView == null)
        {
            throw new MissingComponentException("Clear view object is missing a component that implements IAnimatedView on: " + this);
        }

        saveCompleteView = saveCompleteViewObject.GetComponent <IAnimatedView>();
        if (saveCompleteView == null)
        {
            throw new MissingComponentException("Save Complete view object is missing a component that implements IAnimatedView on: " + this);
        }

        googleView = googleViewObject.GetComponent <IAnimatedView>();
        if (googleView == null)
        {
            throw new MissingComponentException("Google view object is missing a component that implements IAnimatedView on: " + this);
        }

        shareChoiceView = shareChoiceObject.GetComponent <IAnimatedView>();
        if (shareChoiceView == null)
        {
            throw new MissingComponentException("Share Choice view object is missing a component that implements IAnimatedView on: " + this);
        }

        shareLinkChoiceView = shareLinkChoiceObject.GetComponent <IAnimatedView>();
        if (shareLinkChoiceView == null)
        {
            throw new MissingComponentException("Share Link Choice view object is missing a component that implements IAnimatedView on: " + this);
        }

        timeToTidayView = timeToTidayViewObject.GetComponent <IAnimatedView>();
        if (timeToTidayView == null)
        {
            throw new MissingComponentException("Time to Tidy view object is missing a component that implements IAnimatedView on: " + this);
        }

        uploadingView = uploadingViewObject.GetComponent <IAnimatedView>();
        if (uploadingView == null)
        {
            throw new MissingComponentException("Uploading view object is missing a component that implements IAnimatedView on: " + this);
        }

        uploadFailedView = uploadFailedObject.GetComponent <IAnimatedView>();
        if (uploadFailedView == null)
        {
            throw new MissingComponentException("Upload Failed view object is missing a component that implements IAnimatedView on: " + this);
        }

        authConfirmView = authConfirmObject.GetComponent <IAnimatedView>();
        if (authConfirmView == null)
        {
            throw new MissingComponentException("Auth Confirm view object is missing a component that implements IAnimatedView on: " + this);
        }

        aboutView = aboutViewObject.GetComponent <IAnimatedView>();
        if (aboutView == null)
        {
            throw new MissingComponentException("About view object is missing a component that implements IAnimatedView on: " + this);
        }

        accountProhibitedView = accountProhibitedObject.GetComponent <IAnimatedView>();
        if (accountProhibitedView == null)
        {
            throw new MissingComponentException("Account Prohibited view object is missing a component that implements IAnimatedView on: " + this);
        }

        facebookShareBackgroundView = facebookShareBackgroundObject.GetComponent <IAnimatedView>();
        if (facebookShareBackgroundView == null)
        {
            throw new MissingComponentException("Facebook Share Background view object is missing a component that implements IAnimatedView on: " + this);
        }

        blankShareBackgroundView = blankShareBackgroundObject.GetComponent <IAnimatedView>();
        if (blankShareBackgroundView == null)
        {
            throw new MissingComponentException("Blank Share Background view object is missing a component that implements IAnimatedView on: " + this);
        }

        contactsPermissionErrorView = contactsPermissionErrorObject.GetComponent <IAnimatedView>();
        if (contactsPermissionErrorView == null)
        {
            throw new MissingComponentException("Contacts Permission Error view object is missing a component that implements IAnimatedView on: " + this);
        }

        noGyroView = noGyroObject.GetComponent <IAnimatedView>();
        if (noGyroView == null)
        {
            throw new MissingComponentException("No Gyro view object is missing a component that implements IAnimatedView on: " + this);
        }

        badConnectionView = badConnectionObject.GetComponent <IAnimatedView>();
        if (badConnectionView == null)
        {
            throw new MissingComponentException("No Gyro view object is missing a component that implements IAnimatedView on: " + this);
        }

        driveAuthFailedView = driveAuthFailedObject.GetComponent <IAnimatedView>();
        if (driveAuthFailedView == null)
        {
            throw new MissingComponentException("Drive Auth Failed view object is missing a component that implements IAnimatedView on: " + this);
        }

        views = new IAnimatedView[] { editView, listView, viewView, savingView, deleteView, clearView, saveCompleteView, shareLinkChoiceView, timeToTidayView, googleView, shareChoiceView, uploadingView, uploadFailedView, authConfirmView, aboutView, accountProhibitedView, facebookShareBackgroundView, blankShareBackgroundView, contactsPermissionErrorView, noGyroView, badConnectionView, driveAuthFailedView };

        defaultView = editView;

        if (libaryController == null)
        {
            libaryController = FindObjectOfType <LibraryController>();
        }
    }
コード例 #13
0
 public void ShowNoGyro()
 {
     defaultView = noGyroView;
     ShowView(noGyroView);
 }