private MapCube CheckNext(MapCube _mapCube, MapCube.EDirection _direction) { int xIndex = _mapCube.m_X; int yIndex = _mapCube.m_Y; MapCube nextMapCube = null; MapCube.EDirection checkDirection = MapCube.EDirection.eUp; if (_direction == MapCube.EDirection.eUp) { yIndex = yIndex - 1; if (yIndex < 0) { return(null); } nextMapCube = m_Maps[xIndex, yIndex]; checkDirection = MapCube.EDirection.eDown; } else if (_direction == MapCube.EDirection.eDown) { yIndex = yIndex + 1; if (yIndex >= m_MapMaxY) { return(null); } nextMapCube = m_Maps[xIndex, yIndex]; checkDirection = MapCube.EDirection.eUp; } else if (_direction == MapCube.EDirection.eLeft) { xIndex = xIndex - 1; if (xIndex < 0) { return(null); } nextMapCube = m_Maps[xIndex, yIndex]; checkDirection = MapCube.EDirection.eRight; } else if (_direction == MapCube.EDirection.eRight) { xIndex = xIndex + 1; if (xIndex >= m_MapMaxX) { return(null); } nextMapCube = m_Maps[xIndex, yIndex]; checkDirection = MapCube.EDirection.eLeft; } if (nextMapCube.CheckNextMove(checkDirection, _mapCube.m_Cost) == false) { nextMapCube = null; } return(nextMapCube); }