protected virtual void SetupTest() { _reg = new Registry <IModel>(); _reg.Bind <Service.ICardTemplateService, Service.Impl.CardTemplateService>(new Service.Impl.CardTemplateService()); _reg.Bind <IBoardModel, BoardModel>(new BoardModel(8, 8)); _reg.Bind <IArbiterModel, ArbiterModel>(new ArbiterModel()); _reg.Bind <IWhitePlayerModel, WhitePlayerModel>(); _reg.Bind <IBlackPlayerModel, BlackPlayerModel>(); _reg.Bind <ICardModel, CardModel>(); _reg.Bind <IDeckModel, MockDeck>(); _reg.Bind <IHandModel, MockHand>(); _reg.Bind <IPieceModel, PieceModel>(); _reg.Bind <IEndTurnButtonModel, EndTurnButtonModel>(); _reg.Resolve(); _board = _reg.Get <IBoardModel>(); _arbiter = _reg.Get <IArbiterModel>(); _white = _reg.Get <IWhitePlayerModel>(); _black = _reg.Get <IBlackPlayerModel>(); foreach (var model in _reg.Instances.ToList()) { model.PrepareModels(); } }
private void Start() { _model = new BoardModel(); _model.Setup(BOARD_SIZE, MINES); _view = GetComponent <BoardView>(); Initialize(); }
private void BindModels() { _models = new ModelRegistry(); _models.Bind <Service.ICardTemplateService, CardTemplateService>(new CardTemplateService()); _models.Bind <IBoardModel, BoardModel>(new BoardModel(8, 8)); _models.Bind <IArbiterModel, ArbiterModel>(new ArbiterModel()); _models.Bind <IEndTurnButtonModel, EndTurnButtonModel>(); _models.Bind <ICardModel, CardModel>(); _models.Bind <IDeckModel, DeckModel>(); _models.Bind <IHandModel, HandModel>(); _models.Bind <IPieceModel, PieceModel>(); _models.Bind <IPlayerModel, PlayerModel>(); _models.Bind <IPopupModel, PopupModel>(); _models.Resolve(); // make the required minimal components for a game _boardModel = _models.Get <IBoardModel>(); _arbiterModel = _models.Get <IArbiterModel>(); _whitePlayerModel = _models.Get <IPlayerModel>(EColor.White); _blackPlayerModel = _models.Get <IPlayerModel>(EColor.Black); // resolve any cycles of dependency for singletons, // as well as creates models used internally by other models. foreach (var model in _models.Instances.ToList()) { model.PrepareModels(); } }
private void BuildBoard(int numLines, int numColumns, ICellModel cellModelPrototype, float cellWidth = 1f, float cellHeight = 1f) { _boardModel = new BoardModel(numLines, numColumns, cellModelPrototype, cellWidth, cellHeight); float halfWidth = cellWidth * (numColumns - 1) * 0.5f; float halfHeight = cellHeight * (numLines - 1) * 0.5f; for (int i = 0; i < numLines; i++) { for (int j = 0; j < numColumns; j++) { float x = Mathf.Lerp(-halfWidth, halfWidth, j / (numColumns - 1f)); float y = Mathf.Lerp(halfHeight, -halfHeight, i / (numLines - 1f)); ICellModel cellModelInstance = _boardModel.Cells[i, j]; cellModelInstance.OnClick.AddListener(OnClick); cellModelInstance.Transform.localScale = new Vector3(cellWidth, cellHeight, 1f); cellModelInstance.GameObject.name = string.Format("Cell [{0}:{1}]", i, j); Vector3 cellPosition = transform.TransformPoint(new Vector3(x, y, transform.localPosition.z)); cellModelInstance.Transform.localPosition = cellPosition; cellModelInstance.Transform.parent = transform; } } }
public MatchModel(IBoardModel board, int sequenceLength, GameObject[] slotContentVariants) { SlotContentVariants = slotContentVariants; SequenceLength = sequenceLength; Board = board; tileShifter = new MatchTileShifter(Board.Slots); Interaction = new MatchInteraction(); }
public GamePresenter(IBoardView boardView, IGameMaster gameMaster, IBoardModel boardModel, IBoardViewModel boardViewModel) { BoardView = boardView.CheckNull(); GameMaster = gameMaster.CheckNull(); BoardModel = boardModel.CheckNull(); BoardViewModel = boardViewModel.CheckNull(); }
public BoardPreparation(IBoardCreator boardCreator, IFigureCreator figureCreator, IBoardModel boardModel, IFigureController figureController) { BoardCreator = boardCreator.CheckNull(); FigureCreator = figureCreator.CheckNull(); BoardModel = boardModel.CheckNull(); FigureController = figureController.CheckNull(); }
public AiRandomGameControl(IBoardModel boardModel, IFigureModel figureModel, IGameMaster gameMaster, IGameSwitcherTurn gameSwitcherTurn) { BoardModel = boardModel.CheckNull(); FigureModel = figureModel.CheckNull(); GameMaster = gameMaster.CheckNull(); GameSwitcherTurn = gameSwitcherTurn.CheckNull(); }
private void UpdateViewToMatchModel(IBoardModel model, IBoardView view) { for (int row = 0; row < this.boardModel.BoardSize; row++) { for (int column = 0; column < this.boardModel.BoardSize; column++) { this.boardView.UpdateCellState(column, row, this.boardModel.Board[column, row]); } } }
public List <ISlotModel> GetMatchSequences(IBoardModel board, int sequenceLength, ICompareGameObjects comparison) { matchingSlotsToErase = new List <ISlotModel>(); this.comparison = comparison; this.sequenceLength = sequenceLength; SearchRows(board); SearchColumns(board); matchingSlotsToErase = matchingSlotsToErase.Distinct().ToList(); return(matchingSlotsToErase); }
public (IBoardModel, IBoardView) GetBoard(Renderer blocksPrefab, Theme blocks, float blockScale, Transform blocksParent, int numLines, int numColumns) { // Create Builder BoardModel.Builder modelBuilder = new BoardModel.Builder(); BoardView.Builder viewBuilder = new BoardView.Builder(); IBoardModel boardModel = modelBuilder.Build(numLines, numColumns); IBoardView boardView = viewBuilder.Build(boardModel, blocksPrefab, blocks, blockScale, blocksParent); return(boardModel, boardView); }
public GameMaster(IFigureController figureController, IBoardModel boardModel, IGameModel gameModel, IFigurePostTurnLogicManager figurePostTurnLogicManager, IGameMoveTurnManager gameMoveTurnManager) { FigureController = figureController.CheckNull(); BoardModel = boardModel.CheckNull(); GameModel = gameModel.CheckNull(); FigurePostTurnLogicManager = figurePostTurnLogicManager.CheckNull(); GameMoveTurnManager = gameMoveTurnManager.CheckNull(); }
public void UpdateView(IBoardModel boardModel, Theme blocks) { for (int line = 0; line < boardModel.NumLines; line++) { for (int column = 0; column < boardModel.NumColumns; column++) { if (line >= 0 && line < boardModel.NumLines && column >= 0 && column < boardModel.NumColumns) { int blockType = boardModel.Blocks[line, column]; Blocks[line, column].sharedMaterial = blocks.GetMaterial(blockType); } } } }
private void DrawHoldPiece(IBoardModel boardModel, IBoardView boardView, ITetrominoModel tetromino) { for (int line = 0; line < boardModel.NumLines; line++) { for (int column = 0; column < boardModel.NumColumns; column++) { int blockType = tetromino.BlocksPreview[line, column]; boardModel.Blocks[line, column] = blockType; } } // Update view after showing tetromino boardView.UpdateView(boardModel, _blocks); }
public void UpdateView(IBoardModel boardModel, int startLine, int startColumn, int endLine, int endColumn, Theme blocks) { for (int line = startLine; line < endLine; line++) { for (int column = startColumn; column < endColumn; column++) { if (line >= 0 && line < boardModel.NumLines && column >= 0 && column < boardModel.NumColumns) { int blockType = boardModel.Blocks[line, column]; Blocks[line, column].sharedMaterial = blocks.GetMaterial(blockType); } } } }
// Controller depends on interfaces for the model and view public BoardController(IBoardModel model, IBoardView view) { this.model = model; this.view = view; // Listen to input from the view view.OnClicked += HandleClicked; // Listen to changes in the model model.OnBlocksChanged += HandleBlocksChanged; // Set the view's initial state by syncing with the model SyncBlocks(); }
void CreateBoard(GameObject[,] slotContent) { BoardModelFactory modelFactory = new BoardModelFactory(); boardModel = modelFactory.Create(new SlotModelFactory(), rows, columns); BoardViewFactory viewFactory = new BoardViewFactory(); boardView = viewFactory.Create(new SlotViewFactory(), rows, columns, transform); BoardControllerFactory controllerFactory = new BoardControllerFactory(); boardController = controllerFactory.Create(new SlotControllerFactory(), boardModel, boardView); boardModel.SetSlotsContent(slotContent); }
public void SetUp() { var cells = new IBoardCell[, ] { { new BoardCell(BoardCellCol.ColA, BoardCellRow.Row1, 0, 0), new BoardCell(BoardCellCol.ColB, BoardCellRow.Row1, 1, 0) }, { new BoardCell(BoardCellCol.ColC, BoardCellRow.Row2, 0, 1), new BoardCell(BoardCellCol.ColD, BoardCellRow.Row2, 1, 1) } }; BoardModel = new BoardModel(); BoardModel.SetCells(cells); }
public IBoardController Create(ISlotControllerFactory slotFactory, IBoardModel model, IBoardView view) { int rows = model.Rows; int columns = model.Columns; ISlotController[,] slots = new ISlotController[rows, columns]; for (int r = 0; r < rows; r++) { for (int c = 0; c < columns; c++) { slots[r, c] = slotFactory.Create(model.Slots[r, c], view.Slots[r, c]); } } return(new BoardController(slots, model, view)); }
private void SearchColumns(IBoardModel board) { List <ISlotModel> matches = new List <ISlotModel>(); for (int c = 0; c < board.Columns; c++) { for (int r = 0; r < board.Rows; r++) { currentSlot = board.Slots[r, c]; CheckTileInSequence(matches); previousSlot = currentSlot; } CheckIfSequenceIsLongEnough(matches); matches.Clear(); } }
public void CreateCells(IBoardModel boardModel) { var cells = new IBoardCell[MaxColCells, MaxRowCells]; for (var i = 0; i < MaxRowCells; i++) { for (var j = 0; j < MaxColCells; j++) { var col = Cols[j]; var row = Rows[i]; var cell = new BoardCell(col, row, i, j); cells[i, j] = cell; } } boardModel.SetCells(cells); }
public void SetUp() { BoardModel = new BoardModel(); var boardCreator = new BoardCreator(); boardCreator.CreateCells(BoardModel); GameModel = Substitute.For <IGameModel>(); GameModel.CurTeamTurn.Returns(Team); //create figure and cell _mainFigure = Substitute.For <IFigureEntity>(); _mainFigure.Team.Returns(Team); _mainCell = BoardModel.GetCell(CellCol, CellRow); _mainFigure.PlacedCell.Returns(_mainCell); }
public IBoardView Build(IBoardModel boardModel, Renderer blockPrefab, Theme blocks, float blockScale, Transform parent) { Renderer[,] blockRenderers = new Renderer[boardModel.NumLines, boardModel.NumColumns]; float halfBoardWidth = blockScale * (boardModel.NumColumns - 1) * 0.5f; float halfBoardHeight = blockScale * (boardModel.NumLines - 1) * 0.5f; Vector3 localScale = new Vector3(blockScale, blockScale, blockScale - Mathf.Epsilon); // Create Board View from Model for (int line = 0; line < boardModel.NumLines; line++) { for (int col = 0; col < boardModel.NumColumns; col++) { // Set position and scale float normalizedColumn = col / (boardModel.NumColumns - 1f); float normalizedLine = line / (boardModel.NumLines - 1f); float blockX = Mathf.Lerp(-halfBoardWidth, halfBoardWidth, normalizedColumn); float blockY = Mathf.Lerp(halfBoardHeight, -halfBoardHeight, normalizedLine); Vector3 localPosition = new Vector3(blockX, blockY, 0); // Create a transform Renderer blockInstance = Object.Instantiate(blockPrefab, parent); blockInstance.transform.localPosition = localPosition; blockInstance.transform.localScale = localScale; int blockType = boardModel.Blocks[line, col]; blockInstance.sharedMaterial = blocks.GetMaterial(blockType); blockRenderers[line, col] = blockInstance; blockInstance.gameObject.name = string.Format("Block [{0}, {1}] Value: {2}", line, col, blockType); } } IBoardView boardView = new BoardView() { Blocks = blockRenderers }; return(boardView); }
// Create the model public BoardModelFactory() { Model = new BoardModel(); }
public LifeSimulator(IBoardModel boardModel, IBoardView boardView, IBoardController boardController) { this.boardModel = boardModel; this.boardView = boardView; this.boardController = boardController; }
public BoardConsoleView(IBoardModel board) { _board = board; }
public void Construct(IBoardModel boardModel, IGameModel gameModel) { BoardModel = boardModel.CheckNull(); GameModel = gameModel.CheckNull(); }
public void setBoardModel(IBoardModel i_Model) { }
public void setBoardModel(IBoardModel i_Model) { m_BoardModel = i_Model; }
public BoardController(IBoardModel model, IBoardView view) { this.boardModel = model; this.boardView = view; }
public void SetModel(IBoardModel i_BoardModel) { m_BoardModel = i_BoardModel; initializeCurrentPlayer(); }
// Create just the controller public BoardControllerFactory(IBoardModel model, IBoardView view) { Controller = new BoardController(model, view); }