//====== 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);
        }