コード例 #1
0
        private void PlayIntroAnimation()
        {
            FrameRendering += DrawOverlay;
            _introAnimation = new IntroAnimation(_logger, _profileService, _surfaceService);

            // Draw a white overlay over the device
            void DrawOverlay(object sender, FrameRenderingEventArgs args)
            {
                if (_introAnimation == null)
                {
                    args.Canvas.Clear(new SKColor(0, 0, 0));
                }
                else
                {
                    _introAnimation.Render(args.DeltaTime, args.Canvas, _rgbService.BitmapBrush.Bitmap.Info);
                }
            }

            TimeSpan introLength = _introAnimation.AnimationProfile.GetAllLayers().Max(l => l.TimelineLength);

            // Stop rendering after the profile finishes (take 1 second extra in case of slow updates)
            Task.Run(async() =>
            {
                await Task.Delay(introLength.Add(TimeSpan.FromSeconds(1)));
                FrameRendering -= DrawOverlay;

                _introAnimation.AnimationProfile?.Dispose();
                _introAnimation = null;
            });
        }
コード例 #2
0
    public void AddObjectToAnimate(GameObject obj, Vector3 offset)
    {
        if (!obj.activeSelf)
        {
            return;
        }

        Vector3        pos  = obj.transform.localPosition;
        IntroAnimation anim = obj.AddComponent <IntroAnimation>();

        anim.Init(
            this,
            animatingObjects.Count * DelayBetweenObjectAnimations,
            pos - offset,
            pos
            );

        animatingObjects.Add(obj);
    }
コード例 #3
0
    // IntroAnimation.Listener Implementation
    public void OnAnimationComplete(IntroAnimation anim)
    {
        Destroy(anim);
        completeAnimations++;

        if (completeAnimations == animatingObjects.Count)
        {
            Debug.Log("Intro Complete");
            foreach (GameObject obj in objectsToHide)
            {
                obj.SetActive(true);
            }
            foreach (Listener listener in listeners)
            {
                listener.OnIntroComplete();
            }

            Destroy(this);
        }
    }