//====== override: GameObject

        protected override void UpdateImpl()
        {
            int currentScore = scoreStatus.Value;

            if (displayedScore == currentScore)
            {
                return;
            }

            if (toScore != currentScore)
            {
                fromScore = displayedScore;
                toScore   = currentScore;

                delay = new GameTimeDelay(gameTime, TimeSpan.FromSeconds(TransitionDurationInSecs));
            }

            if (delay == null)
            {
                return;                // TODO: Range.Map utility could be nice
            }
            int    maxScoreToAdd = toScore - fromScore;
            double scoreToAdd    = maxScoreToAdd * (delay.PercentageDone / 100d);

            displayedScore = fromScore + MiscUtils.Clamp((int)scoreToAdd, 0, maxScoreToAdd);
        }
Пример #2
0
 public void Update()
 {
     if (gtd?.IsDone ?? false)
     {
         frameIndex = ++frameIndex % frames.Frames.Count;
         gtd        = gtd.ReCreate();
     }
 }
Пример #3
0
        //====== public methods

        public void Start()
        {
            if (gtd is not null)
            {
                throw new InvalidOperationException("Animation already started.");
            }

            gtd = gameTime.CreateDelay(frameDelay);
        }