Ejemplo n.º 1
0
        public int GetNeighbor(int index, eNeighborDirection neighborDirection)
        {
            Vector3 neighborPos = GetCellCenter(index);

            switch (neighborDirection)
            {
            case eNeighborDirection.kLeft:
                ConvertUtils.AccumulateH(ref neighborPos, -m_cellSize);
                break;

            case eNeighborDirection.kTop:
                ConvertUtils.AccumulateV(ref neighborPos, m_cellSize);
                break;

            case eNeighborDirection.kRight:
                ConvertUtils.AccumulateH(ref neighborPos, m_cellSize);
                break;

            case eNeighborDirection.kBottom:
                ConvertUtils.AccumulateV(ref neighborPos, -m_cellSize);
                break;

            default:
                System.Diagnostics.Debug.Assert(false);
                break;
            }
            ;

            int neighborIndex = GetCellIndex(neighborPos);

            if (!IsInBounds(neighborIndex))
            {
                neighborIndex = (int)eNeighborDirection.kNoNeighbor;
            }

            return(neighborIndex);
        }
Ejemplo n.º 2
0
        private int GetNeighbor(int index, eNeighborDirection neighborDirection)
        {
            Vector3 neighborPos = GetCellCenter(index);

            switch (neighborDirection)
            {
            case eNeighborDirection.kLeft:
                neighborPos.x -= m_cellSize;
                break;

            case eNeighborDirection.kTop:
                neighborPos.z += m_cellSize;
                break;

            case eNeighborDirection.kRight:
                neighborPos.x += m_cellSize;
                break;

            case eNeighborDirection.kBottom:
                neighborPos.z -= m_cellSize;
                break;

            default:
                System.Diagnostics.Debug.Assert(false);
                break;
            }
            ;

            int neighborIndex = GetCellIndex(neighborPos);

            if (!IsInBounds(neighborIndex))
            {
                neighborIndex = (int)eNeighborDirection.kNoNeighbor;
            }

            return(neighborIndex);
        }
Ejemplo n.º 3
0
	    private int GetNeighbor(int index, eNeighborDirection neighborDirection)
	    {
			Vector3 neighborPos = GetCellCenter(index);
			
	        switch (neighborDirection)
	        {
	            case eNeighborDirection.kLeft:
					neighborPos.x -= m_cellSize;
	                break;
	            case eNeighborDirection.kTop:
					neighborPos.z += m_cellSize;
	                break;
	            case eNeighborDirection.kRight:
					neighborPos.x += m_cellSize;
	                break;
	            case eNeighborDirection.kBottom:
					neighborPos.z -= m_cellSize;
	                break;
	            default:
	                System.Diagnostics.Debug.Assert(false);
	                break;
	        };
			
			int neighborIndex = GetCellIndex(neighborPos);
			if ( !IsInBounds(neighborIndex) )
			{
				neighborIndex = (int)eNeighborDirection.kNoNeighbor;
			}
	
	        return neighborIndex;
	    }