示例#1
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);
         }
     }));
 }
示例#2
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);
 }
        public MouseOverMoveOptionIndicators(AutoController 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);

            displayMessage = scene.Components.GetOrRegister <Message <ActionIndicatorPattern> >
                                 ((int)ComponentKeys.MouseOverIndicatorPattern, Message <ActionIndicatorPattern> .Create);
            moveOptionCalculator = scene.Components.GetOrRegister <Query <TurnOptions, TurnOptionCalculatorArgs> >
                                       ((int)ComponentKeys.MoveOptionListQuery, Query <TurnOptions, TurnOptionCalculatorArgs> .Create);
            compiler = scene.Components.GetOrRegister <Query <ActionIndicatorPattern, ActionIndicatorPatternCompileArgs> >(
                (int)ComponentKeys.GetActionIndicatorPattern, Query <ActionIndicatorPattern, ActionIndicatorPatternCompileArgs> .Create);
            chosenPiece = scene.Components.GetOrRegister <SubscribableInt>((int)ComponentKeys.TurnChooserChosenPiece, SubscribableInt.Create);
            chosenPiece.Subscribe(new SimpleListener <int>((p) => RefreshMoveOptions()));
            selEvent = scene.Components.GetOrRegister <PlayerSelectionEvent>((int)ComponentKeys.PlayerSelectionChange, PlayerSelectionEvent.Create);
            selEvent.Subscribe(new SimpleListener(RefreshMoveOptions));
        }
        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));
        }
示例#6
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);
        }
        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();
                }
            }));
        }