private void Start() { _currentLevel = _levels[_currentLevelIndex]; LoadWave(); OnLevelChange?.Invoke(GetLevel()); }
private void LoadLevel() { var loadSceneAsync = SceneManager.LoadSceneAsync(Currentlevel.index, LoadSceneMode.Additive); loadSceneAsync.completed += operation => { SetUpPlayer(); LevelTransition.Instance.FadeOut(); OnLevelChange?.Invoke(Currentlevel); }; }
private void CheckForLevelUp() { if (IsAtMaxLevel) { return; } while (experience > TotalExperienceForNextLevel) { experience -= TotalExperienceForNextLevel; level++; OnLevelChange.Invoke(this, level); OnLevelUp.Invoke(this, level); } }
public void ModifyLevel(int levelDifference, bool resetExperience = true) { if (levelDifference != 0) { int oldLevel = this.level; level = Mathf.Clamp(level + levelDifference, 1, MaxLevel); if (resetExperience) { experience = 0f; } OnLevelChange.Invoke(this, level); if (oldLevel < level) { OnLevelUp.Invoke(this, level); } } }
public void SetLevel(int level, bool resetExperience = true) { if (this.level != level) { int oldLevel = this.level; this.level = Mathf.Clamp(level, 1, MaxLevel); if (resetExperience) { experience = 0f; } OnLevelChange.Invoke(this, level); if (oldLevel < level) { OnLevelUp.Invoke(this, level); } } }
private IEnumerator LoadNewLevel() { // Disable previous wave coroutine StopCoroutine(_coroutine); _currentLevelIndex++; // Check if there is another level, if so, load it, otherwise finish the game if (IsGameFinished()) { OnPlayerWin?.Invoke(); yield return(null); } else { OnLevelChange?.Invoke(GetLevel()); PrepareForNewLevel(); // Add delay only between levels yield return(new WaitForSeconds(_delayBetweenLevels)); LoadWave(); } }
protected virtual void _onLevelUp() { OnLevelChange?.Invoke(this, EventArgs.Empty); }
private void InvokeOnLevelChange() { OnLevelChange.Invoke(SavePlayer.Level); }
/// <summary> Invoke actions that listen to a change in level. </summary> public void LevelChanged() { OnLevelChange?.Invoke(pokemon); }