コード例 #1
0
        public SimpleAnimator_Float(float start, float end, float duration, AnimationUpdate updateDelegate, AnimationComplete completeDelegate)
        {
            StartValue = start;
            EndValue   = end;

            Init(duration, updateDelegate, completeDelegate);
        }
コード例 #2
0
        protected void Init(float durationSeconds, AnimationUpdate updateDelegate, AnimationComplete completeDelegate)
        {
            // create our timer at 60hz
            AnimTimer = NSTimer.CreateRepeatingTimer(new TimeSpan(ANIMATION_TICK_FREQUENCY), new Action <NSTimer>(
                                                         delegate
            {
                // update our timer
                CurrentTime += ANIMATION_TICK_RATE;

                float percent = 0.00f;

                // check the style of animation they want
                switch (AnimStyle)
                {
                // linear is, well, linear.
                case Style.Linear:
                    {
                        percent = CurrentTime / durationSeconds;
                        break;
                    }


                // curve ease in starts SLOW and ends FAST
                case Style.CurveEaseIn:
                    {
                        float xPerc = CurrentTime / durationSeconds;
                        percent     = (float)System.Math.Pow(xPerc, 3.0f);
                        break;
                    }

                // curve ease out starts FAST and ends SLOW
                case Style.CurveEaseOut:
                    {
                        float xPerc = CurrentTime / durationSeconds;
                        percent     = (float)1 + (float)System.Math.Pow((xPerc - 1), 3.0f);
                        break;
                    }
                }

                // let the animation implementation do what it needs to
                AnimTick(System.Math.Min(percent, 1.00f), updateDelegate);

                // see if we're finished.
                if (CurrentTime >= durationSeconds)
                {
                    // we are, so notify the completion delegate
                    if (completeDelegate != null)
                    {
                        completeDelegate( );
                    }

                    // and kill the timer
                    AnimTimer.Invalidate( );
                }
            })
                                                     );
        }
コード例 #3
0
ファイル: Page.cs プロジェクト: frederictaillandier/NewFredUI
 void ActiveAnimation()
 {
     this.transform.localScale = Vector3.Lerp(this.transform.localScale, Vector3.one, Time.deltaTime * 16);
     if (this.transform.localScale.magnitude > Vector3.one.magnitude * 0.9f)
     {
         this.transform.localScale = Vector3.one;
         _animationUpdate          = null;
     }
 }
コード例 #4
0
        protected override void AnimTick(float percent, AnimationUpdate updateDelegate)
        {
            float value = StartValue + ((EndValue - StartValue) * percent);

            if (updateDelegate != null)
            {
                updateDelegate(percent, value);
            }
        }
コード例 #5
0
 protected override void AnimTick(float percent, AnimationUpdate updateDelegate)
 {
     // get the current value and provide it to the caller
     System.Drawing.SizeF value = new System.Drawing.SizeF(StartValue.Width + (Delta.Width * percent), StartValue.Height + (Delta.Height * percent));
     if (updateDelegate != null)
     {
         updateDelegate(percent, value);
     }
 }
コード例 #6
0
 protected override void AnimTick(float percent, AnimationUpdate updateDelegate)
 {
     // get the current value and provide it to the caller
     System.Drawing.PointF value = new System.Drawing.PointF(StartValue.X + (Delta.X * percent), StartValue.Y + (Delta.Y * percent));
     if (updateDelegate != null)
     {
         updateDelegate(percent, value);
     }
 }
コード例 #7
0
ファイル: Page.cs プロジェクト: frederictaillandier/NewFredUI
 void DeActiveAnimation()
 {
     this.transform.localScale = Vector3.Lerp(this.transform.localScale, Vector3.zero, Time.deltaTime * 16);
     if (this.transform.localScale.magnitude < 0.1f)
     {
         this.transform.localScale = Vector3.zero;
         _animationUpdate          = null;
         this.gameObject.SetActive(false);
     }
 }
コード例 #8
0
        protected void Init(float duration, AnimationUpdate updateDelegate, AnimationComplete completeDelegate)
        {
            Animator = ValueAnimator.OfFloat(0.00f, 1.00f);

            Animator.AddUpdateListener(this);
            Animator.AddListener(this);

            // convert duration to milliseconds
            Animator.SetDuration((int)(duration * 1000.0f));

            AnimationUpdateDelegate   = updateDelegate;
            AnimationCompleteDelegate = completeDelegate;
        }
コード例 #9
0
ファイル: Tweener.cs プロジェクト: k-may/LightTween
 public ColorTweenData(object o, Color startColor, Color endColor, int duration, AnimationComplete completeHandler, AnimationUpdate updateHandler)
 {
     this._object = o;
     this._prop = _object.GetType().GetProperty("color");
     _property_name = "color";
     _startColor = startColor;
     _endColor = endColor;
     _startVal = 0;
     _endVal = 1;
     _duration = duration;
     _tweenFunc = Tweener.GetFunction(TransitionType.LINEAR);
     Complete += completeHandler;
     Update += updateHandler;
 }
コード例 #10
0
        protected override void AnimTick(float percent, AnimationUpdate updateDelegate)
        {
            // cast to int so we don't lose the sign when adding a negative delta
            uint currR = (uint)((int)StartR + (int)((float)DeltaR * percent));
            uint currG = (uint)((int)StartG + (int)((float)DeltaG * percent));
            uint currB = (uint)((int)StartB + (int)((float)DeltaB * percent));
            uint currA = (uint)((int)StartA + (int)((float)DeltaA * percent));

            uint currValue = currR << 24 | currG << 16 | currB << 8 | currA;

            if (updateDelegate != null)
            {
                updateDelegate(percent, currValue);
            }
        }
コード例 #11
0
        private void OnAnimationUpdate(AnimationUpdate message, Action onCompleteCallback)
        {
            if (Animations.TryGetValue(message.Animation.Id, out BaseAnimation anim))
            {
                anim.ApplyPatch(message.Animation);
            }
            else if (PendingPatches.TryGetValue(message.Animation.Id, out AnimationPatch oldPatch))
            {
                // merge patches
                oldPatch.Merge(message.Animation);
            }
            else
            {
                // just write pending patch
                PendingPatches[message.Animation.Id] = message.Animation;
            }

            onCompleteCallback?.Invoke();
        }
コード例 #12
0
        public SimpleAnimator_Color(uint start, uint end, float duration, AnimationUpdate updateDelegate, AnimationComplete completionDelegate)
        {
            Init(duration, updateDelegate, completionDelegate);

            StartR = (start & 0xFF000000) >> 24;
            StartG = (start & 0x00FF0000) >> 16;
            StartB = (start & 0x0000FF00) >> 8;
            StartA = (start & 0xFF);

            uint endR = (end & 0xFF000000) >> 24;
            uint endG = (end & 0x00FF0000) >> 16;
            uint endB = (end & 0x0000FF00) >> 8;;
            uint endA = (end & 0xFF);

            DeltaR = (int)(endR - StartR);
            DeltaG = (int)(endG - StartG);
            DeltaB = (int)(endB - StartB);
            DeltaA = (int)(endA - StartA);
        }
コード例 #13
0
ファイル: Page.cs プロジェクト: frederictaillandier/NewFredUI
    public virtual void SetSelection(bool selected)
    {
        if (selected)
        {
            Invoke("Open", 0.2f);
        }
        else
        {
            _animationUpdate = DeActiveAnimation;
        }

        for (int i = 0; i < ModelToShow.Length; ++i)
        {
            if (ModelToShow[i] != null)
            {
                ModelToShow[i].gameObject.SetActive(selected);
            }
            else
            {
                Debug.LogError("ModelMissing");
            }
        }
    }
コード例 #14
0
 protected abstract void AnimTick(float percent, AnimationUpdate updateDelegate);
コード例 #15
0
        public SimpleAnimator_PointF(System.Drawing.PointF start, System.Drawing.PointF end, float duration, AnimationUpdate updateDelegate, AnimationComplete completeDelegate)
        {
            StartValue = start;
            Delta      = new System.Drawing.PointF(end.X - start.X, end.Y - start.Y);

            Init(duration, updateDelegate, completeDelegate);
        }
コード例 #16
0
ファイル: Page.cs プロジェクト: frederictaillandier/NewFredUI
 public void Open()
 {
     _animationUpdate = ActiveAnimation;
     this.gameObject.SetActive(true);
 }
コード例 #17
0
        public SimpleAnimator_RectF(System.Drawing.RectangleF start, System.Drawing.RectangleF end, float duration, AnimationUpdate updateDelegate, AnimationComplete completeDelegate)
        {
            StartValue = start;
            Delta      = new System.Drawing.RectangleF(end.X - start.X, end.Y - start.Y, end.Width - start.Width, end.Height - start.Height);

            Init(duration, updateDelegate, completeDelegate);
        }
コード例 #18
0
ファイル: Tweener.cs プロジェクト: k-may/LightTween
 public void addTween(object o, string property_name, float startVal, float endVal, int duration, TransitionType transitionType, AnimationComplete _completeHandler = null, AnimationUpdate _updateHandler = null)
 {
     TweenData tween = new TweenData(o, property_name, startVal, endVal, duration, transitionType, _completeHandler, _updateHandler);
     this.addTween(tween);
 }
コード例 #19
0
ファイル: Tweener.cs プロジェクト: k-may/LightTween
        public TweenData(AnimationComplete completeHandler = null, AnimationUpdate updateHandler = null)
        {
            if (completeHandler != null)
                Complete += completeHandler;

            if (updateHandler != null)
                Update += updateHandler;
        }
コード例 #20
0
ファイル: Tweener.cs プロジェクト: k-may/LightTween
 public TweenData(object o, string property_name, float startVal, float endVal, int duration, TransitionType transitionType, AnimationComplete _completeHandler, AnimationUpdate _updateHandler)
     : this(o, property_name, startVal, endVal, duration, transitionType)
 {
     Complete += _completeHandler;
     Update += _updateHandler;
 }