public GameInterfaceSystem(StageSystem stageSystem, GameInteractionsSystem interactionsSystem)
    {
        this.stageSystem = stageSystem;

        interactionsSystem.onFinishTriggered += NoticeFinishTriggered;
        stageSystem.onFinishCurrentSubstage  += () => finishAction?.Invoke();
    }
示例#2
0
    private static void AfterSceneLoad()
    {
        // Initialize basic game systems.
        var userInterfaceSystem = new UserInterfaceSystem();
        var controlSystem       = new ControlSystem(resourcesData.gameplaySettings);
        var keysSystem          = new KeysSystem(resourcesData.stagePrefabs);
        var stageSystem         = new StageSystem(resourcesData.stagePrefabs, keysSystem);
        var ballSystem          = new BallSystem(resourcesData.ballPrefabs, stageSystem);
        var gameCurrencySystem  = new GameCurrencySystem(userInterfaceSystem);
        var monetizationSystem  = new MonetizationSystem(resourcesData.monetizationSettings, gameCurrencySystem);
        var shopSystem          = new ShopSystem(resourcesData.shopModel, ballSystem, gameCurrencySystem, monetizationSystem);

        // Initialize gameplay systems.
        var gameInteractionsSystem = new GameInteractionsSystem(ballSystem, keysSystem, stageSystem);
        var gameInterfaceSystem    = new GameInterfaceSystem(stageSystem, gameInteractionsSystem);

        // Register a proxy service for gameplay systems.
        var gameplaySystemsProxy = new GameplaySystemsProxy();

        gameplaySystemsProxy.Add(
            gameInteractionsSystem,
            gameInterfaceSystem);

        // Initialize the state machine system with all dependencies.
        var gameStateMachine = new GameStateMachine(
            gameplaySystemsProxy,
            userInterfaceSystem,
            controlSystem,
            stageSystem,
            ballSystem,
            keysSystem,
            gameCurrencySystem,
            monetizationSystem);

        // Preserve links to game services.
        var storage = new GameObject("[Game Services]").AddComponent <GameServices>();

        storage.Add(
            userInterfaceSystem,
            controlSystem,
            keysSystem,
            stageSystem,
            ballSystem,
            gameCurrencySystem,
            monetizationSystem,
            shopSystem);
        storage.Add(
            gameplaySystemsProxy,
            gameStateMachine);

        // Free the static reference to resources data - it's held by services from now.
        resourcesData = null;

        // Since there is only one scene in the project, we just link this very bootstrap script to the event of reloading scene.
        SceneManager.sceneLoaded += RebootOnNextSceneLoaded;
    }