implemented unit factory

improved map loading
This commit is contained in:
devZoGok
2023-01-13 19:52:00 +02:00
parent f91592712f
commit 6a96bafdb7
26 changed files with 197 additions and 53 deletions
+2 -16
View File
@@ -9,7 +9,7 @@
#include "consoleCommand.h"
#include "inGameAppState.h"
#include "player.h"
#include "engineer.h"
#include "unitFactory.h"
using namespace std;
using namespace vb01;
@@ -70,20 +70,6 @@ namespace battleship{
void ConsoleCommand::executeAddUnit(int playerId, int unitId, Vector3 pos, Quaternion rot) {
Player* player = Map::getSingleton()->getPlayer(playerId);
Vehicle *vehicle = nullptr;
LuaManager *luaManager = LuaManager::getSingleton();
int unitClass = luaManager->getIntFromTable("unitClass", vector<Index>{Index(unitId + 1)});
switch((UnitClass)unitClass){
case UnitClass::ENGINEER:
vehicle = new Engineer(player, unitId, pos, rot);
break;
default:
vehicle = new Vehicle(player, unitId, pos, rot);
break;
}
player->addUnit(vehicle);
player->addUnit(UnitFactory::createUnit(player, unitId, pos, rot));
}
}