diff --git a/Assets/Scripts/mapExporter.py b/Assets/Scripts/mapExporter.py index 0c4cb78..43de991 100644 --- a/Assets/Scripts/mapExporter.py +++ b/Assets/Scripts/mapExporter.py @@ -27,7 +27,7 @@ def createCells(cellSize, mapSize, height, land): for i in range(numCells): xId = i % cellsByDim[0] - yId = i / (cellsByDim[0] * cellsByDim[2]) + yId = int(i / (cellsByDim[0] * cellsByDim[2])) zId = (int(i / cellsByDim[0])) % cellsByDim[2] cp = initPos + np.array([xId * cellSize[0], -yId * cellSize[1], zId * cellSize[2]]) cellPos.append(cp) @@ -37,10 +37,6 @@ def createCells(cellSize, mapSize, height, land): cellsStr += '},\nimpassible = {\n' for i in range(numCells): - xId = i % cellsByDim[0] - yId = i / (cellsByDim[0] * cellsByDim[2]) - zId = (i / cellsByDim[0]) % cellsByDim[2] - waterbodyId = -1 impassible = False @@ -131,7 +127,7 @@ content += '\t\talbedoMap = "' + baseFilename + '.jpg",\n' terrDim = np.array([terrain.dimensions.x, terrain.dimensions.z, terrain.dimensions.y]); maxTurnAngles = [.1] -sizes = [(14, 0, 14), (14, 6, 14)] +sizes = [(7, 0, 7), (7, 6, 7)] content += '\t\tsize = {x = ' + str(terrDim[0]) + ', y = ' + str(terrDim[1]) + ', z = ' + str(terrDim[2]) + '},\n' content += '\t\t' + createCells(sizes[0], terrDim, 0, True) + '\n' diff --git a/activeGameState.cpp b/activeGameState.cpp index aa099dd..4d1480d 100755 --- a/activeGameState.cpp +++ b/activeGameState.cpp @@ -247,7 +247,8 @@ namespace battleship{ for(int j = 1; j < map->getNumTerrainObjects(); j++){ if(map->isPointWithinTerrainObject(u->getPos(), j) && map->isPointWithinTerrainObject(o.targets[i].pos, j)){ vector res; - Ray::retrieveCollisions(u->getPos(), Vector3(0, -1, 0), map->getTerrainObject(0).node->getChild(0), res); + Vector3 pos = u->getPos(); + Ray::retrieveCollisions(Vector3(pos.x, 100, pos.z), Vector3(0, -1, 0), map->getTerrainObject(0).node->getChild(0), res); Ray::sortResults(res); o.targets[i].pos.y = res[0].pos.y + depth * (map->getTerrainObject(j).pos.y - res[0].pos.y); break; diff --git a/map.cpp b/map.cpp index 927922a..3dcd04c 100755 --- a/map.cpp +++ b/map.cpp @@ -172,7 +172,7 @@ namespace battleship{ } void Map::load(string mapName) { - cellSize = Vector3(14, 6, 14); + cellSize = Vector3(7, 6, 7); this->mapName = mapName; LuaManager *luaManager = LuaManager::getSingleton(); diff --git a/unit.cpp b/unit.cpp index a4ebd66..775c6d8 100755 --- a/unit.cpp +++ b/unit.cpp @@ -175,7 +175,7 @@ namespace battleship{ advance(movementAmmount); } - if(fabs(pos.y - pathPoints[0].y) > destOffset){ + if(fabs(pos.y - pathPoints[0].y) > 0.5 * height){ float dist = pos.y - pathPoints[0].y; float movementAmmount = (speed > fabs(dist) ? dist : speed); @@ -185,7 +185,9 @@ namespace battleship{ advance(movementAmmount, MoveDir::UP); } - if(pos.getDistanceFrom(type != UnitType::UNDERWATER ? linDest : pathPoints[0]) <= destOffset) + if(type != UnitType::UNDERWATER && pos.getDistanceFrom(linDest) <= destOffset) + pathPoints.erase(pathPoints.begin()); + else if(type == UnitType::UNDERWATER && fabs(pos.y - pathPoints[0].y) < 0.5 * height && pos.getDistanceFrom(linDest) <= destOffset) pathPoints.erase(pathPoints.begin()); }