Ejemplo n.º 1
0
        public LoadingManager(ModdableChessGame game)
        {
            game.Components.GetOrRegister <LocalPlayerInformation>((int)ComponentKeys.LocalPlayerInformation, LocalPlayerInformation.Create)
            .Connection.EnterStateMessenger.Subscribe(new SimpleListener <int>(OnConnectionChange));

            gameStateRefresher = new ReadyCheckSender(game, 5, (r) => SendGameStateRefresh(r));
            gameStateRefresher.InitialWaitPeriod = gameStateRefresher.ResendPeriod;
            onGameStateReceived = game.Components.GetOrRegister <Message <NetworkGameState> >
                                      ((int)ComponentKeys.LoadingGameStateReceived, Message <NetworkGameState> .Create);
            game.Components.GetOrRegister <Command <NetworkGameState> >
                ((int)ComponentKeys.LoadingGameStateSend, Command <NetworkGameState> .Create).Handler = SendGameState;
            game.Components.GetOrRegister <Command>
                ((int)ComponentKeys.LoadingGameStateStopRefreshing, Command.Create).Handler = StopRefreshGameState;

            onErrorReceived = game.Components.GetOrRegister <Message>
                                  ((int)ComponentKeys.LoadingErrorReceived, Message.Create);
            game.Components.GetOrRegister <Command>
                ((int)ComponentKeys.LoadingErrorSend, Command.Create).Handler = SendError;

            onExitReceived = game.Components.GetOrRegister <Message>
                                 ((int)ComponentKeys.LoadingExitReceived, Message.Create);
            readySender = new ReadyCheckSender(game, 5, (r) => SendReadyState(r));
            game.Components.GetOrRegister <Command <bool> >
                ((int)ComponentKeys.LoadingReadySend, Command <bool> .Create).Handler = ReadyStateChange;

            NetworkTracker.ClientMsgCallbacks.loadingGameStateReply = OnReceivedGameState;
            NetworkTracker.ClientMsgCallbacks.loadingErrorRelay     = OnReceivedError;
            NetworkTracker.ClientMsgCallbacks.loadingExitReceived   = OnReceivedExit;
        }
Ejemplo n.º 2
0
        public LobbyScene(ModdableChessGame game) : base(game)
        {
            ComponentRegistry guiMessages = new ComponentRegistry();

            Components.Register((int)ComponentKeys.LobbyGUIMessages, guiMessages);

            screen = new StateMachine(0);
            Components.Register((int)ComponentKeys.LobbyScreen, screen);

            new HostOrClientScreenManager(this);
            new SetupHostScreenManager(this);
            new LobbyInitializedCheck(this);
            new TurnOrderSelectionController(this);
            new Mods.ShallowModLoader(this);
            new ModListController(this);
            new ReadyButtonController(this);
            new OtherPlayerReadyTextController(this);
            new LobbyExitController(this);
            new LobbyBackButton(this);
            new RejoinScreenController(this);

            ServerInformation server = Game.Components.Get <ServerInformation>((int)ComponentKeys.ServerInformation);

            server.Connection.EnterStateMessenger.Subscribe(new SimpleListener <int>(OnServerConnectionChange));
        }
Ejemplo n.º 3
0
        public LobbyInitReadyCheck(ModdableChessGame game)
        {
            readyCheck = new ServerReadyCheckManager(game, TIMEOUT_PERIOD);

            onLobbyInitialized = game.Components.GetOrRegister <Message>((int)ComponentKeys.Server_LobbyInitialized, Message.Create);

            NetworkTracker.ServerMsgCallbacks.lobbyInitNotifyReady = OnReceivedNotice;
        }
Ejemplo n.º 4
0
        public BoardController(ModdableChessGame game)
        {
            info          = game.Components.GetOrRegister <ServerInformation>((int)ComponentKeys.ServerInformation, ServerInformation.Create);
            eotReadyCheck = new ServerReadyCheckManager(game, 10);
            eotReadyCheck.EnforceExtraData = true;

            NetworkTracker.ServerMsgCallbacks.boardActionReceived     = OnActionReceived;
            NetworkTracker.ServerMsgCallbacks.boardEndOfTurnReceived  = OnEoTReceived;
            NetworkTracker.ServerMsgCallbacks.boardEndOfTurnRefreshed = OnEoTRefreshed;
        }
Ejemplo n.º 5
0
        public ClientLobbyInit(ModdableChessGame game)
        {
            sender = new ReadyCheckSender(game, 5, (r) => SendMessage(r));

            NetworkTracker.ClientMsgCallbacks.lobbyInitAllReady = OnAllReady;

            game.Components.GetOrRegister <LocalPlayerInformation>((int)ComponentKeys.LocalPlayerInformation, LocalPlayerInformation.Create)
            .Connection.EnterStateMessenger.Subscribe(new SimpleListener <int>(OnConnectionChange));
            game.Components.GetOrRegister <Command <bool> >((int)ComponentKeys.LobbyInitSendReady, Command <bool> .Create).Handler = OnSendReadyCommand;
            allReadyMessage = game.Components.GetOrRegister <Message>((int)ComponentKeys.LobbyInitAllReadyReceived, Message.Create);
        }
Ejemplo n.º 6
0
        private void CreateGame()
        {
            game = new ModdableChessGame();
            game.LoadFirstScene();
            this.gameObject.AddComponent <Mods.TOCLoader>();

            db     = game.Components.Get <GameDatabase>((int)ComponentKeys.GameDatabase);
            server = game.Components.Get <ServerInformation>((int)ComponentKeys.ServerInformation);
            local  = game.Components.Get <LocalPlayerInformation>((int)ComponentKeys.LocalPlayerInformation);
            lobby  = game.Components.Get <LobbyChoices>((int)ComponentKeys.LobbyChoices);
        }
Ejemplo n.º 7
0
        public ServerReadyCheckManager(ModdableChessGame game, float timeOutPeriod)
        {
            game.AddTicking(this);
            this.timeOutPeriod = timeOutPeriod;

            connections = new List <ConnectionData>();
            serverInfo  = game.Components.Get <ServerInformation>((int)ComponentKeys.ServerInformation);

            game.Components.Get <ServerInformation>((int)ComponentKeys.ServerInformation).Connection.EnterStateMessenger.Subscribe(
                new SimpleListener <int>((s) => CheckServerConnection()));
        }
        private void Start()
        {
            ModdableChessGame game = GameLink.Game;

            models = FindObjectOfType <PieceModelCreator>();
            game.SceneComponents.GetOrRegister <Message <Board> >((int)ComponentKeys.BoardCreatedMessage, Message <Board> .Create)
            .Subscribe(new SimpleListener <Board>((b) => board = b));
            board = game.Components.Get <Board>((int)ComponentKeys.GameBoard);
            db    = game.Components.Get <GameDatabase>((int)ComponentKeys.GameDatabase);

            game.SceneComponents.Get <Message <int> >((int)ComponentKeys.PieceMovedEvent).Subscribe(new SimpleListener <int>(OnPieceMove));
            game.SceneComponents.Get <Message <int> >((int)ComponentKeys.PieceCapturedEvent).Subscribe(new SimpleListener <int>(OnPieceCapture));
        }
Ejemplo n.º 9
0
        public LoadingManager(ModdableChessGame game)
        {
            info = game.Components.GetOrRegister <ServerInformation>((int)ComponentKeys.ServerInformation, ServerInformation.Create);
            //info.Connection.EnterStateMessenger.Subscribe(new SimpleListener<int>((s) => CheckServerConnection()));
            readyToPlay      = new ServerReadyCheckManager(game, 10);
            gameStateRefresh = new ServerReadyCheckManager(game, 10);
            gameStateRefresh.EnforceExtraData = true;

            NetworkTracker.ServerMsgCallbacks.loadingGameStateReceived = OnReceiveGameState;
            NetworkTracker.ServerMsgCallbacks.loadingGameStateRefresh  = OnGameStateRefresh;
            NetworkTracker.ServerMsgCallbacks.loadingErrorReceived     = OnReceiveError;
            NetworkTracker.ServerMsgCallbacks.loadingReadyReceived     = OnReceiveReady;
        }
        private void Start()
        {
            ModdableChessGame game = GameLink.Game;

            game.SceneComponents.GetOrRegister <Message <Board> >((int)ComponentKeys.BoardCreatedMessage, Message <Board> .Create)
            .Subscribe(new SimpleListener <Board>((b) => board = b));
            board      = game.Components.Get <Board>((int)ComponentKeys.GameBoard);
            db         = game.Components.Get <GameDatabase>((int)ComponentKeys.GameDatabase);
            modelGObjs = new Dictionary <int, PieceModel>();
            pieceLayer = LayerMask.NameToLayer("Pieces");

            game.SceneComponents.GetOrRegister <Message <int> >((int)ComponentKeys.PiecePromotionEvent, Message <int> .Create)
            .Subscribe(new SimpleListener <int>(DoPromotion));

            CreateInitialPieces();
        }
        public ServerLobbyMessages(ModdableChessGame game)
        {
            combinedMods = new List <Mod>();
            hostMods     = new List <Mod>();
            clientMods   = new List <Mod>();
            nameMap      = new Dictionary <string, int>();
            readyChecker = new ServerReadyCheckManager(game, 10);

            game.Components.GetOrRegister <Message>((int)ComponentKeys.Server_LobbyInitialized, Message.Create)
            .Subscribe(new SimpleListener(OnLobbyInitialized));
            info = game.Components.GetOrRegister <ServerInformation>((int)ComponentKeys.ServerInformation, ServerInformation.Create);
            NetworkTracker.ServerMsgCallbacks.lobbyPickedTurnOrderReceived = ReceivedPickedTurnOrder;
            NetworkTracker.ServerMsgCallbacks.lobbyModsListReceived        = ReceivedModList;
            NetworkTracker.ServerMsgCallbacks.lobbyModsPickReceived        = ReceivedModPick;
            NetworkTracker.ServerMsgCallbacks.lobbyReadyReceived           = ReceivedReady;
        }
Ejemplo n.º 12
0
        public ServerController(ModdableChessGame game)
        {
            game.AddTicking(this);

            info = game.Components.GetOrRegister <ServerInformation>((int)ComponentKeys.ServerInformation, ServerInformation.Create);
            ClearServerInfo();
            game.Components.Register((int)ComponentKeys.Server_Callbacks, this);
            game.Components.GetOrRegister <Query <bool, StartHostCommand> >((int)ComponentKeys.StartHostCommand, Query <bool, StartHostCommand> .Create)
            .Handler = StartHost;
            game.Components.GetOrRegister <Command>((int)ComponentKeys.StopHostCommand, Command.Create)
            .Handler = StopHost;

            info.Connection.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) =>
                                                                                   UnityEngine.Debug.LogError(string.Format("{0}: Server connection change {1}", game.TickCount, (ServerConnectionState)s))));
            disconnectNextFrame = new Queue <int>();

            //new ReconnectionServerManager(game);
            //new ServerReadyCheckManager(game);
            //new ServerLoadingErrorManager(game);
        }
        public LobbyExitController(AutoController scene)
        {
            game = (ModdableChessGame)scene.Game;

            choices = scene.Game.Components.Get <LobbyChoices>((int)ComponentKeys.LobbyChoices);

            state = new StateMachine(0);
            state.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => OnStateChange()));

            readyStatus = scene.Components.GetOrRegister((int)ComponentKeys.LobbyReadyStatus, SubscribableBool.Create);
            readyStatus.Subscribe(new SimpleListener <bool>((v) => OnReadyStatusChange()));
            readyStatus.Value = false;

            notifyServerReady = scene.Game.Components.Get <Command <bool> >((int)ComponentKeys.LobbyReadyNoticeSendRequest);

            scene.ActivatableList.Add(new ListenerJanitor <IListener <LobbyExitState> >(
                                          scene.Game.Components.Get <IMessage <LobbyExitState> >((int)ComponentKeys.LobbyExitMessageReceived),
                                          new SimpleListener <LobbyExitState>(OnAllReadyReceived)));

            scene.Components.GetOrRegister <SubscribableObject <string> >((int)ComponentKeys.LobbyModSelected, SubscribableObject <string> .Create)
            .Subscribe(new SimpleListener <string>(OnModChange));

            initStatus = scene.Components.GetOrRegister <StateMachine>((int)ComponentKeys.LobbyInitStatus, StateMachine.Create);
            initStatus.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => OnInitStatusChange()));

            getModFolder = scene.Components.GetOrRegister <Query <string, string> >((int)ComponentKeys.GetCachedModFolder, Query <string, string> .Create);

            screen = scene.Components.Get <StateMachine>((int)ComponentKeys.LobbyScreen);
            screen.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => {
                state.State       = 0;
                readyStatus.Value = false;
                if (s == (int)LobbyScreen.HostGamePrefs || s == (int)LobbyScreen.ClientGamePrefs)
                {
                    SendReadyStatus();
                }
            }));
        }
Ejemplo n.º 14
0
        public LobbyMessages(ModdableChessGame game)
        {
            netMods = new List <NetworkModInfo>();

            game.Components.GetOrRegister <LocalPlayerInformation>((int)ComponentKeys.LocalPlayerInformation, LocalPlayerInformation.Create)
            .Connection.EnterStateMessenger.Subscribe(new SimpleListener <int>(OnConnectionChange));

            turnOrderReceived = game.Components.GetOrRegister <Message <LobbyTurnOrderChoice> >
                                    ((int)ComponentKeys.LobbyTurnOrderChoiceReceived, Message <LobbyTurnOrderChoice> .Create);
            game.Components.GetOrRegister <Command <LobbyTurnOrderChoice> >
                ((int)ComponentKeys.LobbyTurnOrderChoiceNotify, Command <LobbyTurnOrderChoice> .Create).Handler = SendPickedTurnOrder;

            modListReceived = game.Components.GetOrRegister <Message <List <NetworkModInfo> > >
                                  ((int)ComponentKeys.NetworkModListReceived, Message <List <NetworkModInfo> > .Create);
            game.Components.GetOrRegister <Command <List <LocalModInfo> > >
                ((int)ComponentKeys.NetworkModListSendRequest, Command <List <LocalModInfo> > .Create).Handler = SendModList;

            modPickReceived = game.Components.GetOrRegister <Message <bool, string> >
                                  ((int)ComponentKeys.NetworkPickedModReceived, Message <bool, string> .Create);
            game.Components.GetOrRegister <Command <bool, string> >
                ((int)ComponentKeys.NetworkPickedModSendRequest, Command <bool, string> .Create).Handler = SendPickedMod;

            readySender        = new ReadyCheckSender(game, 5, (s) => SendReadyNotice(s));
            readyRelayReceived = game.Components.GetOrRegister <Message <bool> >
                                     ((int)ComponentKeys.LobbyOtherPlayerReadyReceived, Message <bool> .Create);
            exitMessageReceived = game.Components.GetOrRegister <Message <LobbyExitState> >
                                      ((int)ComponentKeys.LobbyExitMessageReceived, Message <LobbyExitState> .Create);
            game.Components.GetOrRegister <Command <bool> >
                ((int)ComponentKeys.LobbyReadyNoticeSendRequest, Command <bool> .Create).Handler = ReadyStatusChange;

            NetworkTracker.ClientMsgCallbacks.lobbyPickedTurnOrderRelay = ReceivedPickedTurnOrder;
            NetworkTracker.ClientMsgCallbacks.lobbyModsListRelay        = ReceiveModList;
            NetworkTracker.ClientMsgCallbacks.lobbyModsPickRelay        = ReceiveModPick;
            NetworkTracker.ClientMsgCallbacks.lobbyReadyNoticeRelay     = ReceiveReadyRelay;
            NetworkTracker.ClientMsgCallbacks.lobbyExitMessageReceived  = ReceivedExitMessage;
        }
Ejemplo n.º 15
0
 public ScriptController(ModdableChessGame game)
 {
     game.Components.Register((int)ComponentKeys.LuaScripts, this);
     UserData.RegisterAssembly();
 }