mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
added y axis map cells checking for adjacency
This commit is contained in:
@@ -47,8 +47,8 @@ namespace battleship{
|
||||
std::string mapName;
|
||||
std::vector<WaterBody> waterBodies;
|
||||
//TODO replace hardcoded values
|
||||
vb01::Vector3 size = vb01::Vector3(100, 20, 100);
|
||||
float bottom = 13;
|
||||
vb01::Vector3 size = vb01::Vector3(100, 30, 100);
|
||||
float bottom = 30;
|
||||
|
||||
Map(){}
|
||||
void loadSkybox(gameBase::LuaManager*);
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
#include "mapTest.h"
|
||||
#include "map.h"
|
||||
|
||||
namespace battleship{
|
||||
using namespace vb01;
|
||||
|
||||
void MapTest::setUp(){
|
||||
}
|
||||
|
||||
void MapTest::tearDown(){
|
||||
}
|
||||
|
||||
void MapTest::testGenerateWeights(){
|
||||
Map *map = Map::getSingleton();
|
||||
Vector3 mapSize = map->getSize(), cellSize = Vector3(6, 1, 6);
|
||||
int cellsByDim[3] = {
|
||||
int(mapSize.x / cellSize.x),
|
||||
int(mapSize.y / cellSize.y),
|
||||
int(mapSize.z / cellSize.z)
|
||||
};
|
||||
int numCells = cellsByDim[0] * cellsByDim[1] * cellsByDim[2];
|
||||
|
||||
u32 **weights = new u32*[numCells];
|
||||
|
||||
for(int i = 0; i < numCells; i++)
|
||||
weights[i] = new u32[numCells];
|
||||
|
||||
map->generateWeights(weights, cellSize, UnitType::UNDERWATER, Vector3::VEC_ZERO, 60000);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef MAP_TEST_H
|
||||
#define MAP_TEST_H
|
||||
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
namespace battleship{
|
||||
class MapTest : public CppUnit::TestFixture{
|
||||
CPPUNIT_TEST_SUITE(MapTest);
|
||||
CPPUNIT_TEST(testGenerateWeights);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
MapTest(){}
|
||||
void testGenerateWeights();
|
||||
void setUp();
|
||||
void tearDown();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -302,6 +302,13 @@ namespace battleship{
|
||||
else if(0 < xId && xId < cellsByDim[0] - 1 && abs(j - i) == 1)
|
||||
adjacent = true;
|
||||
|
||||
if(yId == 0 && j - i == cellsByDim[0] * cellsByDim[2])
|
||||
adjacent = true;
|
||||
else if(0 < yId && yId < cellsByDim[1] - 1 && abs(j - i) == cellsByDim[0] * cellsByDim[2])
|
||||
adjacent = true;
|
||||
else if(yId == cellsByDim[1] - 1 && j - i == -(cellsByDim[0] * cellsByDim[2]))
|
||||
adjacent = true;
|
||||
|
||||
if(zId == 0 && j - i == cellsByDim[0])
|
||||
adjacent = true;
|
||||
else if(zId == cellsByDim[2] - 1 && j - i == -cellsByDim[0])
|
||||
@@ -346,11 +353,11 @@ namespace battleship{
|
||||
Map *map = Map::getSingleton();
|
||||
|
||||
Vector3 mapSize = map->getSize();
|
||||
Vector3 cellSize = Vector3(eps, (type == UnitType::UNDERWATER ? int(mapSize.y / height) : 0), eps);
|
||||
Vector3 cellSize = Vector3(eps, (type == UnitType::UNDERWATER ? (mapSize.y / height) : 0), eps);
|
||||
|
||||
int cellsByDim[3] = {
|
||||
int(mapSize.x / cellSize.x),
|
||||
(cellSize.y == 0 ? 1 : int(mapSize.y / cellSize.y)),
|
||||
(cellSize.y == 0 ? 1 : cellSize.y),
|
||||
int(mapSize.z / cellSize.z)
|
||||
};
|
||||
int numCells = cellsByDim[0] * cellsByDim[1] * cellsByDim[2];
|
||||
|
||||
Reference in New Issue
Block a user