public CellController(Cell model, CellView view) { _model = model; _view = view; _view.Initialize(_model); SubscribeEvents(); }
public void InitializeViewData(GameRenderData data) { _resultsContainer.gameObject.SetActive(false); _resultsContainer.InitializeViewData(data.OnGetToMenu); _gridSize = data.GridSize; _piecePool = data.GridList; for (int i = 0; i < _gridSize.x; i++) { List <CellView> cells = new List <CellView>(); for (int j = 0; j < _gridSize.y; j++) { GameObject pieceGO = _gridPieces.gameObject.AddChild(_piecePrefab); pieceGO.transform.localScale = Vector3.one; PieceView piece = pieceGO.GetComponent <PieceView>(); PieceDO pieceDo = data.GridList[i][j]; if (piece != null) { piece.Initialize(pieceDo); piece.transform.localPosition = new Vector3(PIECE_WIDTH * i - _offsetX, PIECE_HEIGHT * j - _offsetY); } GameObject cellGO = _gridCells.gameObject.AddChild(_cellPrefab); cellGO.transform.localScale = Vector3.one; cellGO.transform.localPosition = piece.transform.localPosition; cellGO.name = String.Format("cell {0}/{1}", i, j); CellView cell = cellGO.GetComponent <CellView>(); cell.Piece = piece; cell.Initialize(data.SelectCell); cells.Add(cell); } _cells.Add(cells); } SetNeighbors(); _piecePrefab.SetActive(false); _cellPrefab.SetActive(false); _currentScore = 0; _scoreCounter = new NguiLabelCounterInt(_scoreLabel); _scoreCounter.SetInitialCounterValue(_currentScore); _currentDiamondScore = 0; _diamondProgressBar.value = 0; _addDiamondPiece = data.AddDiamondPiece; }
void Awake() { cells = new Cell[xSize * ySize]; for (int x = 0; x < xSize; x++) { for (int y = 0; y < ySize; y++) { GameObject cellObject = (GameObject)Instantiate(cellPrefab); cellObject.transform.parent = transform; cells[ySize * x + y] = cellObject.GetComponent <Cell>(); cells[ySize * x + y].Initialize(x, y, this); CellView cellView = cellObject.GetComponent <CellView>(); cellView.Initialize(cells[ySize * x + y]); } } for (int i = 0; i < cells.Length; i++) { cells[i].InitializeAdjacentCells(this); } }