コード例 #1
0
ファイル: MapManage.cs プロジェクト: linxiubao/UniShader
    // 注册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);
        }
    }
コード例 #2
0
ファイル: MapManage.cs プロジェクト: linxiubao/UniShader
    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;
    }
コード例 #3
0
ファイル: HeroToy.cs プロジェクト: linxiubao/UniShader
    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);
                }
            }
        }
    }
コード例 #4
0
ファイル: MapManage.cs プロジェクト: linxiubao/UniShader
 public Cell getCell(ref CellPos posCell)
 {
     if (!checkCellValid(ref posCell))
     {
         return null;
     }
     return m_arrCell[posCell.x, posCell.y];
 }
コード例 #5
0
ファイル: MapManage.cs プロジェクト: linxiubao/UniShader
    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;
    }
コード例 #6
0
ファイル: MapManage.cs プロジェクト: linxiubao/UniShader
    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;
}
コード例 #7
0
ファイル: MapManage.cs プロジェクト: linxiubao/UniShader
    public void leaveCell(Toy pToy, ref CellPos posCell)
    {
        if (!checkCellValid(ref posCell))
        {
            return;
        }

        Cell pCell = getCell(ref posCell);
        if (null != pCell)
        {
            pCell.leaveCell(pToy);
        }
    }