Exemple #1
0
        private void CreateAnimationCycle()
        {
            _transform = this.GameObject.GetComponent<TransformationComponent>();

            _animationProcess = Process.BuildProcessChain(
                new TweenProcess(Easing.GetSineFunction(), _duration, interp =>
                {
                    _transform.Scale = GetTweenedSwellSize(interp.Value);
                }),
                new TweenProcess(Easing.ConvertTo(EasingKind.EaseOut, Easing.GetSineFunction()), _duration, interp =>
                {
                    _transform.Scale = GetTweenedSwellSize(1.0f - interp.Value);
                }),
                new ActionProcess(() =>
                {
                    _transform.Scale = 1.0f;
                    if (_isRepeating)
                    {
                        CreateAnimationCycle();
                    }
                    else
                    {
                        // We are done, remove self
                        this.GameObject.RemoveComponent<SwellComponent>();
                    }
                }));

            this.GameObject.ProcessManager.AttachProcess(_animationProcess);
        }
Exemple #2
0
        private void CreateAnimationCycle()
        {
            _transform = this.GameObject.GetComponent <TransformationComponent>();

            _animationProcess = Process.BuildProcessChain(
                new TweenProcess(Easing.GetSineFunction(), _duration, interp =>
            {
                _transform.Scale = GetTweenedSwellSize(interp.Value);
            }),
                new TweenProcess(Easing.ConvertTo(EasingKind.EaseOut, Easing.GetSineFunction()), _duration, interp =>
            {
                _transform.Scale = GetTweenedSwellSize(1.0f - interp.Value);
            }),
                new ActionProcess(() =>
            {
                _transform.Scale = 1.0f;
                if (_isRepeating)
                {
                    CreateAnimationCycle();
                }
                else
                {
                    // We are done, remove self
                    this.GameObject.RemoveComponent <SwellComponent>();
                }
            }));

            this.GameObject.ProcessManager.AttachProcess(_animationProcess);
        }
Exemple #3
0
        protected override void OnLoaded()
        {
            _transform = this.GameObject.GetComponent <TransformationComponent>();

            this.GameObject.ProcessManager.AttachProcess(Process.BuildProcessChain(
                                                             new TweenProcess(_duration, interp =>
            {
                var shakeDistance = 0f;
                if (_shakeHarderAtEnd)
                {
                    shakeDistance = (float)(_maximumShakeDistance * interp.Value);
                }
                else
                {
                    shakeDistance = (float)(_maximumShakeDistance - (_maximumShakeDistance * interp.Value));
                }

                var rotation = _random.NextDouble() * (2 * Math.PI);
                var offset   = new Vector2(shakeDistance, 0);
                offset       = Vector2.Transform(offset, Matrix.CreateRotationZ((float)rotation));

                _transform.PositionOffset = offset;
            }),
                                                             new ActionProcess(() =>
            {
                _transform.PositionOffset = Vector2.Zero;
                this.GameObject.RemoveComponent <ShakeComponent>();
            })));
        }
Exemple #4
0
        protected override void OnLoaded()
        {
            _transform = this.GameObject.GetComponent<TransformationComponent>();

            this.GameObject.ProcessManager.AttachProcess(Process.BuildProcessChain(
                new TweenProcess(_duration, interp =>
                {
                    var shakeDistance = 0f;
                    if (_shakeHarderAtEnd)
                    {
                        shakeDistance = (float)(_maximumShakeDistance * interp.Value);
                    }
                    else
                    {
                        shakeDistance = (float)(_maximumShakeDistance - (_maximumShakeDistance * interp.Value));
                    }

                    var rotation = _random.NextDouble() * (2 * Math.PI);
                    var offset = new Vector2(shakeDistance, 0);
                    offset = Vector2.Transform(offset, Matrix.CreateRotationZ((float)rotation));

                    _transform.PositionOffset = offset;
                }),
                new ActionProcess(() =>
                {
                    _transform.PositionOffset = Vector2.Zero;
                    this.GameObject.RemoveComponent<ShakeComponent>();
                })));
        }