Ejemplo n.º 1
0
        public ActiveTurnDisplay(ChessScene scene)
        {
            text                  = scene.Components.GetOrRegister <TextDisplay>((int)ComponentKeys.ActiveTurnText, TextDisplay.Create);
            text.Text.Value       = "";
            text.Visibility.Value = false;

            scene.Components.GetOrRegister <Message <Board> >((int)ComponentKeys.BoardCreatedMessage, Message <Board> .Create)
            .Subscribe(new SimpleListener <Board>((b) => {
                board = b;
                RefreshText();
            }));

            scene.Components.GetOrRegister <Message>((int)ComponentKeys.TurnChange, Message.Create)
            .Subscribe(new SimpleListener(RefreshText));

            matchState = scene.Components.GetOrRegister <StateMachine>((int)ComponentKeys.MatchState, StateMachine.Create);
            matchState.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => OnMatchStateChange()));
            OnMatchStateChange();
        }
Ejemplo n.º 2
0
        public GameOverScreen(ChessScene scene)
        {
            exitButton                  = scene.Components.GetOrRegister <Button>((int)ComponentKeys.EndScreenExitBtn, Button.Create);
            exitButton.Text.Value       = "Exit";
            exitButton.Visibility.Value = false;
            exitButton.PressMessage.Subscribe(new SimpleListener(OnExitPressed));

            headerText                  = scene.Components.GetOrRegister <TextDisplay>((int)ComponentKeys.EndScreenHeaderText, TextDisplay.Create);
            headerText.Text.Value       = "Match End";
            headerText.Visibility.Value = false;

            resultText                  = scene.Components.GetOrRegister <TextDisplay>((int)ComponentKeys.EndScreenResultText, TextDisplay.Create);
            resultText.Text.Value       = "";
            resultText.Visibility.Value = false;

            matchState = scene.Components.GetOrRegister <StateMachine>((int)ComponentKeys.MatchState, StateMachine.Create);
            matchState.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => OnMatchStateChange()));

            exitToLobby = scene.Components.GetOrRegister <Command>((int)ComponentKeys.EndScreenExitPressed, Command.Create);

            scene.Components.GetOrRegister <Message <GameEndType> >((int)ComponentKeys.GameEnd, Message <GameEndType> .Create)
            .Subscribe(new SimpleListener <GameEndType>(OnGameEndMessage));
        }