Пример #1
0
    public override void OnGameStart()
    {
        base.OnGameStart();

        PresentationHelpers.PresentationWorld.GetExistingSystem <TickSimulationSystem>().PauseSimulation(LEVEL_NOT_STARTED);

        SyncedValues.RegisterValueListener <SyncedValueCurrentLevel>(OnLevelSet, callImmediatelyIfValueExits: true);

        string levelToPlay = null;

        if (SyncedValues.CanWriteValues)
        {
            switch (GameStateManager.currentGameState)
            {
            case GameStateInGameServer serverGameState:
                levelToPlay = serverGameState.LevelToPlay;
                break;

            case GameStateInGameLocal localGameState:
                levelToPlay = localGameState.LevelToPlay;
                break;

                // CLIENT DOESN'T GET TO CHOOSE !!
            }

            SyncedValues.SetOrCreate(new SyncedValueCurrentLevel()
            {
                Name = levelToPlay
            });
        }
    }
Пример #2
0
    protected override void OnDestroy()
    {
        if (SyncedValues.CanWriteValues)
        {
            SyncedValues.Destroy <SyncedValueCurrentLevel>();
        }

        PresentationHelpers.PresentationWorld?.GetExistingSystem <TickSimulationSystem>()?.PauseSimulation(LEVEL_NOT_STARTED);
        SyncedValues.UnregisterValueListener <SyncedValueCurrentLevel>(OnLevelSet);

        base.OnDestroy();
    }
Пример #3
0
    public void StartLevel(string levelName)
    {
        if (!SystemReady)
        {
            Log.Error("LevelManagerSystem is not ready");
            return;
        }

        if (SyncedValues.CanWriteValues)
        {
            SyncedValues.SetOrCreate(new SyncedValueCurrentLevel()
            {
                Name = levelName
            });
        }
        else
        {
            Log.Error("Client cannot start a level. The server must do that.");
        }
    }