コード例 #1
0
    //Animate By
    public void AnimateBy(UnityEngine.Object obj, float Duration, GameObject CallbackObj, object CallbackMsg, object CallbackParams, params object[] args)
    {
        int          Count = 0;
        object       tmpProperty, tmpValue;
        AnimationObj tmpObj = new AnimationObj();

        //Setup new animation object
        tmpObj.Obj            = obj;
        tmpObj.Cmd            = "By";
        tmpObj.Duration       = Duration;
        tmpObj.CallbackObj    = CallbackObj;
        tmpObj.CallbackMsg    = (string)CallbackMsg;
        tmpObj.CallbackParams = CallbackParams;
        for (Count = 0; Count < args.Length; Count = Count + 2)
        {
            //Make sure we don't go pass the end of the array
            if ((Count + 2) <= args.Length)
            {
                tmpProperty = args[Count];
                tmpValue    = args[Count + 1];
                tmpObj.Properties.Add(tmpProperty, tmpValue);
            }
        }

        //Add object to array
        mAnimate.Add(tmpObj);
    }
コード例 #2
0
ファイル: Drawingboard.xaml.cs プロジェクト: tingxin/Kiosk
        private void CreateRotateAnimation(StrokeCollection strokes, Point centerOffset, Point from, Point to)
        {
            Rect         bound = strokes.GetBounds();
            AnimationObj obj   = AnimationEngine.AddDurationActionAnimation(strokes, AnimationActionType.Rotate, centerOffset, 5, from, to, true);

            obj.Begin();
        }
コード例 #3
0
ファイル: Animator.cs プロジェクト: TheMadGamer/Snowboarder
    /*----------------------------------------Methods----------------------------------------*/
    //Animate To
    public void AnimateTo(UnityEngine.Object obj, float Duration, GameObject CallbackObj, object CallbackMsg, object CallbackParams, params object[] args)
    {
        int Count = 0;
        object tmpProperty, tmpValue;
        AnimationObj tmpObj = new AnimationObj();

        //Setup new animation object
        tmpObj.Obj = obj;
        tmpObj.Cmd = "To";
        tmpObj.Duration = Duration;
        tmpObj.CallbackObj = CallbackObj;
        tmpObj.CallbackMsg = (string) CallbackMsg;
        tmpObj.CallbackParams = CallbackParams;
        for (Count=0;Count<args.Length;Count=Count+2)
        {
            //Make sure we don't go pass the end of the array
            if ((Count+2) <= args.Length)
            {
                tmpProperty = args[Count];
                tmpValue = args[Count+1];
                tmpObj.Properties.Add(tmpProperty, tmpValue);
            }
        }

        //Add object to array
        mAnimate.Add(tmpObj);
    }
コード例 #4
0
ファイル: Drawingboard.xaml.cs プロジェクト: tingxin/Kiosk
        void CreateFlashAnimation(StrokeCollection strokes)
        {
            Rect  bound = strokes.GetBounds();
            Point from  = new Point(bound.Left + bound.Width / 2, bound.Top + bound.Height / 2);

            AnimationLibrary.Current.GetFlashAnimationSync(bound, (to) =>
            {
                AnimationObj obj = AnimationEngine.AddSeriesActionsAnimation(strokes, AnimationActionType.Translate, center, from, to);
                obj.Begin();
            });
        }
コード例 #5
0
ファイル: Drawingboard.xaml.cs プロジェクト: tingxin/Kiosk
        private void CreateBlinkAnimation(StrokeCollection strokes, AOrientation oritation)
        {
            Rect  bound = strokes.GetBounds();
            Point from  = new Point(1, 1);

            AnimationLibrary.Current.GetBlinkAnimationSync(bound, oritation, 2, 0.2, (to) =>
            {
                AnimationObj obj = AnimationEngine.AddSeriesActionsAnimation(strokes, AnimationActionType.Scale, center, from, to, true);
                obj.Begin();
            });
        }
コード例 #6
0
ファイル: Drawingboard.xaml.cs プロジェクト: tingxin/Kiosk
        private void CreateSwingAnimation(StrokeCollection strokes, Point centerOffset)
        {
            Rect  bound = strokes.GetBounds();
            Point from  = new Point(0, 0);

            AnimationLibrary.Current.GetSwingAnimationSync(bound, 1, 30, (to) =>
            {
                AnimationObj obj = AnimationEngine.AddSeriesActionsAnimation(strokes, AnimationActionType.Rotate, centerOffset, from, to, true);
                obj.Begin();
            });
        }
コード例 #7
0
ファイル: Drawingboard.xaml.cs プロジェクト: tingxin/Kiosk
        private void CreateShakeAnimation(StrokeCollection strokes, AOrientation oritation)
        {
            Rect  bound = strokes.GetBounds();
            Point from  = new Point(bound.Left + bound.Width / 2, bound.Top + bound.Height / 2);

            AnimationLibrary.Current.GetShakeAnimationSync(bound, oritation, 5, (to) =>
            {
                AnimationObj obj = AnimationEngine.AddSeriesActionsAnimation(strokes, AnimationActionType.Translate, center, from, to, true);
                obj.Begin();
            });
        }
コード例 #8
0
ファイル: Drawingboard.xaml.cs プロジェクト: tingxin/Kiosk
        AnimationObj CreateAnimationRomdom3(StrokeCollection strokes)
        {
            double x = 10;
            double y = 255;

            AnimationObj obj = AnimationEngine.AddPropertyAnimation(strokes, 5, 255, 0, (change) =>
            {
                byte r = (byte)change;
                foreach (Stroke stroke in strokes)
                {
                    stroke.DrawingAttributes.Color = Color.FromArgb(r, 255, 0, 0);
                }
            });

            return(obj);
        }
コード例 #9
0
    //Coroutine animator
    IEnumerator AnimateEngine()
    {
        int Index = 0;

        while ((mAnimate.Count > 0) && (mAnimating == true))
        {
            if (Index < mAnimate.Count)
            {
                AnimationObj item = (AnimationObj)mAnimate[Index];

                //Send animation command to AniMate
                switch (item.Cmd)
                {
                case "To":
                    yield return(Ani.Mate.To(item.Obj, item.Duration, item.Properties));

                    break;

                case "From":
                    yield return(Ani.Mate.From(item.Obj, item.Duration, item.Properties));

                    break;

                case "By":
                    yield return(Ani.Mate.By(item.Obj, item.Duration, item.Properties));

                    break;
                }

                //Send message to callback object
                if (item.CallbackObj != null)
                {
                    item.CallbackObj.SendMessage(item.CallbackMsg, item.CallbackParams, SendMessageOptions.DontRequireReceiver);
                }

                //Remove animation object if needed
                if (mAnimateMode == Ani.Animate.OneShot)
                {
                    //Check to see if list was emptied before attempting to remove item
                    if (mAnimate.Count > 0)
                    {
                        mAnimate.RemoveAt(Index);
                    }
                }
                else
                {
                    //Loop mode.  Just point to the next anim object
                    Index++;
                    if (Index >= mAnimate.Count)
                    {
                        Index = 0;
                    }
                }
            }
        }

        //Done animating
        mAnimating = false;

        //Send message to callback from Start Animation
        if ((mCallbackObj != null) && (mCallbackMsg != null))
        {
            mCallbackObj.SendMessage(mCallbackMsg, mCallbackParams, SendMessageOptions.DontRequireReceiver);
        }
    }
コード例 #10
0
ファイル: Drawingboard.xaml.cs プロジェクト: tingxin/Kiosk
        void GoAnimation(StrokeCollection strokes, ATowardto atoward)
        {
            Rect  bound       = strokes.GetBounds();
            Rect  screenBound = new Rect(0, 0, this.ActualWidth, this.ActualHeight);
            Point from        = new Point(bound.Left + bound.Width / 2, bound.Top + bound.Height / 2);

            AnimationLibrary.Current.GetGoAnimationSync(bound, screenBound, atoward, false, (position) =>
            {
                AnimationObj ani1 = AnimationEngine.AddDurationActionAnimation(strokes, AnimationActionType.Translate, center, (int)position[0].Duration, from, position[0].To);
                AnimationObj ani2 = AnimationEngine.AddDurationActionAnimation(strokes, AnimationActionType.Translate, center, (int)position[2].Duration, position[1].To, position[2].To);


                ani1.AnimationCompleted += (sender, ex) =>
                {
                    Matrix maritx  = new Matrix();
                    double tChange = 0;
                    switch (atoward)
                    {
                    case ATowardto.ToLeft:
                    case ATowardto.ToRight:
                        tChange = position[1].To.X - position[0].To.X;
                        maritx.Translate(tChange, 0);
                        break;

                    case ATowardto.ToTop:
                    case ATowardto.ToBottom:
                        tChange = position[1].To.Y - position[0].To.Y;
                        maritx.Translate(0, tChange);
                        break;

                    default:
                        break;
                    }

                    strokes.Transform(maritx, false);
                    ani2.Begin();
                };

                ani2.AnimationCompleted += (sender, ex) =>
                {
                    Matrix maritx  = new Matrix();
                    double tChange = 0;
                    switch (atoward)
                    {
                    case ATowardto.ToLeft:
                    case ATowardto.ToRight:
                        tChange = position[1].To.X - position[0].To.X;
                        maritx.Translate(tChange, 0);
                        break;

                    case ATowardto.ToTop:
                    case ATowardto.ToBottom:
                        tChange = position[1].To.Y - position[0].To.Y;
                        maritx.Translate(0, tChange);
                        break;

                    default:
                        break;
                    }

                    strokes.Transform(maritx, false);
                    ani2.Begin();
                };

                ani1.Begin();
            });
        }