Beispiel #1
0
        /// <summary>
        /// Updates the animation. Not the part of entity loop,
        /// you need to call it on your own.
        ///
        /// NOTE: If using in Draw method, keep in mind that each camera calls the event separately.
        /// You may want to restrict it only to the first camera.
        /// </summary>
        public void Update()
        {
            if (!Running)
            {
                return;
            }

            if (TimeKeeper == null)
            {
                LinearProgress += TimeKeeper.GlobalTime(Math.Abs(Speed));
            }
            else
            {
                LinearProgress += TimeKeeper.Time(Math.Abs(Speed));
            }

            if (LinearProgress > 1)
            {
                if (!Looping)
                {
                    Running        = false;
                    LinearProgress = 1;
                }
                else
                {
                    LinearProgress -= (int)LinearProgress;
                }

                AnimationEndEvent?.Invoke(this);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Updates alarm. Returns true, if alarm is being triggered.
        /// </summary>
        public new virtual bool Update()
        {
            if (Enabled && Counter > 0)
            {
                Counter -= TimeKeeper.Time();

                if (Counter <= 0)
                {
                    TriggerEvent?.Invoke(this);
                    return(true);
                }
            }

            return(false);
        }