Beispiel #1
0
        public void Start( )
        {
            if (_started)
            {
                return;
            }

            _propertyInfo = _propertiesThisAppliesTo.GetType( ).GetProperty(_behaviourProperties.NameOfPropertyToModify);

            if (_propertyInfo.PropertyType != typeof(Vector2))
            {
                throw new InvalidOperationException(@"Only Vector2 properties are valid for animating positions.");
            }

            _originalValue = _propertyInfo.GetValue(_propertiesThisAppliesTo, null);

            _tweener = new Vector2Tweener(
                _behaviourProperties.From,
                _behaviourProperties.To,
                TimeSpan.FromSeconds(_behaviourProperties.DurationInSeconds),
                Tweener.CreateTweeningFunction(
                    Type.GetType(_behaviourProperties.ClrTypeOfInterpolator), _behaviourProperties.Easing));

            _started = true;
        }
Beispiel #2
0
        public virtual void moveRight()
        {


            tween = new Vector2Tweener(new Vector2(x, y), new Vector2(x + 24, y), moveSpeed(), XNATweener.Cubic.EaseOut);
            tween.Ended += new EndHandler(endTween);
        }
        /// <summary>
        /// Function used to set our animation parameters
        /// </summary>
        /// <param name="transition">Type of interpolation function to utilize</param>
        /// <param name="startPosition"> Our start position</param>
        /// <param name="endPosition">Our end position</param>
        /// <param name="durationInSeconds">How many seconds the animation should take</param>
        public void Animate(TypeOfTransition transition, Vector3 startPosition, Vector3 endPosition, double durationInSeconds)
        {
            currentTransition = transition;

            switch (kindOfAnimation)
            {
            case VariableToAnimate.floatValue:
                singleValueTweener = new Tweener(startPosition.X, endPosition.X, TimeSpan.FromSeconds(durationInSeconds), GetTweeningFunction());
                singleValueTweener.PositionChanged += delegate(float newPosition) { returnValue = new Vector3(newPosition, 0, 0); };
                break;

            case VariableToAnimate.Vector2Value:
                vectorTwoTweener = new Vector2Tweener(new Vector2(startPosition.X, startPosition.Y), new Vector2(endPosition.X, endPosition.Y), TimeSpan.FromSeconds(durationInSeconds), GetTweeningFunction());
                vectorTwoTweener.PositionChanged += delegate(Vector2 newPosition) { returnValue = new Vector3(newPosition.X, newPosition.Y, 0); };
                break;

            case VariableToAnimate.Vector3Value:
                vector3Tweener = new Vector3Tweener(startPosition, endPosition, TimeSpan.FromSeconds(durationInSeconds), GetTweeningFunction());
                vector3Tweener.PositionChanged += delegate(Vector3 newPosition) { returnValue = newPosition; };
                break;

            default:
                vector3Tweener = new Vector3Tweener(startPosition, endPosition, TimeSpan.FromSeconds(durationInSeconds), GetTweeningFunction());
                vector3Tweener.PositionChanged += delegate(Vector3 newPosition) { returnValue = newPosition; };
                break;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Sprite Constructor
        /// </summary>
        /// <param name="xPos"></param>
        /// <param name="yPos"></param>
        public Character(int xPos, int yPos)
            : base(xPos, yPos)
        {
            tween = new Vector2Tweener(new Vector2(x,y), new Vector2(x,y), 0.3f, XNATweener.Cubic.EaseOut);

            tween.Ended +=new EndHandler(endTween);

            tween.Pause();
            
        }
        public void Start( )
        {
            if (_started)
            {
                return;
            }

            _propertyInfo = _propertiesThisAppliesTo.GetType( ).GetProperty(_behaviourProperties.NameOfPropertyToModify);

            _originalValue = _propertyInfo.GetValue(_propertiesThisAppliesTo, null);

            _tweener = new Vector2Tweener(
                _behaviourProperties.From.AsVector2(  ),
                _behaviourProperties.To.AsVector2(  ),
                TimeSpan.FromSeconds(_behaviourProperties.DurationInSeconds),
                Tweener.CreateTweeningFunction(
                    Type.GetType(_behaviourProperties.ClrTypeOfInterpolator), _behaviourProperties.Easing));

            _started = true;
        }
Beispiel #6
0
        /// <summary>
        /// Function used to set our animation parameters
        /// </summary>
        /// <param name="transition">Type of interpolation function to utilize</param>
        /// <param name="startPosition"> Our start position</param>
        /// <param name="endPosition">Our end position</param>
        /// <param name="durationInSeconds">How many seconds the animation should take</param>
        public void Animate(TypeOfTransition transition, Vector3 startPosition, Vector3 endPosition, double durationInSeconds)
        {
            currentTransition = transition;

            switch (kindOfAnimation)
            {
                case VariableToAnimate.floatValue:
                    singleValueTweener = new Tweener(startPosition.X, endPosition.X, TimeSpan.FromSeconds(durationInSeconds), GetTweeningFunction());
                    singleValueTweener.PositionChanged += delegate(float newPosition) { returnValue = new Vector3(newPosition, 0, 0); };
                    break;
                case VariableToAnimate.Vector2Value:
                    vectorTwoTweener = new Vector2Tweener(new Vector2(startPosition.X, startPosition.Y), new Vector2(endPosition.X, endPosition.Y), TimeSpan.FromSeconds(durationInSeconds), GetTweeningFunction());
                    vectorTwoTweener.PositionChanged += delegate(Vector2 newPosition) { returnValue = new Vector3(newPosition.X, newPosition.Y, 0); };
                    break;

                case VariableToAnimate.Vector3Value:
                    vector3Tweener = new Vector3Tweener(startPosition, endPosition, TimeSpan.FromSeconds(durationInSeconds), GetTweeningFunction());
                    vector3Tweener.PositionChanged += delegate(Vector3 newPosition) { returnValue = newPosition;};
                    break;

                default:
                    vector3Tweener = new Vector3Tweener(startPosition, endPosition, TimeSpan.FromSeconds(durationInSeconds), GetTweeningFunction());
                    vector3Tweener.PositionChanged += delegate(Vector3 newPosition) { returnValue = newPosition;};
                    break;
            }
        }
Beispiel #7
0
 protected virtual void CreateNewTweener()
 {
     tweener = new Vector2Tweener(spritePosition, pointerPosition, TimeSpan.FromSeconds(duration), GetTweeningFunction());
     tweener.PositionChanged += delegate(Vector2 newPosition) { spritePosition = newPosition; };
 }