Ejemplo n.º 1
0
 public virtual void PlayProgressAnimation(OnAnimationComplete onAnimComplete = null)
 {
     if (onAnimComplete != null)
     {
         onAnimComplete();
     }
 }
Ejemplo n.º 2
0
    void Update()
    {
        float t = 0;

        if (animating)
        {
            animationProgress += Time.deltaTime;
            t = animationProgress;
        }

        rotationOffset += SpeedAnim.Evaluate(t) * Time.deltaTime;
        float radius = RadiusAnim.Evaluate(t);
        float scale  = SizeAnim.Evaluate(t);

        for (int i = 0; i < transforms.Count; i++)
        {
            float theta = Mathf.PI * 2 / transforms.Count * i + rotationOffset;
            transforms[i].localScale = new Vector2(scale, scale);

            Vector2 targetPosition = new Vector2(Mathf.Cos(theta) * radius, Mathf.Sin(theta) * radius);
            transforms[i].localPosition = Vector2.Lerp(transforms[i].localPosition, targetPosition, 1 - Mathf.Exp(-MovementSharpness * Time.deltaTime));
        }

        if (animating && animationProgress >= AnimationLength)
        {
            OnAnimationComplete?.Invoke();
            animating         = false;
            animationProgress = 0;
        }
    }
Ejemplo n.º 3
0
        public void Update(GameTime gameTime)
        {
            if (State != AnimationState.Playing)
            {
                return;
            }

            CurrentTime += (float)gameTime.ElapsedGameTime.TotalSeconds;

            int frameTime       = (int)(CurrentTime * CurrentAnimation.FPS);
            int animationLenght = CurrentAnimation.Frames.Length;

            if (frameTime >= animationLenght)
            {
                var animation = CurrentAnimation;
                if (CurrentAnimation.IsLooping)
                {
                    CurrentTime %= (animationLenght / animation.FPS);
                    FrameIndex   = animation.Frames[(int)(CurrentTime * animation.FPS)];
                }
                else
                {
                    FrameIndex = animation.Frames[animationLenght - 1];
                    Stop();
                    OnAnimationComplete?.Invoke(this, new AnimationEventArgs(animation, CurrentTime));
                }
            }
            else
            {
                FrameIndex = CurrentAnimation.Frames[frameTime];
            }
        }
Ejemplo n.º 4
0
 public void Update(GameTime gameTime)
 {
     if (Frames.Count == 0)
     {
         return;
     }
     _currentElapsedTime += gameTime.ElapsedGameTime.Milliseconds;
     if (_currentElapsedTime >= Frames[_currentFrame].Duration)
     {
         _currentElapsedTime = 0;
         var nextFrame = _currentFrame + 1;
         if (nextFrame >= Frames.Count)
         {
             if (Looping)
             {
                 _currentFrame = 0;
             }
             else
             {
                 if (!CompleteAnimation)
                 {
                     // stay stuck on last frame
                     CompleteAnimation = true;
                     OnAnimationComplete?.Invoke(this);
                 }
             }
         }
         else
         {
             _currentFrame = nextFrame;
         }
     }
 }
Ejemplo n.º 5
0
 private void CompleteAnimationEvent(OnAnimationComplete animationCompleteEvent)
 {
     if (animationCompleteEvent != null)
     {
         animationCompleteEvent();
     }
     _animationSequence = null;
 }
 public void Clear()
 {
     LuaOnInit              = null;
     LuaOnFree              = null;
     LuaOnUpdate            = null;
     LuaOnEnter             = null;
     LuaOnExit              = null;
     LuaPause               = null;
     LuaOnResume            = null;
     LuaOnAnimationStart    = null;
     LuaOnAnimationComplete = null;
     LuaOnEventTrigger      = null;
     LuaOnColliderTrigger   = null;
 }
 public void Bind(string luaName)
 {
     LuaOnInit              = GameMode.XLua.GetInPath <OnInit>($"{luaName}.OnInit");
     LuaOnFree              = GameMode.XLua.GetInPath <OnFree>($"{luaName}.OnFree");
     LuaOnUpdate            = GameMode.XLua.GetInPath <OnUpdate>($"{luaName}.OnUpdate");
     LuaOnEnter             = GameMode.XLua.GetInPath <OnEnter>($"{luaName}.OnEnter");
     LuaOnExit              = GameMode.XLua.GetInPath <OnExit>($"{luaName}.OnExit");
     LuaPause               = GameMode.XLua.GetInPath <OnPause>($"{luaName}.OnPause");
     LuaOnResume            = GameMode.XLua.GetInPath <OnResume>($"{luaName}.OnResume");
     LuaOnAnimationStart    = GameMode.XLua.GetInPath <OnAnimationStart>($"{luaName}.OnAnimationStart");
     LuaOnAnimationComplete = GameMode.XLua.GetInPath <OnAnimationComplete>($"{luaName}.OnAnimationComplete");
     LuaOnEventTrigger      = GameMode.XLua.GetInPath <OnEventTrigger>($"{luaName}.OnEventTrigger");
     LuaOnColliderTrigger   = GameMode.XLua.GetInPath <OnColliderTrigger>($"{luaName}.OnColliderTrigger");
 }
Ejemplo n.º 8
0
        public void NextFrame()
        {
            if (animationDirection != 0)
            {
                animationcount++;
                if (animationcount >= animationSpeed)
                {
                    if (animationDirection > 0)
                    {
                        if (currentFrame >= stopFrame)
                        {
                            if (animateOnce)
                            {
                                currentFrame = stopFrame;
                                OnAnimationComplete?.Invoke(id);
                            }
                            else
                            {
                                currentFrame = startFrame;
                            }
                        }
                        else
                        {
                            currentFrame++;
                        }
                    }

                    if (animationDirection < 0)
                    {
                        if (currentFrame <= startFrame)
                        {
                            if (animateOnce)
                            {
                                currentFrame = startFrame;
                                OnAnimationComplete?.Invoke(id);
                            }
                            else
                            {
                                currentFrame = stopFrame;
                            }
                        }
                        else
                        {
                            currentFrame--;
                        }
                    }

                    animationcount = 0;
                }
            }

            if (movementEnabled)
            {
                movementcount++;
                if (movementcount >= movementSpeed)
                {
                    SetPosition(Convert.ToInt32(xPos + movementDistance * Math.Cos(radianAngle)), Convert.ToInt32(yPos + movementDistance * Math.Sin(radianAngle)));
                    movementcount = 0;
                }
            }
        }
 protected void DoHideAnimation(bool disableAnimation, OnAnimationComplete animationDoneCallback = null)
 {
 protected void DoHideAnimation(OnAnimationComplete animationDoneCallback = null)
 {
     this.DoHideAnimation(false, animationDoneCallback);
 }
Ejemplo n.º 11
0
 internal void OnComplete()
 {
     OnAnimationComplete?.Invoke(this, new EventArgs());
 }
Ejemplo n.º 12
0
 protected override void OnComplete(object sender, EventArgs e)
 {
     OnAnimationComplete?.Invoke();
     base.OnComplete(sender, e);
 }