Esempio n. 1
0
    private void Start()
    {
        _currentLevel = _levels[_currentLevelIndex];
        LoadWave();

        OnLevelChange?.Invoke(GetLevel());
    }
Esempio n. 2
0
        private void LoadLevel()
        {
            var loadSceneAsync = SceneManager.LoadSceneAsync(Currentlevel.index, LoadSceneMode.Additive);

            loadSceneAsync.completed += operation =>
            {
                SetUpPlayer();
                LevelTransition.Instance.FadeOut();
                OnLevelChange?.Invoke(Currentlevel);
            };
        }
Esempio n. 3
0
            private void CheckForLevelUp()
            {
                if (IsAtMaxLevel)
                {
                    return;
                }

                while (experience > TotalExperienceForNextLevel)
                {
                    experience -= TotalExperienceForNextLevel;
                    level++;
                    OnLevelChange.Invoke(this, level);
                    OnLevelUp.Invoke(this, level);
                }
            }
Esempio n. 4
0
            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);
                    }
                }
            }
Esempio n. 5
0
            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);
                    }
                }
            }
Esempio n. 6
0
    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();
        }
    }
Esempio n. 7
0
 protected virtual void _onLevelUp()
 {
     OnLevelChange?.Invoke(this, EventArgs.Empty);
 }
Esempio n. 8
0
 private void InvokeOnLevelChange()
 {
     OnLevelChange.Invoke(SavePlayer.Level);
 }
 /// <summary> Invoke actions that listen to a change in level.  </summary>
 public void LevelChanged()
 {
     OnLevelChange?.Invoke(pokemon);
 }