private void Start()
    {
        Init();

        StartCoroutine(LevelUpdate());
        OnLevelStart?.Invoke();
    }
    // Start is called before the first frame update
    void Start()
    {
        cakesRemaining = startNumberOfCakes;
        cakesPacked    = 0;

        OnLevelStart?.Invoke(this, EventArgs.Empty);
    }
Exemple #3
0
 static void QuickTest()
 {
     OnFlowStart?.Invoke();
     UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync(0);
     StartCoroutine(QuickTestCoroutine());
     OnLevelStart?.Invoke();
 }
 private static void LevelStart()
 {
     IntroLevelCanvasController.Instance.Hide();
     LevelCompleteCanvasController.Instance.Hide();
     LevelFailController.Instance.Hide();
     InLevelCanvasController.Instance.Show();
     OnLevelStart?.Invoke();
 }
Exemple #5
0
    private void StartCurrentLevel()
    {
        currentLevel.gameObject.SetActive(true);
        nextLevel.gameObject.SetActive(false);

        currentLevel.transform.position = bottomOfScreen.position;
        nextLevel.transform.position    = topOfScreen.position;

        currentLevel.StartBarsMoving(barData);
        OnLevelStart?.Invoke(); //TODO: Refracter uses; switch to EventManager
        EventManager.TriggerEvent(EventNames.LevelStarted);
    }
    private IEnumerator StartMainLoopCoroutine()
    {
        _lost = false;
        yield return(new WaitForSeconds(1.5f));

        OnPrepareNewLevel?.Invoke();
        yield return(new WaitForSeconds(1.5f));

        PlayCountdownAudio();
        yield return(new WaitForSeconds(3.5f));

        _startTime = Time.time;
        OnLevelStart?.Invoke();
    }
Exemple #7
0
    public void ChangeState(gameState gameState)
    {
        GameState = gameState;
        switch (GameState)
        {
        case gameState.LevelStart:
        {
            OnLevelStart?.Invoke();
        }
        break;

        case gameState.LevelAccomplish:
        {
            OnLevelAccomplish?.Invoke();
        }
        break;
        }
    }
        public void GenerateLevelEvents(GameTime gameTime)
        {
            // only generate events every 2 seconds
            if (_startGameTime == null)
            {
                _startGameTime = gameTime.TotalGameTime;
            }

            // nothing to do until tick time
            if (gameTime.TotalGameTime - _startGameTime < TickTimeSpan)
            {
                return;
            }

            _startGameTime = gameTime.TotalGameTime;

            foreach (var e in _currentLevel[_currentLevelRow])
            {
                switch (e)
                {
                case LevelEvents.GenerateEnemies g:
                    OnGenerateEnemies?.Invoke(this, g);
                    break;

                case LevelEvents.GenerateTurret g:
                    OnGenerateTurret?.Invoke(this, g);
                    break;

                case LevelEvents.StartLevel s:
                    OnLevelStart?.Invoke(this, s);
                    break;

                case LevelEvents.EndLevel s:
                    OnLevelEnd?.Invoke(this, s);
                    break;

                case LevelEvents.NoRowEvent n:
                    OnLevelNoRowEvent?.Invoke(this, n);
                    break;
                }
            }

            _currentLevelRow++;
        }
Exemple #9
0
    private static void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
    {
        // When a scene loads, store the levels build index in 'LevelIndex'.
        if (LevelIndex != arg0.buildIndex)
        {
            LevelIndex = arg0.buildIndex;
        }

        // When a scene loads and the scene is not the Main Menu, handle certain elements.
        if (arg0.name != LevelInformation.Levels[0].name)
        {
            StarsAcquired = 0;
            GemsAcquired  = 0;

            if (!hpOn)
            {
                hpOn = !hpOn;
            }

            OnLevelStart?.Invoke();

            #region WHEN SCENE STARTS, CLEAR LIST OF COLLECTIBLES AND FIND ALL NEW ONES IN CURRENT SCENE LOADED
            // On Scene Loaded, the new level gold has not yet been acquired.
            for (int i = 0; i < StarConditions.Length; i++)
            {
                if (StarConditions[i])
                {
                    StarConditions[i] = false;
                }
            }

            // Clear all gems in array from previous level played (if any)
            if (GemsInCurrentLevel.Count > 0)
            {
                GemsInCurrentLevel.Clear();
            }

            // Gather list of all GEMS in the current loaded scene.
            Collectible[] collectibles = UnityEngine.Object.FindObjectsOfType <Collectible>();

            if (collectibles.Length > 1)
            {
                foreach (Collectible collectible in collectibles)
                {
                    if (collectible.Type == Collectible.CollectibleType.GEM)
                    {
                        if (!GemsInCurrentLevel.Contains(collectible))
                        {
                            //Debug.Log(collectible);
                            GemsInCurrentLevel.Add(collectible);
                        }
                    }
                }
            }
            #endregion
        }
        else
        {
            // When the game starts, find Audio Sources.
            if (MM_UI.MMUI != null)
            {
                SoundManager.SetAudioSources(MM_UI.MMUI.SFXSoundSource, MM_UI.MMUI.MusicSoundSource);
            }

            if (hpOn)
            {
                hpOn = !hpOn;
            }
        }

        OnToggleHP?.Invoke(hpOn);

        // Play level music accordingly
        HandleAudioSources(SoundManager.MusicSource, SoundManager.SFXSource);
    }
Exemple #10
0
 /// <summary>
 /// StartLevel calls the OnLevelStart event.
 /// </summary>
 /// <param name="level">The level index of a level that needs to be started.</param>
 public static void StartLevel(int level)
 {
     OnLevelStart?.Invoke(level);
 }
Exemple #11
0
 private void StartLevel()
 {
     levelText.enabled = false;
     OnLevelStart?.Invoke();
 }
Exemple #12
0
 public void LevelStart()
 {
     OnLevelStart?.Invoke();
 }