Example #1
0
        public async Task Proceed(CardsView cardsView, params ProcessorItem[] items)
        {
            var    animation = new AnimationWrapper();
            Action onFinish  = null;

            foreach (var item in items)
            {
                var view = item.Views.FirstOrDefault();

                if (item.IsFront)
                {
                    if (view != null)
                    {
                        view.Scale = 1;
                    }
                    continue;
                }

                if (view != null)
                {
                    animation.Add(0, 1, new AnimationWrapper(v => view.Opacity = v, view.Opacity, 0));
                    onFinish = () => view.IsVisible = false;
                }
            }
            await animation.Commit(cardsView, Path.GetRandomFileName(), 16, AnimationLength, AnimationEasing);

            onFinish?.Invoke();
        }
Example #2
0
        public override Task Reset(CardsView cardsView, params ProcessorItem[] items)
        {
            var animation  = new AnimationWrapper();
            var animLength = AnimationLength;
            var step       = GetStep(cardsView);

            foreach (var item in items)
            {
                var view = item.Views.FirstOrDefault();
                if (view == null)
                {
                    continue;
                }

                if (item.IsFront)
                {
                    var animTimePercent = 1 - (step - Abs(GetTranslationX(view, cardsView))) / step;
                    animLength = Max((uint)(AnimationLength * animTimePercent) * 3 / 2, 1);
                    animation.Add(0, 1, new AnimationWrapper(v => SetTranslationX(view, v, cardsView, true), GetTranslationX(view, cardsView), 0));
                    continue;
                }

                if (view == cardsView.CurrentView)
                {
                    continue;
                }
                var otherViews = item.Views.Union(item.InactiveViews ?? Enumerable.Empty <View>()).Except(Enumerable.Repeat(view, 1));
                animation.Add(0, 1, new AnimationWrapper(v => ProceedPositionChanged(v, view, otherViews, cardsView), GetTranslationX(view, cardsView), Sign((int)item.Direction) * step));
            }
            return(animation.Commit(cardsView, Path.GetRandomFileName(), 16, animLength, AnimationEasing));
        }
Example #3
0
        public virtual Task Reset(CardsView cardsView, params ProcessorItem[] items)
        {
            var animation  = new AnimationWrapper();
            var animLength = AnimationLength;

            foreach (var item in items)
            {
                var view = item.Views.FirstOrDefault();
                if (view == null)
                {
                    continue;
                }

                if (item.IsFront)
                {
                    var animTimePercent = 1 - (cardsView.GetSize() - Abs(GetTranslationX(view, cardsView))) / cardsView.GetSize();
                    animLength = Max((uint)(AnimationLength * animTimePercent) * 3 / 2, 1);
                    animation.Add(0, 1, new AnimationWrapper(v => SetTranslationX(view, v, cardsView, true), GetTranslationX(view, cardsView), 0));
                    continue;
                }

                if (view == cardsView.CurrentView)
                {
                    continue;
                }
                animation.Add(0, 1, new AnimationWrapper(v => SetTranslationX(view, v, cardsView, false), GetTranslationX(view, cardsView), Sign((int)item.Direction) * cardsView.GetSize()));
            }

            return(animation.Commit(cardsView, Path.GetRandomFileName(), 16, animLength, AnimationEasing));
        }
Example #4
0
        public virtual Task Navigate(CardsView cardsView, params ProcessorItem[] items)
        {
            var animation = new AnimationWrapper();
            var lenght    = AnimationLength;

            foreach (var item in items)
            {
                var view = item.Views.FirstOrDefault();
                if (view == null)
                {
                    continue;
                }
                view.IsVisible = true;
                if (item.IsFront)
                {
                    animation.Add(0, 1, new AnimationWrapper(v => SetTranslationX(view, v, cardsView, true), GetTranslationX(view, cardsView), 0));
                    continue;
                }

                var destinationPos = item.Direction == AnimationDirection.Prev
                    ? cardsView.GetSize()
                    : -cardsView.GetSize();

                animation.Add(0, 1, new AnimationWrapper(v => SetTranslationX(view, v, cardsView, false), 0, destinationPos));
            }
            return(animation.Commit(cardsView, Path.GetRandomFileName(), 16, AnimationLength, AnimationEasing));
        }
Example #5
0
    public void TriggerAnimation(string animatorAndAnimationName)
    {
        string animatorName  = animatorAndAnimationName.Split(stringSeparator)[0];
        string animationName = animatorAndAnimationName.Split(stringSeparator)[1];

        AnimationWrapper.StartAnimation(animatorName, animationName);
    }
Example #6
0
 private void Start()
 {
     animators = transform.GetComponentsInChildren <Animator>();
     if (singleton == null)
     {
         singleton = this;
     }
 }
	/// <summary>
	/// Unity method.
	/// Awake this instance.
	/// </summary>
	public override void Awake()
	{
		base.Awake();
		
		cachedAnimWrapper = AnimationWrapper.Instance;
		if (animationSource) {
			cachedAnimation = cachedAnimWrapper.GetAnimationComponent(animationSource);
		}
	}
    /// <summary>
    /// Unity method.
    /// Awake this instance.
    /// </summary>
    public override void Awake()
    {
        base.Awake();

        cachedAnimWrapper = AnimationWrapper.Instance;
        if (animationSource)
        {
            cachedAnimation = cachedAnimWrapper.GetAnimationComponent(animationSource);
        }
    }
Example #9
0
        public async Task Reset(CardsView cardsView, params ProcessorItem[] items)
        {
            var    animation  = new AnimationWrapper();
            var    animLength = AnimationLength;
            Action onFinish   = null;

            foreach (var item in items)
            {
                var view = item.Views.FirstOrDefault();

                if (item.IsFront)
                {
                    onFinish   = () => ResetInitialState(view, cardsView, true);
                    animLength = (uint)(AnimationLength * Min(Abs(view.TranslationX / cardsView.RealMoveDistance), 1.0));

                    if (animLength == 0)
                    {
                        continue;
                    }

                    animation.Add(0, 1, new AnimationWrapper {
                        { 0, 1, new AnimationWrapper(v => SetTranslationX(view, v, cardsView, true), view.TranslationX, 0) },
                        { 0, 1, new AnimationWrapper(v => view.TranslationY = v, view.TranslationY, 0) },
                        { 0, 1, new AnimationWrapper(v => view.Rotation = v, view.Rotation, 0) }
                    });
                    continue;
                }
                if (view == null || view == cardsView.CurrentView)
                {
                    continue;
                }
                animation.Add(0, 1, new AnimationWrapper(v => {
                    if (double.IsNaN(v))
                    {
                        return;
                    }
                    view.Scale = v;
                }, view.Scale, BackViewInitialScale));
            }
            await animation.Commit(cardsView, Path.GetRandomFileName(), 16, animLength, AnimationEasing);

            onFinish?.Invoke();
        }
Example #10
0
	/// <summary>
	/// Unity method. 
	/// Awake this instance.
	/// </summary>
	public override void Awake()
	{
		base.Awake();
		
		if (children.Count == 0) {
			cachedAnimWrapper = AnimationWrapper.Instance;
			cachedAnimation = cachedAnimWrapper.GetAnimationComponent(gameObject);
			
			cachedRenderWrapper = RenderWrapper.Instance;
			cachedRender = cachedRenderWrapper.GetRenderComponent(gameObject);
			
			if (cachedRender) {
				cachedRenderWrapper.ChangeAlpha(cachedRender, 0f);
			}
			else {
				Debug.LogWarning("TextBlock: " + name + " doesn't have a renderer!");
			}
		}
	}
Example #11
0
    /// <summary>
    /// Unity method.
    /// Awake this instance.
    /// </summary>
    public override void Awake()
    {
        base.Awake();

        if (children.Count == 0)
        {
            cachedAnimWrapper = AnimationWrapper.Instance;
            cachedAnimation   = cachedAnimWrapper.GetAnimationComponent(gameObject);

            cachedRenderWrapper = RenderWrapper.Instance;
            cachedRender        = cachedRenderWrapper.GetRenderComponent(gameObject);

            if (cachedRender)
            {
                cachedRenderWrapper.ChangeAlpha(cachedRender, 0f);
            }
            else
            {
                Debug.LogWarning("TextBlock: " + name + " doesn't have a renderer!");
            }
        }
    }
Example #12
0
        public override Task Navigate(CardsView cardsView, params ProcessorItem[] items)
        {
            var animation = new AnimationWrapper();

            foreach (var item in items)
            {
                var view = item.Views.FirstOrDefault();
                if (view == null)
                {
                    continue;
                }

                if (item.IsFront)
                {
                    animation.Add(0, 1, new AnimationWrapper(v => SetTranslationX(view, v, cardsView, true), GetTranslationX(view, cardsView), 0));
                    continue;
                }

                var otherViews = item.Views.Union(item.InactiveViews ?? Enumerable.Empty <View>()).Except(Enumerable.Repeat(view, 1));
                animation.Add(0, 1, new AnimationWrapper(v => ProceedPositionChanged(v, view, otherViews, cardsView), 0, -Sign((int)item.Direction) * GetStep(cardsView)));
            }
            return(animation.Commit(cardsView, Path.GetRandomFileName(), 16, AnimationLength, AnimationEasing));
        }
        public void IsRunningShouldReportStatus()
        {
            var animation = new Animation
            {
                { 0, 1, new Animation(d => { }) }
            };

            var animationWrapper = new AnimationWrapper(
                animation,
                Guid.NewGuid().ToString(),
                new BoxView(),
                16,
                100,
                Easing.Linear,
                (v, t) => { },
                () => false);

            Assert.IsFalse(animationWrapper.IsRunning);

            animationWrapper.Commit();

            Assert.IsTrue(animationWrapper.IsRunning);
        }
Example #14
0
 private void AddAnimation( AnimationWrapper wrapper )
 {
     animations[wrapper.name] = wrapper;
 }
Example #15
0
 public void StartLevel()
 {
     AnimationWrapper.StartLevel();
 }
Example #16
0
 private void Start()
 {
     animationWrapper = gameObject.AddComponent <AnimationWrapper>();
     content          = platformDependentComponent.CanvasGroup;
 }