Beispiel #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;
            }
        }
Beispiel #2
0
 public void FillExperienceBar(ExperienceViewModel newExperienceViewModel)
 {
     _acumulatedTime         = 0;
     _newExperienceViewModel = newExperienceViewModel;
     if (!HasGainedALevel(newExperienceViewModel))
     {
         _fillBarMethod = FillBarMethod.RiseCurrentLevel;
     }
     else
     {
         _fillBarMethod = FillBarMethod.CompleteCurrentLevel;
     }
 }
Beispiel #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;
     }
 }
Beispiel #4
0
 private bool HasGainedALevel(ExperienceViewModel newExperienceViewModel)
 {
     return(_currentExperienceViewModel.CurrentLevel < newExperienceViewModel.CurrentLevel);
 }
Beispiel #5
0
 public void UpdateExperienceBar(ExperienceViewModel experienceViewModel)
 {
     _level.Setlevel(experienceViewModel.CurrentLevel);
     _experienceBar.value        = (float)experienceViewModel.CurrentExperience / experienceViewModel.NextLevelRequirement;
     _currentExperienceViewModel = experienceViewModel;
 }