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 TurnManager(ChessScene scene) { //db = scene.Game.Components.Get<GameDatabase>((int)ComponentKeys.GameDatabase); scene.Components.GetOrRegister <Message <Board> >((int)ComponentKeys.BoardCreatedMessage, Message <Board> .Create) .Subscribe(new SimpleListener <Board>((b) => board = b)); startTurnChoosingCommand = scene.Components.GetOrRegister <Command> ((int)ComponentKeys.StartTurnChoosingCommand, Command.Create); stopTurnChoosingCommand = scene.Components.GetOrRegister <Command> ((int)ComponentKeys.StopTurnChoosingCommand, Command.Create); scene.Components.GetOrRegister <Query <NextTurnInfo> >((int)ComponentKeys.NextTurnInfoQuery, Query <NextTurnInfo> .Create) .Handler = FigureNextTurn; moveCommand = scene.Components.GetOrRegister <Command <MoveCommand> > ((int)ComponentKeys.MovePieceCommand, Command <MoveCommand> .Create); captureCommand = scene.Components.GetOrRegister <Command <CaptureCommand> > ((int)ComponentKeys.CapturePieceCommand, Command <CaptureCommand> .Create); promoteCommand = scene.Components.GetOrRegister <Command <PromoteCommand> > ((int)ComponentKeys.PromotePieceCommand, Command <PromoteCommand> .Create); scene.Components.GetOrRegister <Message <TurnAction> >((int)ComponentKeys.MoveChoiceMadeEvent, Message <TurnAction> .Create) .Subscribe(new SimpleListener <TurnAction>(HandleChoiceMade)); scene.Components.GetOrRegister <Command <bool> >((int)ComponentKeys.NextTurnCommand, Command <bool> .Create).Handler = NextTurnCommand; scripts = scene.Game.Components.Get <ScriptController>((int)ComponentKeys.LuaScripts); handleEndOfTurn = scene.Components.GetOrRegister <Command <TurnActionExecutionResult> > ((int)ComponentKeys.HandleEndOfTurn, Command <TurnActionExecutionResult> .Create); turnChange = scene.Components.GetOrRegister <Message>((int)ComponentKeys.TurnChange, Message.Create); scene.Components.GetOrRegister <Message>((int)ComponentKeys.TurnState, Message.Create) .Subscribe(new SimpleListener(OnTurnStateChange)); connectionState = scene.Components.GetOrRegister <StateMachine>((int)ComponentKeys.ReconnectionState, StateMachine.Create); connectionState.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => OnConnectionStateChange())); }
public CaptureManager(ChessScene scene) { scene.Components.GetOrRegister <Message <Board> >((int)ComponentKeys.BoardCreatedMessage, Message <Board> .Create) .Subscribe(new SimpleListener <Board>((b) => board = b)); scene.Components.GetOrRegister <Command <CaptureCommand> >((int)ComponentKeys.CapturePieceCommand, Command <CaptureCommand> .Create) .Handler = DoCapture; pieceCapturedEvent = scene.Components.GetOrRegister <Message <int> >((int)ComponentKeys.PieceCapturedEvent, Message <int> .Create); }
public ActionIndicatorPatternCompiler(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); scene.Components.GetOrRegister <Query <ActionIndicatorPattern, ActionIndicatorPatternCompileArgs> >( (int)ComponentKeys.GetActionIndicatorPattern, Query <ActionIndicatorPattern, ActionIndicatorPatternCompileArgs> .Create) .Handler = Compile; }
public PieceMover(ChessScene scene) { scene.Components.GetOrRegister <Message <Board> >((int)ComponentKeys.BoardCreatedMessage, Message <Board> .Create) .Subscribe(new SimpleListener <Board>((b) => board = b)); scene.Components.GetOrRegister <Command <MoveCommand> >((int)ComponentKeys.MovePieceCommand, Command <MoveCommand> .Create) .Handler = DoMovePiece; pieceChangePos = scene.Components.GetOrRegister <Message <int> >((int)ComponentKeys.PieceMovedEvent, Message <int> .Create); }
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 CheckCalculator(ChessScene scene) { scene.Components.GetOrRegister <Query <bool, CheckCalcArgs> >((int)ComponentKeys.CheckQuery, Query <bool, CheckCalcArgs> .Create) .Handler = Calculate; 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); moveOptionQuery = scene.Components.GetOrRegister <Query <TurnOptions, TurnOptionCalculatorArgs> > ((int)ComponentKeys.MoveOptionListQuery, Query <TurnOptions, TurnOptionCalculatorArgs> .Create); }
public TurnOptionCalculator(ChessScene scene) { scripts = scene.Game.Components.Get <ScriptController>((int)ComponentKeys.LuaScripts); db = scene.Game.Components.Get <GameDatabase>((int)ComponentKeys.GameDatabase); scene.Components.GetOrRegister <Message <Board> >((int)ComponentKeys.BoardCreatedMessage, Message <Board> .Create) .Subscribe(new SimpleListener <Board>((b) => board = b)); luaHelper = UserData.Create(new Mods.Lua.TurnActionHelper()); scene.Components.GetOrRegister <Query <TurnOptions, TurnOptionCalculatorArgs> > ((int)ComponentKeys.MoveOptionListQuery, Query <TurnOptions, TurnOptionCalculatorArgs> .Create) .Handler = CalculateMoveOptions; }
public OpponentTurnActionWatcher(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); turnOptionCalculator = scene.Components.GetOrRegister <Query <TurnOptions, TurnOptionCalculatorArgs> > ((int)ComponentKeys.MoveOptionListQuery, Query <TurnOptions, TurnOptionCalculatorArgs> .Create); choiceMadeEvent = scene.Components.GetOrRegister <Message <TurnAction> >((int)ComponentKeys.MoveChoiceMadeEvent, Message <TurnAction> .Create); scene.ActivatableList.Add(new ListenerJanitor <IListener <TurnAction> >( scene.Game.Components.Get <Message <TurnAction> >((int)ComponentKeys.OpponentTurnActionReceived), new SimpleListener <TurnAction>(OnReceivedAction))); }
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); }