示例#1
0
 public void AddRemainScore()
 {
     if (remainScore > 0)
     {
         if (OnAddScore != null)
         {
             OnAddScore.Invoke(remainScore);
         }
         remainScore = 0;
     }
     ResetRemainTime();
 }
示例#2
0
        public void Update(TimeSpan currentTime)
        {
            if (score == 0)
            {
                return;
            }
            if (remainScore < 0)
            {
                score = 0;
                return;
            }
            long newUpdateTime = currentTime.Ticks - startTime;
            bool exceed        = newUpdateTime > duration;

            if (exceed)
            {
                newUpdateTime = duration;
            }
            int addScore = Mathf.FloorToInt((float)score * (newUpdateTime - previousUpdatetime) / duration);

            if (addScore > 0)
            {
                remainScore -= addScore;
                if (remainScore < 0)
                {
                    addScore += remainScore;
                }
                if (OnAddScore != null)
                {
                    OnAddScore.Invoke(addScore);
                }
                previousUpdatetime = newUpdateTime;
            }
            if (exceed)
            {
                score = 0;
            }
        }