Пример #1
0
 /// <summary>
 /// Construct a board panel with the specified board
 /// </summary>
 public BoardPanel2D()
 {
     board        = new Checkerboard();
     boardPainter = new BoardPainter(PieceSetFactory.CreateWoodGrainPieceSet());
     this.Cursor  = HandSelectCursor;
     gameMessage  = "Click Your Piece To Play";
     moveAnimator = new MoveAnimator(this, TimeSpan.FromMilliseconds(80), floatingPiece);
     moveAnimator.MoveCompleted += new MoveAnimator.MoveCompletedDelegate(moveAnimator_MoveCompleted);
     InitializeComponent();
     presenter = new BoardPresenter(this);
 }
Пример #2
0
 public EraseLineService(
     IBoard board,
     BoardPresenter boardPresenter,
     Score score,
     ScorePresenter scorePresenter
     )
 {
     Board          = board;
     BoardPresenter = boardPresenter;
     Score          = score;
     ScorePresenter = scorePresenter;
 }
Пример #3
0
 public PutControlBlocksService(
     IBoard board,
     CollisionDetection collisionDetection,
     BoardPresenter boardPresenter,
     ControlBlocksAdjuster adjuster
     )
 {
     Board = board;
     CollisionDetection = collisionDetection;
     BoardPresenter     = boardPresenter;
     Adjuster           = adjuster;
 }
Пример #4
0
    /*
     * Initializer
     */
    void Start()
    {
        presenter = new BoardPresenter(this);
        const float SPACING = 2.5f;

        squares = new GameObject[3, 3];

        // Instantiate each of the interactive squares and position them on the screen
        for (int x = 0; x < squares.GetLength(0); x++)
        {
            for (int y = 0; y < squares.GetLength(1); y++)
            {
                GameObject square = (GameObject)Instantiate(squarePrefab, transform.position, transform.rotation);
                square.transform.parent = transform;
                square.transform.Translate(-SPACING + SPACING * x, -SPACING + SPACING * y, 0);
                SquareViewer squareViewer = square.GetComponent <SquareViewer>();
                squareViewer.linkToPosition(new Coordinates(x, y));
                squareViewer.presenter = presenter;
                squareViewer.GetComponent <SpriteRenderer>().sprite = emptySprite;

                squares[x, y] = square;
            }
        }
    }
Пример #5
0
        IEnumerator Start()
        {
            #region Config

            log.Info("\n\nStart");
            var units                 = new UnitInfoLoader().Load();
            var saveDataLoader        = new SaveInfoLoader();
            var saves                 = saveDataLoader.Load();
            var decisionTreeLoader    = new DecisionTreeLoader();
            var decisionTreeComponent = decisionTreeLoader.Load();

            #endregion
            #region Infrastructure

            var tickController  = new TickController();
            var inputController = new InputController(tickController);
            //TODO: implement event bus that won't allocate(no delegates)
            var eventBus = new EventBus();            //TODO: stop using eventbus Ievent interface to remove reference on that library from model
            EventBus.Log     = m => log.Info($"{m}"); //TODO: remove that lmao
            EventBus.IsLogOn = () => DebugController.Info.IsDebugOn;

            #endregion
            #region View

            var mainCamera                  = Camera.main;
            var tileSpawner                 = new TilePresenter(TileStartPoints, new TileViewFactory(TileViewPrefab));
            var coordFinder                 = new CoordFinder(TileStartPoints);
            var unitViewFactory             = new UnitViewFactory(units, UnitViewPrefab, coordFinder, mainCamera);
            var unitViewCoordChangedHandler = new UnitViewCoordChangedHandler(coordFinder);
            var boardPresenter              = new BoardPresenter(unitViewCoordChangedHandler);

            var playerPresenterContext = new PlayerPresenterContext(
                new PlayerPresenter(unitViewFactory, unitViewCoordChangedHandler),
                new PlayerPresenter(unitViewFactory, unitViewCoordChangedHandler));

            #endregion
            #region Model
            var decisionTreeLookup = new DecisionTreeLookup();

            var decisionTreeCreatorVisitor = new DecisionTreeCreatorVisitor(eventBus,
                                                                            d => new LoggingDecorator(d, DebugController.Info), decisionTreeLookup);

            var unitFactory = new UnitFactory(units, new DecisionFactory(
                                                  decisionTreeCreatorVisitor, decisionTreeComponent));

            //TODO: replace board/bench dictionaries with array?
            var playerContext = new PlayerContext(new Player(unitFactory), new Player(unitFactory));
            var board         = new Board();
            var aiHeap        = new AiHeap();
            var aiContext     = new AiContext(board, aiHeap);

            #endregion
            #region Shared

            var worldContext = new PlayerSharedContext(playerContext, playerPresenterContext, BattleSetupUI);

            #endregion
            #region Controller

            var raycastController = new RaycastController(mainCamera,
                                                          LayerMask.GetMask("Terrain", "GlobalCollider"), LayerMask.GetMask("Unit"));

            var unitSelectionController = new UnitSelectionController(inputController,
                                                                      raycastController, coordFinder);

            var unitTooltipController = new UnitTooltipController(UnitTooltipUI,
                                                                  unitSelectionController);

            #endregion
            #region Unit drag

            var battleStateController = new BattleStateController(BattleSimulationUI);
            var unitDragController    = new UnitDragController(raycastController,
                                                               new CoordFinderBySelectedPlayer(coordFinder, BattleSetupUI),
                                                               inputController, unitSelectionController,
                                                               new CanStartDrag(battleStateController, BattleSetupUI));

            var tileHighlightController = new TileHighlighterController(tileSpawner,
                                                                        unitDragController);

            var unitMoveController = new UnitMoveController(worldContext, unitDragController);

            #endregion
            #region Battle simulation

            var movementController  = new MovementController(boardPresenter, coordFinder);
            var attackController    = new AttackController(boardPresenter, unitTooltipController);
            var animationController = new AnimationController(boardPresenter);
            eventBus.Register <StartMoveEvent>(movementController, animationController); //TODO: register implicitly?
            eventBus.Register <FinishMoveEvent>(movementController);
            eventBus.Register <RotateEvent>(movementController);
            eventBus.Register <UpdateHealthEvent>(attackController);
            eventBus.Register <DeathEvent>(attackController);
            eventBus.Register <IdleEvent>(animationController);
            eventBus.Register <StartAttackEvent>(animationController);

            var battleSimulationPresenter = new BattleSimulationPresenter(coordFinder,
                                                                          boardPresenter, movementController, movementController);

            var battleSimulation = new BattleSimulation(aiContext, board, aiHeap);

            var realtimeBattleSimulationController = new RealtimeBattleSimulationController(
                movementController, battleSimulation);

            #endregion
            #region Debug

            var battleSimulationDebugController = new BattleSimulationDebugController(
                battleSimulation, BattleSimulationUI,
                aiContext, playerContext, playerPresenterContext, realtimeBattleSimulationController,
                battleSimulationPresenter);

            var battleSaveController = new BattleSaveController(playerContext,
                                                                playerPresenterContext, BattleSaveUI, saveDataLoader, saves,
                                                                battleSimulationDebugController);

            var battleSetupController = new BattleSetupController(playerContext,
                                                                  playerPresenterContext, BattleSetupUI);

            var unitModelDebugController = new UnitModelDebugController(playerContext, board, ModelUI,
                                                                        DebugController.Info, unitSelectionController);

            var takenCoordDebugController = new TakenCoordDebugController(board, DebugController,
                                                                          tileSpawner);

            var targetDebugController = new TargetDebugController(
                board, coordFinder, DebugController.Info);

            var uiDebugController = new UIDebugController(
                BattleSetupUI, BattleSaveUI, BattleSimulationUI,
                unitModelDebugController);

            #endregion

            yield return(null);

            #region Infrastructure

            tickController.InitObservable(takenCoordDebugController, targetDebugController,
                                          uiDebugController, unitModelDebugController, realtimeBattleSimulationController,
                                          DebugController); //TODO: register implicitly?
            inputController.InitObservables();

            #endregion
            #region View

            BattleSetupUI.SetDropdownOptions(units.Keys.ToList());
            BattleSaveUI.SubToUI(saves.Keys.ToList());
            tileSpawner.SpawnTiles();

            #endregion
            decisionTreeCreatorVisitor.Init();
            #region Controller

            unitSelectionController.SubToInput(disposable);
            battleStateController.SubToUI();
            unitDragController.SubToUnitSelection(disposable);
            tileHighlightController.SubToDrag(disposable);
            unitMoveController.SubToDrag(disposable);
            unitTooltipController.SubToUnitSelection(disposable);

            #endregion
            #region Debug

            battleSaveController.SubToUI();
            battleSetupController.SubToUI();
            unitModelDebugController.SubToUnitSelection(disposable);
            battleSimulationDebugController.SubToUI();
            DebugController.Init(UnitTooltipUI);

            #endregion

            MonoBehaviourCallBackController.StartUpdating(tickController);
        }
 private void Awake()
 {
     Instance = this;
 }
 public AttackController(BoardPresenter boardPresenter,
                         UnitTooltipController unitTooltipController)
 {
     this.boardPresenter        = boardPresenter;
     this.unitTooltipController = unitTooltipController;
 }
 /// <summary>
 /// Construct checkers game to use the given reader and writer for I/O
 /// Построить игру в шашки для использования данного читателя и писателя для ввода / вывода
 /// </summary>
 /// <param name="writer">
 /// Used to write game play information to user
 /// Используется для записи информации об игровом процессе пользователю
 /// </param>
 /// <param name="reader">
 /// Used to get input from user
 /// Используется для получения ввода от пользователя
 /// </param>
 public ConsoleCheckerboardView(TextWriter writer, TextReader reader)
 {
     this.writer    = writer;
     this.reader    = reader;
     this.presenter = new BoardPresenter(this);
 }
 public MovementController(BoardPresenter board, CoordFinder finder)
 {
     this.board  = board;
     this.finder = finder;
 }
 public AnimationController(BoardPresenter board) => this.board = board;