Exemplo n.º 1
0
        void InitializeGame()
        {
            var sceneParameters = GameBoardSceneParameters.GetParameters();

            // If null, start with a default board for testing when directly starting from GameBoard scene.
            if (sceneParameters == null)
            {
                sceneParameters = new GameBoardSceneParameters()
                {
                    GameBoard = GameBoardGenerator.CreateTriangleGame(4),
                    TimeLimit = 180f
                };
            }

            if (sceneParameters.IsReplay)
            {
                replayManager.InitializeWithReplay(sceneParameters.ReplayHistory);
                BuildBoardView(replayManager.GameBoard);
            }
            else
            {
                gameController.InitializeWithBoard(sceneParameters.GameBoard, sceneParameters.TimeLimit);
                BuildBoardView(gameController.GameBoard);
            }
        }
Exemplo n.º 2
0
        void Start()
        {
            gameController.OnGameEnded += GameController_OnGameEnded;
            IsReplay = GameBoardSceneParameters.GetParameters()?.IsReplay ?? false;
            if (IsReplay)
            {
                gameController.gameObject.SetActive(false);

                // Forward some replayManager events.
                replayManager.OnBindingUpdate += (ObservableMessage msg) => {
                    if (msg.Name == nameof(ReplayManager.CanMoveForward))
                    {
                        RaiseBindingUpdate(nameof(CanReplayForward), CanReplayForward);
                    }
                    else if (msg.Name == nameof(ReplayManager.CanMoveBackward))
                    {
                        RaiseBindingUpdate(nameof(CanReplayBackward), CanReplayBackward);
                    }
                };
            }
        }