Beispiel #1
0
    private IEnumerator InitGame(int gameIdx, ScenePayloadBase payload)
    {
        Debug.Log($"Initializing Game");

        _nextPayload = null;
        HideMenus();
        debugOverlay.SetGame(gameIdx, payload.ToString());

        var buildIdx = _manifest.GetGameSceneBuildIdx(gameIdx);

        SceneManager.LoadScene(buildIdx);
        yield return(null); // Wait frame for scene to load

        var sceneRootGOs = SceneManager
                           .GetActiveScene()
                           .GetRootGameObjects();

        // Assume single levelManager in scene, without a parent
        var levelManager = sceneRootGOs
                           .Select(go => go.GetComponent <LevelManagerBase>())
                           .Single(x => x != null);

        levelManager.OnEnd += OnLevelEnd;
        levelManager.Init(payload);
    }
Beispiel #2
0
    private void OnLevelEnd(object sender, ScenePayloadBase payload)
    {
        var levelManager = (LevelManagerBase)sender;

        Debug.Log($"Level ended! ({levelManager.name})");
        levelManager.OnEnd -= OnLevelEnd;
        _nextPayload        = payload;
        gameCompletedMenu.gameObject.SetActive(true);
    }
Beispiel #3
0
    private void LoadNextGame(ScenePayloadBase payload)
    {
        _currPayload = payload;
        _gameIdx++;
        if (_manifest.Games.Length <= _gameIdx)
        {
            Debug.LogError("No more games found! Ending game series");
            StartCoroutine(EndSeries());
            return;
        }

        StartCoroutine(InitGame(_gameIdx, payload));
    }
Beispiel #4
0
    public override void Init(ScenePayloadBase payload)
    {
        var castedPayload = (TInput)payload;

        InitInternal(castedPayload);
    }
Beispiel #5
0
 protected void InvokeEndEvent(ScenePayloadBase payload) => OnEnd?.Invoke(this, payload);
Beispiel #6
0
 public abstract void Init(ScenePayloadBase payload);
Beispiel #7
0
 private void OnRestartSequenceClicked()
 {
     _gameIdx     = 0;
     _nextPayload = new StartPayload();
     StartCoroutine(InitGame(_gameIdx, _nextPayload));
 }