public ReadyButtonController(AutoController scene)
        {
            ComponentRegistry guiComps = scene.Components.Get <ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages);

            buttonEnabled = new SubscribableBool(true);
            guiComps.Register((int)GUICompKeys.ReadyBtnEnabled, buttonEnabled);
            buttonLabel = new SubscribableObject <string>("");
            guiComps.Register((int)GUICompKeys.ReadyBtnLabel, buttonLabel);
            Message buttonClick = new Message();

            guiComps.Register((int)GUICompKeys.ReadyBtnClicked, buttonClick);
            buttonClick.Subscribe(new SimpleListener(OnButtonClick));

            selectedMod = scene.Components.GetOrRegister <SubscribableObject <string> >
                              ((int)ComponentKeys.LobbyModSelected, SubscribableObject <string> .Create);
            selectedMod.Subscribe(new SimpleListener <string>((m) => {
                RefreshButton();
            }));
            readyStatus = scene.Components.GetOrRegister <SubscribableBool>((int)ComponentKeys.LobbyReadyStatus, SubscribableBool.Create);
            readyStatus.Subscribe(new SimpleListener <bool>((v) => RefreshButton()));

            StateMachine screen = scene.Components.Get <StateMachine>((int)ComponentKeys.LobbyScreen);

            screen.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => {
                isHost = s == (int)LobbyScreen.HostGamePrefs;
                if (s == (int)LobbyScreen.HostGamePrefs || s == (int)LobbyScreen.ClientGamePrefs)
                {
                    ScreenEnter();
                }
            }));
        }
示例#2
0
 public Button()
 {
     interactable = new SubscribableBool(true);
     visible      = new SubscribableBool(true);
     text         = new SubscribableObject <string>("");
     pressMessage = new Message();
 }
示例#3
0
 public BoardSpaceChooser(ChessScene scene)
 {
     actionList   = new List <int>();
     inputOffsets = new Dictionary <IntVector2, int>();
     scene.Components.GetOrRegister <Message <Board> >((int)ComponentKeys.BoardCreatedMessage, Message <Board> .Create)
     .Subscribe(new SimpleListener <Board>((b) => board = b));
     db           = scene.Game.Components.Get <GameDatabase>((int)ComponentKeys.GameDatabase);
     chooserState = scene.Components.GetOrRegister <StateMachine>((int)ComponentKeys.TurnChooserState, StateMachine.Create);
     chooserState.EnterStateMessenger.Subscribe(new SimpleListener <int>(OnEnterState));
     selEvent = scene.Components.GetOrRegister <PlayerSelectionEvent>((int)ComponentKeys.PlayerSelectionChange, PlayerSelectionEvent.Create);
     selEvent.Subscribe(new SimpleListener(OnSelectionChange));
     acceptBtn = scene.Components.GetOrRegister <SubscribableBool>((int)ComponentKeys.PlayerSelectionAcceptBtn, SubscribableBool.Create);
     acceptBtn.Subscribe(new TriggerListener(OnSelectionBtnTrigger));
     chosenAction = scene.Components.GetOrRegister <SubscribableObject <TurnAction> >
                        ((int)ComponentKeys.TurnChooserChosenAction, SubscribableObject <TurnAction> .Create);
     highlightMessage = scene.Components.GetOrRegister <Message <TurnChooserHighlight> >
                            ((int)ComponentKeys.TurnChooserHighlightChange, Message <TurnChooserHighlight> .Create);
     chosenPiece          = scene.Components.GetOrRegister <SubscribableInt>((int)ComponentKeys.TurnChooserChosenPiece, SubscribableInt.Create);
     turnOptionCalculator = scene.Components.GetOrRegister <Query <TurnOptions, TurnOptionCalculatorArgs> >
                                ((int)ComponentKeys.MoveOptionListQuery, Query <TurnOptions, TurnOptionCalculatorArgs> .Create);
     scene.Components.GetOrRegister <SubscribableBool>((int)ComponentKeys.PlayerSelectionCycleBtn, SubscribableBool.Create)
     .Subscribe(new TriggerListener(OnCycleButtonPress));
     scene.Components.GetOrRegister <SubscribableInt>((int)ComponentKeys.ScrollWheel, SubscribableInt.Create)
     .Subscribe(new SimpleListener <int>((s) => {
         if (s != 0)
         {
             OnScrollWheel(s);
         }
     }));
 }
        public void Start()
        {
            if (field == null)
            {
                field = GetComponent <InputField>();
            }
            if (messageKey != 0)
            {
                Message <string> valueChange = GameLink.Game.SceneComponents.Get <ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages).Get <Message <string> >((int)messageKey);

                field.onValueChanged.AddListener(valueChange.Send);
            }
            if (setKey != 0)
            {
                fieldText = GameLink.Game.SceneComponents.Get <ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages).Get <SubscribableObject <string> >((int)setKey);
                fieldText.Subscribe(new SimpleListener <string>((t) => RefreshText()));
                RefreshText();
            }
            if (interactableKey != 0)
            {
                interactable = GameLink.Game.SceneComponents.Get <ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages).Get <SubscribableBool>((int)interactableKey);
                interactable.Subscribe(new SimpleListener <bool>((t) => RefreshInteractable()));
                RefreshInteractable();
            }
        }
示例#5
0
 private void Start()
 {
     selAcceptBtn     = GameLink.Game.SceneComponents.Get <SubscribableBool>((int)ComponentKeys.PlayerSelectionAcceptBtn);
     selBackBtn       = GameLink.Game.SceneComponents.Get <SubscribableBool>((int)ComponentKeys.PlayerSelectionCancelBtn);
     selCycleBtn      = GameLink.Game.SceneComponents.Get <SubscribableBool>((int)ComponentKeys.PlayerSelectionCycleBtn);
     scrollWheel      = GameLink.Game.SceneComponents.Get <SubscribableInt>((int)ComponentKeys.ScrollWheel);
     cameraMouseTrack = GameLink.Game.SceneComponents.Get <SubscribableBool>((int)ComponentKeys.CameraTrackMouseBtn);
     mouseChange      = GameLink.Game.SceneComponents.Get <SubscribableVector2>((int)ComponentKeys.MouseChange);
     recenterCamera   = GameLink.Game.SceneComponents.Get <SubscribableBool>((int)ComponentKeys.CameraRecenterBtn);
 }
 public PieceChooser(ChessScene scene)
 {
     scene.Components.GetOrRegister <Message <Board> >((int)ComponentKeys.BoardCreatedMessage, Message <Board> .Create)
     .Subscribe(new SimpleListener <Board>((b) => board = b));
     chooserState = scene.Components.GetOrRegister <StateMachine>((int)ComponentKeys.TurnChooserState, StateMachine.Create);
     chooserState.EnterStateMessenger.Subscribe(new SimpleListener <int>(OnEnterState));
     selEvent = scene.Components.GetOrRegister <PlayerSelectionEvent>((int)ComponentKeys.PlayerSelectionChange, PlayerSelectionEvent.Create);
     //selEvent.Subscribe(new SimpleListener(OnSelectionChange));
     acceptBtn = scene.Components.GetOrRegister <SubscribableBool>((int)ComponentKeys.PlayerSelectionAcceptBtn, SubscribableBool.Create);
     acceptBtn.Subscribe(new TriggerListener(OnSelectionBtnTrigger));
     chosenPiece = scene.Components.GetOrRegister <SubscribableInt>((int)ComponentKeys.TurnChooserChosenPiece, SubscribableInt.Create);
 }
示例#7
0
 private void Start()
 {
     if (group == null)
     {
         group = GetComponent <ToggleGroup>();
     }
     if (allowAllOffKey != 0)
     {
         allowAllOff = GameLink.Game.SceneComponents.Get <ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages).Get <SubscribableBool>((int)allowAllOffKey);
         allowAllOff.Subscribe(new SimpleListener <bool>((e) => RefreshAllOff()));
         RefreshAllOff();
     }
 }
        public SetupClientScreenManager(AutoController scene)
        {
            ComponentRegistry guiComps = scene.Components.Get <ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages);

            guiComps.Register((int)GUICompKeys.BtnClientCancelPress, new Message());
            guiComps.Register((int)GUICompKeys.BtnStartClientPress, new Message());
            guiComps.Register((int)GUICompKeys.ClientPortChange, new Message <string>());
            guiComps.Register((int)GUICompKeys.ClientAddressChange, new Message <string>());

            startBtnEnabled = new SubscribableBool(hasPort);
            guiComps.Register((int)GUICompKeys.BtnClientStartEnabledCommand, startBtnEnabled);

            setInputInteractable = new SubscribableBool(state != State.Connecting);
            guiComps.Register((int)GUICompKeys.ClientStartInputInteractable, setInputInteractable);

            setPortField = new SubscribableObject <string>(port.ToString());
            guiComps.Register((int)GUICompKeys.ClientPortSetCommand, setPortField);

            setAddressField = new SubscribableObject <string>("");
            guiComps.Register((int)GUICompKeys.ClientAddressTextField, setAddressField);

            statusText = new SubscribableObject <string>("");
            guiComps.Register((int)GUICompKeys.ClientConnectionStatusLabel, statusText);

            guiComps.Get <Message <string> >((int)GUICompKeys.ClientPortChange).Subscribe(new SimpleListener <string>(OnPortChange));
            guiComps.Get <Message <string> >((int)GUICompKeys.ClientAddressChange).Subscribe(new SimpleListener <string>(OnAddressChange));
            guiComps.Get <Message>((int)GUICompKeys.BtnClientCancelPress).Subscribe(new SimpleListener(OnCancelPress));
            guiComps.Get <Message>((int)GUICompKeys.BtnStartClientPress).Subscribe(new SimpleListener(OnStartPress));

            screen             = scene.Components.Get <StateMachine>((int)ComponentKeys.LobbyScreen);
            startClientCommand = scene.Game.Components.Get <Message <string, int> >((int)ComponentKeys.StartClientCommand);
            stopClientCommand  = scene.Game.Components.Get <Message>((int)ComponentKeys.StopClientCommand);

            screen.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => {
                if (s == (int)LobbyScreen.SetupClient)
                {
                    state = State.Choosing;
                    SetDefaults();
                }
                else
                {
                    state = State.Hidden;
                }
            }));

            scene.ActivatableList.Add(new ListenerJanitor <IListener <int> >(
                                          scene.Game.Components.Get <LocalPlayerInformation>((int)ComponentKeys.LocalPlayerInformation).Connection.EnterStateMessenger,
                                          new SimpleListener <int>(OnConnectionEstablished)));
        }
        public CameraController(ChessScene scene)
        {
            scene.ActivatableList.Add(new TickingJanitor(scene.Game, this));

            scene.Components.GetOrRegister <Message <Board> >((int)ComponentKeys.BoardCreatedMessage, Message <Board> .Create)
            .Subscribe(new SimpleListener <Board>(ReceivedNewBoard));

            rotation       = scene.Components.GetOrRegister <SubscribableQuaternion>((int)ComponentKeys.GameCameraRotation, SubscribableQuaternion.Create);
            rotation.Value = Quaternion.identity;
            zoom           = scene.Components.GetOrRegister <SubscribableFloat>((int)ComponentKeys.GameCameraZoom, SubscribableFloat.Create);
            zoom.Value     = ZOOM_DEFAULT;

            trackMouseBtn = scene.Components.GetOrRegister <SubscribableBool>((int)ComponentKeys.CameraTrackMouseBtn, SubscribableBool.Create);
            mouseChange   = scene.Components.GetOrRegister <SubscribableVector2>((int)ComponentKeys.MouseChange, SubscribableVector2.Create);
            mouseWheel    = scene.Components.GetOrRegister <SubscribableInt>((int)ComponentKeys.ScrollWheel, SubscribableInt.Create);
            scene.Components.GetOrRegister <SubscribableBool>((int)ComponentKeys.CameraRecenterBtn, SubscribableBool.Create)
            .Subscribe(new ReleaseListener(RecenterCamera));
        }
示例#10
0
        public HostOrClientScreenManager(AutoController scene)
        {
            ComponentRegistry guiComps = scene.Components.Get <ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages);

            guiComps.Register((int)GUICompKeys.ChooseToHostBtnPress, new Message());
            guiComps.Register((int)GUICompKeys.ChooseToJoinBtnPress, new Message());
            guiComps.Register((int)GUICompKeys.ChooseToRejoinBtnPress, new Message());

            rejoinButtonVisible = new SubscribableBool(false);
            guiComps.Register((int)GUICompKeys.ChooseToRejoinBtnVisible, rejoinButtonVisible);

            guiComps.Get <Message>((int)GUICompKeys.ChooseToHostBtnPress).Subscribe(new SimpleListener(OnHostBtn));
            guiComps.Get <Message>((int)GUICompKeys.ChooseToJoinBtnPress).Subscribe(new SimpleListener(OnJoinBtn));
            guiComps.Get <Message>((int)GUICompKeys.ChooseToRejoinBtnPress).Subscribe(new SimpleListener(OnRejoinBtn));

            screen = scene.Components.Get <StateMachine>((int)ComponentKeys.LobbyScreen);
            screen.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => OnEnterScreen()));
        }
 public void Start() {
     if(toggle == null) {
         toggle = GetComponent<Toggle>();
     }
     if(changeKey != 0) {
         Message<bool> messenger = GameLink.Game.SceneComponents.Get<ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages).Get<Message<bool>>((int)changeKey);
         toggle.onValueChanged.AddListener(messenger.Send);
     }
     if(enableKey != 0) {
         enabledState = GameLink.Game.SceneComponents.Get<ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages).Get<SubscribableBool>((int)enableKey);
         enabledState.Subscribe(new SimpleListener<bool>((e) => RefreshEnabled()));
         RefreshEnabled();
     }
     if(setKey != 0) {
         selectedState = GameLink.Game.SceneComponents.Get<ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages).Get<SubscribableBool>((int)setKey);
         selectedState.Subscribe(new SimpleListener<bool>((e) => RefreshSelected()));
         RefreshSelected();
     }
 }
示例#12
0
        public void Start()
        {
            if (button == null)
            {
                button = GetComponent <Button>();
            }
            if (messageKey != 0)
            {
                Message messenger = GameLink.Game.SceneComponents.Get <ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages).Get <Message>((int)messageKey);

                button.onClick.AddListener(messenger.Send);
            }
            if (enableKey != 0)
            {
                enabledState = GameLink.Game.SceneComponents.Get <ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages).Get <SubscribableBool>((int)enableKey);
                enabledState.Subscribe(new SimpleListener <bool>((e) => RefreshEnabled()));
                RefreshEnabled();
            }
        }
        public LobbyBackButton(AutoController scene)
        {
            ComponentRegistry guiComps = scene.Components.Get <ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages);

            onClick = new Message();
            guiComps.Register((int)GUICompKeys.BackButtonClicked, onClick);
            onClick.Subscribe(new SimpleListener(OnButtonClicked));

            buttonInteractable = new SubscribableBool(false);
            guiComps.Register((int)GUICompKeys.BackButtonInteractable, buttonInteractable);

            connHelper = scene.Game.Components.Get <ConnectionHelper>((int)ComponentKeys.ConnectionHelper);
            scene.ActivatableList.Add(new ListenerJanitor <IListener <int> >(
                                          connHelper.Connection.EnterStateMessenger,
                                          new SimpleListener <int>((s) => CheckDisconnect())));

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

            screen = scene.Components.Get <StateMachine>((int)ComponentKeys.LobbyScreen);
            screen.EnterStateMessenger.Subscribe(new SimpleListener <int>(OnEnterScreen));
        }
        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();
                }
            }));
        }
示例#15
0
        public TurnChooser(ChessScene scene)
        {
            //scene.Components.GetOrRegister<Message<Board>>((int)ComponentKeys.BoardCreatedMessage, Message<Board>.Create)
            //    .Subscribe(new SimpleListener<Board>((b) => board = b));
            //db = scene.Game.Components.Get<GameDatabase>((int)ComponentKeys.GameDatabase);

            tickHelper = new TickingJanitor(scene.Game, this);
            tickHelper.ForceInactive = true;
            scene.ActivatableList.Add(tickHelper);

            states = scene.Components.GetOrRegister <StateMachine>((int)ComponentKeys.TurnChooserState, StateMachine.Create);
            states.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => OnEnterChoosingState()));

            backBtn = scene.Components.GetOrRegister <SubscribableBool>((int)ComponentKeys.PlayerSelectionCancelBtn, SubscribableBool.Create);
            backBtn.Subscribe(new TriggerListener(OnBackBtnTrigger));
            choiceMadeEvent = scene.Components.GetOrRegister <Message <TurnAction> >((int)ComponentKeys.MoveChoiceMadeEvent, Message <TurnAction> .Create);
            chosenPiece     = scene.Components.GetOrRegister <SubscribableInt>((int)ComponentKeys.TurnChooserChosenPiece, SubscribableInt.Create);
            chosenPiece.Subscribe(new SimpleListener <int>(OnPieceChosen));
            chosenAction = scene.Components.GetOrRegister <SubscribableObject <TurnAction> >
                               ((int)ComponentKeys.TurnChooserChosenAction, SubscribableObject <TurnAction> .Create);
            chosenAction.Subscribe(new SimpleListener <TurnAction>(OnActionChosen));

            scene.Components.GetOrRegister <Command>((int)ComponentKeys.StartTurnChoosingCommand, Command.Create)
            .Handler = ChoosingStartCommand;
            scene.Components.GetOrRegister <Command>((int)ComponentKeys.StopTurnChoosingCommand, Command.Create)
            .Handler = ChoosingStopCommand;
            scene.Components.GetOrRegister <Command>((int)ComponentKeys.ForfeitGame, Command.Create)
            .Handler = ForfeitGameCommand;

            requestSendAction = scene.Game.Components.Get <Command <TurnAction> >((int)ComponentKeys.SendTurnAction);

            connectionState = scene.Components.GetOrRegister <StateMachine>((int)ComponentKeys.ReconnectionState, StateMachine.Create);
            connectionState.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => OnConnectionStateChange()));

            new PieceChooser(scene);
            new BoardSpaceChooser(scene);
        }
示例#16
0
        //private int frame;

        public SetupHostScreenManager(AutoController scene)
        {
            state = State.Hidden;

            ComponentRegistry guiComps = scene.Components.Get <ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages);

            guiComps.Register((int)GUICompKeys.BtnHostCancelPress, new Message());
            guiComps.Register((int)GUICompKeys.BtnStartHostPress, new Message());
            guiComps.Register((int)GUICompKeys.HostPortChange, new Message <string>());
            guiComps.Register((int)GUICompKeys.ClientAddressChange, new Message <string>());

            startBtnEnabled = new SubscribableBool(hasPort);
            guiComps.Register((int)GUICompKeys.BtnHostStartEnabledCommand, startBtnEnabled);

            setInputInteractable = new SubscribableBool(state != State.Connecting);
            guiComps.Register((int)GUICompKeys.HostStartInputInteractable, setInputInteractable);

            setPortField = new SubscribableObject <string>(port.ToString());
            guiComps.Register((int)GUICompKeys.HostPortSetCommand, setPortField);

            setAddressField = new SubscribableObject <string>("");
            guiComps.Register((int)GUICompKeys.ClientAddressTextField, setAddressField);
            setAddressInteractable = new SubscribableBool(false);
            guiComps.Register((int)GUICompKeys.HostAddressInteractable, setAddressInteractable);

            statusText = new SubscribableObject <string>("");
            guiComps.Register((int)GUICompKeys.HostConnectionStatusLabel, statusText);
            titleText = new SubscribableObject <string>("");
            guiComps.Register((int)GUICompKeys.StartGameTitleText, titleText);
            startButtonText = new SubscribableObject <string>("");
            guiComps.Register((int)GUICompKeys.StartGameStartButtonText, startButtonText);

            guiComps.Get <Message <string> >((int)GUICompKeys.HostPortChange).Subscribe(new SimpleListener <string>(OnPortChange));
            guiComps.Get <Message <string> >((int)GUICompKeys.ClientAddressChange).Subscribe(new SimpleListener <string>(OnAddressChange));
            guiComps.Get <Message>((int)GUICompKeys.BtnHostCancelPress).Subscribe(new SimpleListener(OnCancelPress));
            guiComps.Get <Message>((int)GUICompKeys.BtnStartHostPress).Subscribe(new SimpleListener(OnStartPress));

            setPasswordField = new SubscribableObject <string>("");
            guiComps.Register((int)GUICompKeys.PasswordTextSet, setPasswordField);
            Message <string> passwordChange = new Message <string>();

            guiComps.Register((int)GUICompKeys.PasswordChange, passwordChange);
            passwordChange.Subscribe(new SimpleListener <string>(OnPasswordChange));

            choices   = scene.Game.Components.Get <LobbyChoices>((int)ComponentKeys.LobbyChoices);
            screen    = scene.Components.Get <StateMachine>((int)ComponentKeys.LobbyScreen);
            netHelper = scene.Game.Components.Get <ConnectionHelper>((int)ComponentKeys.ConnectionHelper);
            scene.ActivatableList.Add(new ListenerJanitor <IListener <int> >(
                                          netHelper.Connection.EnterStateMessenger,
                                          new SimpleListener <int>(OnConnectionChange)));

            screen.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => {
                //BalugaDebug.Log("Entering screen " + (LobbyScreen)s);
                if (s == (int)LobbyScreen.SetupHost || s == (int)LobbyScreen.SetupClient)
                {
                    state = State.Choosing;
                    EnterScreen();
                }
                else
                {
                    state = State.Hidden;
                }
            }));
        }
示例#17
0
 public TextDisplay()
 {
     visible = new SubscribableBool(true);
     text    = new SubscribableObject <string>("");
 }
        public ModListController(AutoController scene)
        {
            statusSortOrder = new Dictionary <int, int>();
            statusSortOrder[(int)ModNetworkStatus.Playable]        = 0;
            statusSortOrder[(int)ModNetworkStatus.HostOutOfDate]   = 1;
            statusSortOrder[(int)ModNetworkStatus.ClientOutOfDate] = 1;
            statusSortOrder[(int)ModNetworkStatus.OnlyHost]        = 2;
            statusSortOrder[(int)ModNetworkStatus.OnlyClient]      = 3;
            statusSortOrder[(int)ModNetworkStatus.Unknown]         = 4;
            localMods        = new List <LocalModInfo>();
            networkMods      = new List <NetworkModInfo>();
            allMods          = new List <ComboModInfo>();
            showNotLocalMods = true;

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

            ComponentRegistry guiComps = scene.Components.Get <ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages);

            modButtons = new ModList();
            guiComps.Register((int)GUICompKeys.ModList, modButtons);
            modButtons.OnButtonClick.Subscribe(new SimpleListener <int>(OnModButtonClick));
            pickedLabelTop = new SubscribableObject <string>("");
            guiComps.Register((int)GUICompKeys.ModListLabelTop, pickedLabelTop);
            pickedLabelBottom = new SubscribableObject <string>("");
            guiComps.Register((int)GUICompKeys.ModListLabelBottom, pickedLabelBottom);
            pickedModTop = new SubscribableObject <string>("");
            guiComps.Register((int)GUICompKeys.ModListPickedTop, pickedModTop);
            pickedModBottom = new SubscribableObject <string>("");
            guiComps.Register((int)GUICompKeys.ModListPickedBottom, pickedModBottom);
            Message reloadBtnPressed = new Message();

            guiComps.Register((int)GUICompKeys.ModListReloadBtnPress, reloadBtnPressed);
            reloadBtnPressed.Subscribe(new SimpleListener(OnReloadButton));
            Message hideBtnPressed = new Message();

            guiComps.Register((int)GUICompKeys.ModListHideBtnPress, hideBtnPressed);
            hideBtnPressed.Subscribe(new SimpleListener(OnHideButton));

            reqSendNetworkModList = scene.Game.Components.Get <Command <List <LocalModInfo> > >((int)ComponentKeys.NetworkModListSendRequest);
            scene.ActivatableList.Add(new ListenerJanitor <IListener <List <NetworkModInfo> > >(
                                          scene.Game.Components.Get <Message <List <NetworkModInfo> > >((int)ComponentKeys.NetworkModListReceived),
                                          new SimpleListener <List <NetworkModInfo> >(OnNetworkModListReceived)));

            reqSendPickedMod = scene.Game.Components.Get <Command <bool, string> >((int)ComponentKeys.NetworkPickedModSendRequest);
            scene.ActivatableList.Add(new ListenerJanitor <IListener <bool, string> > (
                                          scene.Game.Components.Get <Message <bool, string> >((int)ComponentKeys.NetworkPickedModReceived),
                                          new SimpleListener <bool, string>(OnNetworkPickedModReceived)));

            selectedModName = scene.Components.GetOrRegister((int)ComponentKeys.LobbyModSelected, SubscribableObject <string> .Create);

            modSearcher = scene.Components.GetOrRegister <Query <List <LocalModInfo>, string> >
                              ((int)ComponentKeys.SearchModFolderRequest, Query <List <LocalModInfo>, string> .Create);

            localInfo = scene.Game.Components.Get <LocalPlayerInformation>((int)ComponentKeys.LocalPlayerInformation);

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

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

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

            screen = scene.Components.Get <StateMachine>((int)ComponentKeys.LobbyScreen);
            screen.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => {
                switch ((LobbyScreen)s)
                {
                case LobbyScreen.ClientGamePrefs:
                case LobbyScreen.HostGamePrefs:
                    OnEnterScreen();
                    break;
                }
            }));
        }
        public TurnOrderSelectionController(AutoController scene)
        {
            tickHelper        = new TickingJanitor(scene.Game, this);
            tickHelper.Active = false;

            ComponentRegistry guiComps = scene.Components.Get <ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages);

            btnsInteractable       = guiComps.GetOrRegister <SubscribableBool>((int)GUICompKeys.TOSInteractable, SubscribableBool.Create);
            btnsInteractable.Value = true;

            toggleValues    = new SubscribableBool[3];
            toggleValues[0] = new SubscribableBool(false);
            guiComps.Register((int)GUICompKeys.TOSOpt1Set, toggleValues[0]);
            toggleValues[1] = new SubscribableBool(false);
            guiComps.Register((int)GUICompKeys.TOSOpt2Set, toggleValues[1]);
            toggleValues[2] = new SubscribableBool(false);
            guiComps.Register((int)GUICompKeys.TOSOpt3Set, toggleValues[2]);

            Message <bool>[] toggleChanges = new Message <bool> [3];
            toggleChanges[0] = new Message <bool>();
            guiComps.Register((int)GUICompKeys.TOSOpt1Change, toggleChanges[0]);
            toggleChanges[1] = new Message <bool>();
            guiComps.Register((int)GUICompKeys.TOSOpt2Change, toggleChanges[1]);
            toggleChanges[2] = new Message <bool>();
            guiComps.Register((int)GUICompKeys.TOSOpt3Change, toggleChanges[2]);
            for (int i = 0; i < toggleChanges.Length; i++)
            {
                int index = i;
                toggleChanges[i].Subscribe(new SimpleListener <bool>((v) => OnToggleChange(index, v)));
            }

            choiceBtnIndex = new Dictionary <LobbyTurnOrderChoice, int>();
            choiceBtnIndex[LobbyTurnOrderChoice.HostIsFirst]   = 0;
            choiceBtnIndex[LobbyTurnOrderChoice.ClientIsFirst] = 1;
            choiceBtnIndex[LobbyTurnOrderChoice.Random]        = 2;
            choiceBtnIndex[LobbyTurnOrderChoice.None]          = -1;

            otherSelLabel = new SubscribableObject <string>("");
            guiComps.Register((int)GUICompKeys.TOSOtherSelectionLabel, otherSelLabel);
            otherSelValue = new SubscribableObject <string>("");
            guiComps.Register((int)GUICompKeys.TOSOtherSelectionValue, otherSelValue);

            allowTogglesOff = new SubscribableBool(false);
            guiComps.Register((int)GUICompKeys.TOSAllowAllTogglesOff, allowTogglesOff);

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

            selected = new SubscribableInt(0);
            //scene.SceneComponents.Register((int)ComponentKeys.LobbyTurnOrderSelected, selected);

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

            reqSendPick = scene.Game.Components.Get <Command <LobbyTurnOrderChoice> >((int)ComponentKeys.LobbyTurnOrderChoiceNotify);
            scene.ActivatableList.Add(new ListenerJanitor <IListener <LobbyTurnOrderChoice> >(
                                          scene.Game.Components.Get <IMessage <LobbyTurnOrderChoice> >((int)ComponentKeys.LobbyTurnOrderChoiceReceived),
                                          new SimpleListener <LobbyTurnOrderChoice>(OnNetworkPickReceived)));

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

            screen = scene.Components.Get <StateMachine>((int)ComponentKeys.LobbyScreen);
            screen.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => {
                isHost = s == (int)LobbyScreen.HostGamePrefs;
                if (s == (int)LobbyScreen.HostGamePrefs || s == (int)LobbyScreen.ClientGamePrefs)
                {
                    ScreenEnter();
                }
            }));
        }