Пример #1
0
        public ChessScene(ModdableChessGame game) : base(game)
        {
            new MatchManager(this);
            new PieceMover(this);
            new TurnOptionCalculator(this);
            new TurnManager(this);
            new TurnChooser(this);
            new WinConditionChecker(this);
            new PromotionManager(this);
            new SelectedMoveOptionIndicators(this);
            new MouseOverMoveOptionIndicators(this);
            new ReconnectionManager(this);
            new GameStateCompiler(this);
            new BoardCreator(this);
            new OpponentTurnActionWatcher(this);
            new ActionIndicatorPatternCompiler(this);
            new CaptureManager(this);
            new PlayUI.ForfeitButtonController(this);
            new PlayUI.GameOverScreen(this);
            new PlayUI.ActiveTurnDisplay(this);
            new PlayUI.CameraController(this);

            Components.GetOrRegister <Command>((int)ComponentKeys.EndScreenExitPressed, Command.Create)
            .Handler = ExitToLobby;
        }
        public ConnectionHelper(ModdableChessGame game)
        {
            game.Components.Register((int)ComponentKeys.ConnectionHelper, this);

            localInfo        = game.Components.GetOrRegister <LocalPlayerInformation>((int)ComponentKeys.LocalPlayerInformation, LocalPlayerInformation.Create);
            serverInfo       = game.Components.GetOrRegister <ServerInformation>((int)ComponentKeys.ServerInformation, ServerInformation.Create);
            startHostCommand = game.Components.GetOrRegister <Query <bool, StartHostCommand> >
                                   ((int)ComponentKeys.StartHostCommand, Query <bool, StartHostCommand> .Create);
            stopHostCommand    = game.Components.GetOrRegister <Command>((int)ComponentKeys.StopHostCommand, Command.Create);
            startClientCommand = game.Components.GetOrRegister <Query <bool, StartClientCommand> >
                                     ((int)ComponentKeys.StartClientCommand, Query <bool, StartClientCommand> .Create);
            stopClientCommand = game.Components.GetOrRegister <Command>((int)ComponentKeys.StopClientCommand, Command.Create);
            state             = new StateMachine((int)State.None);

            localInfo.Connection.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => OnClientConnectionChange()));
            serverInfo.Connection.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => OnServerConnectionChange()));
            state.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) =>
                                                                         UnityEngine.Debug.LogError(string.Format("{0}: Helper connection change {2}-{1}", game.TickCount, (State)s, mode))));
        }
Пример #3
0
        public ModLoadingScene(ModdableChessGame game) : base(game)
        {
            connHelper = game.Components.Get <ConnectionHelper>((int)ComponentKeys.ConnectionHelper);
            ActivatableList.Add(new ListenerJanitor <IListener <int> >(
                                    connHelper.Connection.EnterStateMessenger,
                                    new SimpleListener <int>((s) => CheckDisconnect())));

            phase = new StateMachine(0);
            phase.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => OnStateChange()));
            timer          = 1;
            lobbyChoices   = game.Components.Get <LobbyChoices>((int)ComponentKeys.LobbyChoices);
            startGenerator = Components.GetOrRegister <Query <NetworkGameState> >((int)ComponentKeys.CalculateStartConditions,
                                                                                  Query <NetworkGameState> .Create);

            reqModLoad           = Components.GetOrRegister((int)ComponentKeys.DeepLoadMod, Command <string> .Create);
            sendGameState        = Game.Components.Get <Command <NetworkGameState> >((int)ComponentKeys.LoadingGameStateSend);
            stopRefreshGameState = Game.Components.Get <Command>((int)ComponentKeys.LoadingGameStateStopRefreshing);
            sendReady            = Game.Components.Get <Command <bool> >((int)ComponentKeys.LoadingReadySend);
            sendError            = Game.Components.Get <Command>((int)ComponentKeys.LoadingErrorSend);

            loadingError = Components.GetOrRegister((int)ComponentKeys.ModLoadError, Message <string> .Create);
            loadingError.Subscribe(new SimpleListener <string>(OnModLoadError));

            Components.GetOrRegister((int)ComponentKeys.ModTranslationComplete, Message.Create).Subscribe(new SimpleListener(OnModTranslated));

            ActivatableList.Add(new ListenerJanitor <IListener <NetworkGameState> >(
                                    Game.Components.Get <IMessage <NetworkGameState> >((int)ComponentKeys.LoadingGameStateReceived),
                                    new SimpleListener <NetworkGameState>(OnReceiveConditions)));
            ActivatableList.Add(new ListenerJanitor <IListener>(
                                    Game.Components.Get <IMessage>((int)ComponentKeys.LoadingExitReceived),
                                    new SimpleListener(ReadyToPlay)));
            ActivatableList.Add(new ListenerJanitor <IListener>(
                                    Game.Components.Get <IMessage>((int)ComponentKeys.LoadingErrorReceived),
                                    new SimpleListener(ExitToLobby)));

            new GameStartGenerator(this);
            new BoardCreator(this);
            new ModErrorLog(this);

            CheckDisconnect();
        }