// 注册cell的监听者 public void regCell(ref CellPos posCell, ICellListener pListener) { if (!checkCellValid(ref posCell)) { return; } Cell pCell = getCell(ref posCell); if (null != pCell) { pCell.RegLister(pListener); } }
public void init() { if (m_bInit) { this.reset(); return; } int i; int j; for (i = 0; i < MAP_ROWS; ++i) { for (j = 0; j < MAP_COLS; ++j) { CellPos posCell = new CellPos(i, j); Cell pCell = createCell(ref posCell); m_arrCell[i, j] = pCell; } } m_bInit = true; }
private void listenCell() { if (null == m_pHeroData) { return; } Vector2 vecCellPos = this.getCellPos(); CellPos posCell = new CellPos((int)vecCellPos.x, (int)vecCellPos.y); posCell.x = -1; int i; for (i = 0; i < MapManage.MAP_ROWS; ++i) { posCell.x += 1; if (MapManage.Instance().checkCellValid(ref posCell)) { Cell pCell = MapManage.Instance().getCell(ref posCell); if (null != pCell) { pCell.RegLister(this); } } } }
public Cell getCell(ref CellPos posCell) { if (!checkCellValid(ref posCell)) { return null; } return m_arrCell[posCell.x, posCell.y]; }
public Cell createCell(ref CellPos pos) { if (!checkCellValid(ref pos)) { return null; } Cell pCell = new Cell(); if (null != pCell) { pCell.init(ref pos); } return pCell; }
public bool checkCellValid(ref CellPos pos) { if (pos.x < 0 || pos.y < 0 || pos.x >= MAP_ROWS || pos.y >= MAP_COLS) { return false; } return true; }
public void leaveCell(Toy pToy, ref CellPos posCell) { if (!checkCellValid(ref posCell)) { return; } Cell pCell = getCell(ref posCell); if (null != pCell) { pCell.leaveCell(pToy); } }