diff --git a/Assets/Models/Maps/222/222.lua b/Assets/Models/Maps/222/222.lua index b84b39f..fcb32c2 100644 --- a/Assets/Models/Maps/222/222.lua +++ b/Assets/Models/Maps/222/222.lua @@ -2,14 +2,12 @@ map = { numWaterBodies = 0, size = {x = 123.000000, y = 100, z = 123.000000}, impassibleNodeValue = 65535, -numPlayers = 1, -numSpawnPoints = 1, spawnPoints = { {x = -50.000000, y = 0.000000, z = -50.000000}, +{x = 0.000000, y = 0.000000, z = 0.000000}, }, players = { { -numResourceDeposits = 12, resourceDeposits = { {id = 0, pos = {x = -2.211494, y = 0.000000, z = -10.615765}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}}, {id = 0, pos = {x = -2.211494, y = 0.000000, z = -10.615765}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}}, @@ -24,10 +22,15 @@ resourceDeposits = { {id = 0, pos = {x = -5.240124, y = 0.000004, z = 11.061106}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}}, {id = 0, pos = {x = -5.381660, y = 0.000004, z = 11.083004}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}}, }, -numUnits = 1, units = { {id = 3, pos = {x = -50.000000, y = 0.000000, z = -50.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}}, } +}, +{ + resourceDeposits = {}, + units = { + {id = 3, pos = {x = 0.000000, y = 0.000000, z = 0.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}} + } } }, numCells = 289, diff --git a/map.cpp b/map.cpp index 17755a5..a6d562f 100755 --- a/map.cpp +++ b/map.cpp @@ -124,7 +124,7 @@ namespace battleship{ } } - void Map::loadPlayerGameObjects(Player *player){ + void Map::loadPlayerGameObjects(){ AssetManager *assetManager = AssetManager::getSingleton(); string path = GameManager::getSingleton()->getPath(); assetManager->load(path + DEFAULT_TEXTURE); @@ -138,23 +138,22 @@ namespace battleship{ int numPlayers = SOL_LUA_VIEW["numPlayers"]; for(int i = 0; i < numPlayers; i++){ - if(i == 0){ - string resDepInd = "resourceDeposits"; - SOL_LUA_VIEW.script("numResourceDeposits = #" + mapTable + "." + playerInd + "[" + to_string(i + 1) + "]." + resDepInd); - int numNpcObjs = SOL_LUA_VIEW["numResourceDeposits"]; + string resDepInd = "resourceDeposits"; + SOL_LUA_VIEW.script("numResourceDeposits = #" + mapTable + "." + playerInd + "[" + to_string(i + 1) + "]." + resDepInd); + int numNpcObjs = SOL_LUA_VIEW["numResourceDeposits"]; + Player *player = Game::getSingleton()->getPlayer(i); - for(int j = 0; j < numNpcObjs; j++){ - sol::table npcObjTable = SOL_LUA_VIEW[mapTable][playerInd][i + 1][resDepInd][j + 1]; - int id = npcObjTable["id"]; + for(int j = 0; j < numNpcObjs; j++){ + sol::table npcObjTable = SOL_LUA_VIEW[mapTable][playerInd][i + 1][resDepInd][j + 1]; + int id = npcObjTable["id"]; - sol::table posTable = npcObjTable["pos"]; - Vector3 pos = Vector3(posTable["x"], posTable["y"], posTable["z"]); + sol::table posTable = npcObjTable["pos"]; + Vector3 pos = Vector3(posTable["x"], posTable["y"], posTable["z"]); - sol::table rotTable = npcObjTable["rot"]; - Quaternion rot = Quaternion(rotTable["w"], rotTable["x"], rotTable["y"], rotTable["z"]); + sol::table rotTable = npcObjTable["rot"]; + Quaternion rot = Quaternion(rotTable["w"], rotTable["x"], rotTable["y"], rotTable["z"]); - player->addResourceDeposit(GameObjectFactory::createResourceDeposit(player, id, pos, rot)); - } + player->addResourceDeposit(GameObjectFactory::createResourceDeposit(player, id, pos, rot)); } //int spawnPointId = SOL_LUA_STATE[mapTable]["spawnPointInd"][i + 1][spawnPointId]; diff --git a/map.h b/map.h index 5280b9a..951ebc2 100755 --- a/map.h +++ b/map.h @@ -48,7 +48,7 @@ namespace battleship{ void unload(); int getCellId(vb01::Vector3); bool isPointWithinTerrainObject(vb01::Vector3, int); - void loadPlayerGameObjects(Player*); + void loadPlayerGameObjects(); inline std::string getMapName(){return mapName;} inline vb01::Node* getNodeParent(){return terrainNode;} inline vb01::Vector3 getCellSize(){return CELL_SIZE;} diff --git a/mapEditorAppState.cpp b/mapEditorAppState.cpp index 7d317ad..ebf1f17 100644 --- a/mapEditorAppState.cpp +++ b/mapEditorAppState.cpp @@ -63,11 +63,10 @@ namespace battleship{ else{ int numPlayers = map->getNumSpawnPoints(); - for(int i = 0; i < numPlayers; i++){ - Player *player = new Player(0, 0, 0, Vector3(1, 1, 1)); - map->loadPlayerGameObjects(player); - addPlayer(player); - } + for(int i = 0; i < numPlayers; i++) + addPlayer(new Player(0, 0, 0, Vector3(1, 1, 1))); + + map->loadPlayerGameObjects(); } } diff --git a/playButton.cpp b/playButton.cpp index b6cab8a..7be1f3f 100644 --- a/playButton.cpp +++ b/playButton.cpp @@ -39,11 +39,11 @@ namespace battleship{ for(int i = 0; i < numPlayers; i++){ bool cpuPlayer = (i < numPlayers - 1); string name = (cpuPlayer ? "CPU player #" + to_string(i) : "Player"); - Player *player = new Player(0, 0, i, Vector3(1, 1, 1), cpuPlayer, map->getSpawnPoint(i), name); - map->loadPlayerGameObjects(player); - Game::getSingleton()->addPlayer(player); + Game::getSingleton()->addPlayer(new Player(0, 0, i, Vector3(1, 1, 1), cpuPlayer, map->getSpawnPoint(i), name)); } + map->loadPlayerGameObjects(); + ConcreteGuiManager::getSingleton()->readLuaScreenScript("inGame.lua"); StateManager *stateManager = GameManager::getSingleton()->getStateManager();