Example #1
0
        private void RiseExperienceBarCurrentLevel()
        {
            _experienceBar.value = Mathf.Lerp(
                (float)_currentExperienceViewModel.CurrentExperience / _currentExperienceViewModel.NextLevelRequirement,
                (float)_newExperienceViewModel.CurrentExperience / _newExperienceViewModel.NextLevelRequirement,
                _acumulatedTime);

            if (HasReachedDesiredValue())
            {
                _currentExperienceViewModel = _newExperienceViewModel;
                _fillBarMethod = FillBarMethod.None;
            }
        }
Example #2
0
 public void FillExperienceBar(ExperienceViewModel newExperienceViewModel)
 {
     _acumulatedTime         = 0;
     _newExperienceViewModel = newExperienceViewModel;
     if (!HasGainedALevel(newExperienceViewModel))
     {
         _fillBarMethod = FillBarMethod.RiseCurrentLevel;
     }
     else
     {
         _fillBarMethod = FillBarMethod.CompleteCurrentLevel;
     }
 }
Example #3
0
 private void RiseExperienceBarToCompleteCurrentLevel()
 {
     _experienceBar.value = Mathf.Lerp(
         (float)_currentExperienceViewModel.CurrentExperience / _currentExperienceViewModel.NextLevelRequirement,
         1,
         _acumulatedTime * 2);
     if (HasReachedMaxValue())
     {
         _level.IncreaseLevel();
         _acumulatedTime             = 0;
         _currentExperienceViewModel = new ExperienceViewModel(0,
                                                               _newExperienceViewModel.NextLevelRequirement, _newExperienceViewModel.CurrentLevel,
                                                               _newExperienceViewModel.EnemiesUnlocked);
         _fillBarMethod = FillBarMethod.RiseCurrentLevel;
     }
 }
Example #4
0
 private bool HasGainedALevel(ExperienceViewModel newExperienceViewModel)
 {
     return(_currentExperienceViewModel.CurrentLevel < newExperienceViewModel.CurrentLevel);
 }
Example #5
0
 public void UpdateExperienceBar(ExperienceViewModel experienceViewModel)
 {
     _level.Setlevel(experienceViewModel.CurrentLevel);
     _experienceBar.value        = (float)experienceViewModel.CurrentExperience / experienceViewModel.NextLevelRequirement;
     _currentExperienceViewModel = experienceViewModel;
 }