mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
implemented Lua manager and unit data manager
This commit is contained in:
@@ -10,3 +10,6 @@
|
||||
[submodule "external/vb01"]
|
||||
path = external/vb01
|
||||
url = https://github.com/devZoGok/vb01
|
||||
[submodule "external/lua"]
|
||||
path = external/lua
|
||||
url = https://github.com/lua/lua
|
||||
|
||||
+7
-2
@@ -7,13 +7,14 @@ cmake_policy(SET CMP0015 NEW)
|
||||
set(states activeGameState.cpp inGameAppState.cpp guiAppState.cpp)
|
||||
set(util util.cpp binds.h)
|
||||
set(gui tooltip.cpp optionsButton.cpp exitButton.cpp consoleCommand.cpp)
|
||||
set(core gameManager.cpp main.cpp)
|
||||
set(core gameManager.cpp luaManager.cpp main.cpp)
|
||||
set(ships vessel.cpp destroyer.cpp cruiser.cpp aircraftCarrier.cpp submarine.cpp)
|
||||
set(projectiles projectile.cpp guidedMissile.cpp depthCharge.cpp missile.cpp shell.cpp torpedo.cpp)
|
||||
set(aircraft jet.cpp demoJet.cpp missileJet.cpp)
|
||||
set(fx explosion.cpp)
|
||||
set(content player.cpp unit.cpp map.cpp ${ships} ${projectiles} ${aircraft} ${fx})
|
||||
set(content player.cpp unitDataManager.cpp unit.cpp map.cpp ${ships} ${projectiles} ${aircraft} ${fx})
|
||||
|
||||
set(LUA_DIR external/lua)
|
||||
set(SFML_DIR external/SFML)
|
||||
set(VB01_DIR external/vb01)
|
||||
set(FREETYPE_DIR ${VB01_DIR}/external/freetype)
|
||||
@@ -53,6 +54,10 @@ set(GLFW_LIB_DIR build/${GLFW_DIR}/src)
|
||||
include_directories(${GLFW_DIR}/include/GLFW)
|
||||
target_link_directories(${GAME_NAME} PUBLIC ${GLFW_LIB_DIR})
|
||||
|
||||
set(LUA_LIB_DIR ${LUA_DIR}/testes/libs)
|
||||
include_directories(${LUA_DIR})
|
||||
|
||||
target_link_libraries(${GAME_NAME} lua)
|
||||
target_link_libraries(${GAME_NAME} vb01)
|
||||
target_link_libraries(${GAME_NAME} vb01Gui)
|
||||
target_link_libraries(${GAME_NAME} gameBase)
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
PATH = "/home/dominykas/c++/Battleship/Assets/"
|
||||
DEFAULT_TEXTURE = PATH .. "Textures/defaultTexture.jpg"
|
||||
|
||||
numAppStates = 3
|
||||
numMaxBinds = 23
|
||||
numBinds = {12, 1, 23}
|
||||
numConfBinds = {0, 1, 13}
|
||||
@@ -0,0 +1,272 @@
|
||||
--dofile("defConfigs.lua")
|
||||
|
||||
numUnits = 11
|
||||
UnitType = {VESSEL = 0, DESTROYER = 1, CRUISER = 2, AIRCRAFT_CARRIER = 3, SUBMARINE = 4, MISSILE_JET = 5, DEMO_JET = 6};
|
||||
unitType = {
|
||||
UnitType.VESSEL, UnitType.VESSEL,
|
||||
UnitType.DESTROYER, UnitType.DESTROYER,
|
||||
UnitType.CRUISER, UnitType.CRUISER,
|
||||
UnitType.AIRCRAFT_CARRIER, UnitType.AIRCRAFT_CARRIER,
|
||||
UnitType.SUBMARINE,
|
||||
UnitType.MISSILE_JET, UnitType.DEMO_JET
|
||||
};
|
||||
health = {500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500}
|
||||
speed = {.025, .025, .05, .05, .1, .1, .1, .1, .1, .1, .15}
|
||||
destinationOffset = {.75, .75, 1, 1, .1, .1, .1, .1, .1, .5, .5}
|
||||
anglePrecision = {.1, .1, .1, .1, .1, .1, .1, .1, .1, 3, 3}
|
||||
cost = {500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500}
|
||||
maxTurnAngle = {1, 1, .5, .5, 1, 1, .5, .5, 1, 2, 2}
|
||||
range = {15, 15, 14, 14, 13, 13, 12, 12,15,25}
|
||||
|
||||
unitCornerPoints = {
|
||||
{
|
||||
{x = .9, y = -1, z = -6},
|
||||
{x = -.9, y = -1, z = -6},
|
||||
{x = -.9, y = -1, z = 5.8},
|
||||
{x = .9, y = -1, z = 5.8},
|
||||
{x = .9, y = 3.5, z = -6},
|
||||
{x = -.9, y = 3.5, z = -6},
|
||||
{x = -.9, y = 3.5, z = 5.8},
|
||||
{x = .9, y = 3.5, z = 5.8}
|
||||
},
|
||||
{
|
||||
{x = .5, y = -.5, z = -7.05},
|
||||
{x = -.5, y = -.5, z = -7.05},
|
||||
{x = -.5, y = -.5, z = 6.4},
|
||||
{x = .5, y = -.5, z = 6.4},
|
||||
{x = .5, y = 3, z = -7.05},
|
||||
{x = -.5, y = 3, z = -7.05},
|
||||
{x = -.5, y = 3, z = 6.4},
|
||||
{x = .5, y = 3, z = 6.4}
|
||||
},
|
||||
{
|
||||
{x = .5, y = -.5, z = -3.4},
|
||||
{x = -.5, y = -.5, z = -3.4},
|
||||
{x = -.5, y = -.5, z = 3.4},
|
||||
{x = .5, y = -.4, z = 3.4},
|
||||
{x = .5, y = 2.1, z = -3.4},
|
||||
{x = -.5, y = 2, z = -3.4},
|
||||
{x = -.5, y = 2, z = 3.4},
|
||||
{x = .5, y = 2, z = 3.4}
|
||||
},
|
||||
{
|
||||
{x = .5, y = -.25, z = -4.8},
|
||||
{x = -.5, y = -.25, z = -4.8},
|
||||
{x = -.5, y = -.25, z = 4.7},
|
||||
{x = .5, y = -.25, z = 4.7},
|
||||
{x = .5, y = .8, z = -4.8},
|
||||
{x = -.5, y = .8, z = -4.8},
|
||||
{x = -.5, y = .8, z = 4.7},
|
||||
{x = .5, y = .8, z = 4.7}
|
||||
},
|
||||
{
|
||||
{x = .7, y = -.3, z = -4},
|
||||
{x = -.7, y = -.3, z = -4},
|
||||
{x = -.7, y = -.3, z = 3.4},
|
||||
{x = .7, y = -.3, z = 3.4},
|
||||
{x = .7, y = 2.9, z = -4},
|
||||
{x = -.7, y = 2.9, z = -4},
|
||||
{x = -.7, y = 2.9, z = 3.4},
|
||||
{x = .7, y = 2.9, z = 3.4}
|
||||
},
|
||||
{
|
||||
{x = .5, y = -.5, z = -6.1},
|
||||
{x = -.5, y = -.5, z = -6.1},
|
||||
{x = -.5, y = -.5, z = 5.2},
|
||||
{x = .5, y = -.5, z = 5.2},
|
||||
{x = .5, y = 2.2, z = -6.1},
|
||||
{x = -.5, y = 2.2, z = -6.1},
|
||||
{x = -.5, y = 2.2, z = 5.2},
|
||||
{x = .5, y = 2.2, z = 5.2}
|
||||
},
|
||||
{
|
||||
{x = 2, y = -.5, z = -10},
|
||||
{x = -2, y = -.5, z = -10},
|
||||
{x = -2, y = -.5, z = 9},
|
||||
{x = 2, y = -.5, z = 9},
|
||||
{x = 2, y = 5.5, z = -10},
|
||||
{x = -2, y = 5.5, z = -10},
|
||||
{x = -2, y = 5.5, z = 9},
|
||||
{x = 2, y = 5.5, z = 9}
|
||||
},
|
||||
{
|
||||
{x = 2, y = -1, z = -10},
|
||||
{x = -2, y = -1, z = -10},
|
||||
{x = -2, y = -1, z = 9},
|
||||
{x = 2, y = -1, z = 9},
|
||||
{x = 2, y = 4.5, z = -10},
|
||||
{x = -2, y = 4.5, z = -10},
|
||||
{x = -2, y = 4.5, z = 9},
|
||||
{x = 2, y = 4.5, z = 9}
|
||||
},
|
||||
{
|
||||
{x = .25, y = -.5, z = -2},
|
||||
{x = -.25, y = -.5, z = -2},
|
||||
{x = -.25, y = -.5, z = 3},
|
||||
{x = .25, y = -.5, z = 3},
|
||||
{x = .25, y = .7, z = -2},
|
||||
{x = -.25, y = .7, z = -2},
|
||||
{x = -.25, y = .7, z = 3},
|
||||
{x = .25, y = .7, z = 3}
|
||||
},
|
||||
{
|
||||
{x = .6, y =-.1, z =-1.3},
|
||||
{x = -.6, y =-.1, z =-1.3},
|
||||
{x = -.6, y =-.1, z =.8},
|
||||
{x = .6, y =-.1, z =.8},
|
||||
{x = .6, y =.3, z =-1.3},
|
||||
{x = -.6, y =.3, z =-1.3},
|
||||
{x = -.6, y =.3, z =.8},
|
||||
{x = .6, y =.3, z =.8}
|
||||
},
|
||||
{
|
||||
{x = .5, y =-.1, z =-1.3},
|
||||
{x = -.5, y =-.1, z =-1.3},
|
||||
{x = -.5, y =-.1, z =.7},
|
||||
{x = .5, y =-.1, z =.7},
|
||||
{x = .5, y =.15, z =-1.3},
|
||||
{x = -.5, y =.15, z =-1.3},
|
||||
{x = -.5, y =.15, z =.7},
|
||||
{x = .5, y =.15, z =.7}
|
||||
}
|
||||
};
|
||||
unitCuboidDimensions = {
|
||||
{
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1}
|
||||
},
|
||||
{
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1}
|
||||
},
|
||||
{
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1}
|
||||
},
|
||||
{
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1}
|
||||
},
|
||||
{
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1}
|
||||
},
|
||||
{
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1}
|
||||
},
|
||||
{
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1}
|
||||
},
|
||||
{
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1},
|
||||
{x = 1, y = 1, z = 1}
|
||||
},
|
||||
{
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1}
|
||||
},
|
||||
{
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1}
|
||||
},
|
||||
{
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1},
|
||||
{x = .1, y = .1, z = .1}
|
||||
}
|
||||
};
|
||||
|
||||
unitAxisLength = {8, 8,6,6,5, 5,8, 8, 7,2,2}
|
||||
lineOfSight = {5, 8, 4, 4, 3, 3, 6, 6, 3, 3, 8}
|
||||
name = {
|
||||
"Battleship", "Battleship",
|
||||
"Destroyer", "Destroyer",
|
||||
"Cruiser", "Cruiser",
|
||||
"Aircraft carrier", "Aircraft carrier",
|
||||
"Submarine",
|
||||
"Jet", "Jet"
|
||||
}
|
||||
meshPath = {
|
||||
"battleship00.vb", "battleship01.vb",
|
||||
"destroyer00.vb", "destroyer01.vb",
|
||||
"cruiser00.vb", "cruiser01.vb",
|
||||
"aircraftCarrier00.vb", "aircraftCarrier01.vb",
|
||||
"submarine.vb",
|
||||
"jet00.x", "jet01.x"
|
||||
}
|
||||
PATH = ""
|
||||
basePath = {
|
||||
PATH .. "Models/Battleships/", PATH .. "Models/Battleships/",
|
||||
PATH .. "Models/Destroyers/", PATH .. "Models/Destroyers/",
|
||||
PATH .. "Models/Cruisers/", PATH .. "Models/Cruisers/",
|
||||
PATH .. "Models/Aircraft carriers/", PATH .. "Models/Aircraft carriers/",
|
||||
PATH .. "Models/Submarines/",
|
||||
PATH .. "Models/Jets/", PATH .. "Models/Jets/"
|
||||
};
|
||||
+1
Submodule external/lua added at c33b1728ae
@@ -0,0 +1,79 @@
|
||||
#include "luaManager.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace battleship{
|
||||
static LuaManager *luaManager = nullptr;
|
||||
|
||||
LuaManager* LuaManager::getSingleton(){
|
||||
if(!luaManager) luaManager = new LuaManager();
|
||||
|
||||
return luaManager;
|
||||
}
|
||||
|
||||
LuaManager::LuaManager(){
|
||||
state = luaL_newstate();
|
||||
luaL_openlibs(state);
|
||||
}
|
||||
|
||||
void LuaManager::readFile(string file){
|
||||
if(luaL_dofile(state, file.c_str()) && lua_pcall(state, 0, 0, 0))
|
||||
cout << "Error reading Lua file" << file << "\n";
|
||||
}
|
||||
|
||||
int LuaManager::getInt(string varName){
|
||||
lua_getglobal(state, varName.c_str());
|
||||
int isNum;
|
||||
int var = (int)lua_tointegerx(state, -1, &isNum);
|
||||
lua_pop(state, 1);
|
||||
return var;
|
||||
}
|
||||
|
||||
void LuaManager::prepareTableForRetrieval(string table, vector<Index> &indices){
|
||||
lua_getglobal(state, table.c_str());
|
||||
|
||||
if(!lua_istable(state, -1))
|
||||
cout << table << " is not a table\n";
|
||||
|
||||
for(int i = 0; i < indices.size(); i++){
|
||||
if(indices[i].string)
|
||||
lua_pushstring(state, indices[i].index.c_str());
|
||||
else
|
||||
lua_pushnumber(state, atoi(indices[i].index.c_str()));
|
||||
|
||||
lua_gettable(state, -2);
|
||||
}
|
||||
}
|
||||
|
||||
int LuaManager::getIntFromTable(string table, vector<Index> indices){
|
||||
prepareTableForRetrieval(table, indices);
|
||||
|
||||
int isNum;
|
||||
int result = lua_tointegerx(state, -1, &isNum);
|
||||
|
||||
lua_pop(state, 1 + indices.size());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
float LuaManager::getFloatFromTable(string table, vector<Index> indices){
|
||||
prepareTableForRetrieval(table, indices);
|
||||
|
||||
int isNum;
|
||||
float result = lua_tonumberx(state, -1, &isNum);
|
||||
|
||||
lua_pop(state, 1 + indices.size());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
string LuaManager::getStringFromTable(string table, vector<Index> indices){
|
||||
prepareTableForRetrieval(table, indices);
|
||||
string result = lua_tostring(state, -1);
|
||||
lua_pop(state, 1 + indices.size());
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef LUA_MANAGER_H
|
||||
#define LUA_MANAGER_H
|
||||
|
||||
#include <lua.hpp>
|
||||
#include <lauxlib.h>
|
||||
#include <lualib.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace battleship{
|
||||
class LuaManager{
|
||||
public:
|
||||
struct Index{
|
||||
std::string index;
|
||||
bool string;
|
||||
|
||||
Index(std::string index, bool string){
|
||||
this->index = index;
|
||||
this->string = string;
|
||||
}
|
||||
};
|
||||
|
||||
static LuaManager* getSingleton();
|
||||
inline lua_State* getState(){return state;}
|
||||
void readFile(std::string);
|
||||
int getInt(std::string);
|
||||
int getIntFromTable(std::string, std::vector<Index>);
|
||||
float getFloatFromTable(std::string, std::vector<Index>);
|
||||
std::string getStringFromTable(std::string, std::vector<Index>);
|
||||
private:
|
||||
LuaManager();
|
||||
void prepareTableForRetrieval(std::string, std::vector<Index>&);
|
||||
|
||||
lua_State *state = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,76 @@
|
||||
#include "unitDataManager.h"
|
||||
#include "luaManager.h"
|
||||
|
||||
#include <lauxlib.h>
|
||||
#include <lualib.h>
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace vb01;
|
||||
|
||||
namespace battleship{
|
||||
typedef LuaManager::Index Index;
|
||||
|
||||
UnitDataManager *unitDataManager = nullptr;
|
||||
|
||||
UnitDataManager* UnitDataManager::getSingleton(){
|
||||
if(!unitDataManager)
|
||||
unitDataManager = new UnitDataManager();
|
||||
|
||||
return unitDataManager;
|
||||
}
|
||||
|
||||
UnitDataManager::UnitDataManager(){
|
||||
LuaManager *luaManager = LuaManager::getSingleton();
|
||||
luaManager->readFile("../Scripts/unitData.lua");
|
||||
|
||||
numUnits = luaManager->getInt("numUnits");
|
||||
|
||||
health = new int[numUnits];
|
||||
speed = new float[numUnits];
|
||||
destinationOffset = new float[numUnits];
|
||||
anglePrecision = new float[numUnits];
|
||||
cost = new int[numUnits];
|
||||
maxTurnAngle = new float[numUnits];
|
||||
range = new float[numUnits];
|
||||
unitAxisLength = new float[numUnits];
|
||||
lineOfSight = new float[numUnits];
|
||||
name = new string[numUnits];
|
||||
meshPath = new string[numUnits];
|
||||
basePath = new string[numUnits];
|
||||
unitCornerPoints = new Vector3*[numUnits];
|
||||
unitCuboidDimensions = new Vector3*[numUnits];
|
||||
|
||||
for(int i = 0; i < numUnits; i++){
|
||||
health[i] = luaManager->getIntFromTable("health", vector<Index>{Index(to_string(i + 1), false)});
|
||||
speed[i] = luaManager->getFloatFromTable("speed", vector<Index>{Index(to_string(i + 1), false)});
|
||||
destinationOffset[i] = luaManager->getFloatFromTable("destinationOffset", vector<Index>{Index(to_string(i + 1), false)});
|
||||
anglePrecision[i] = luaManager->getFloatFromTable("anglePrecision", vector<Index>{Index(to_string(i + 1), false)});
|
||||
cost[i] = luaManager->getIntFromTable("cost", vector<Index>{Index(to_string(i + 1), false)});
|
||||
maxTurnAngle[i] = luaManager->getFloatFromTable("maxTurnAngle", vector<Index>{Index(to_string(i + 1), false)});
|
||||
range[i] = luaManager->getFloatFromTable("range", vector<Index>{Index(to_string(i + 1), false)});
|
||||
unitAxisLength[i] = luaManager->getFloatFromTable("unitAxisLength", vector<Index>{Index(to_string(i + 1), false)});
|
||||
lineOfSight[i] = luaManager->getFloatFromTable("lineOfSight", vector<Index>{Index(to_string(i + 1), false)});
|
||||
name[i] = luaManager->getStringFromTable("name", vector<Index>{Index(to_string(i + 1), false)});
|
||||
meshPath[i] = luaManager->getStringFromTable("meshPath", vector<Index>{Index(to_string(i + 1), false)});
|
||||
basePath[i] = luaManager->getStringFromTable("basePath", vector<Index>{Index(to_string(i + 1), false)});
|
||||
|
||||
unitCornerPoints[i] = new Vector3[8];
|
||||
unitCuboidDimensions[i] = new Vector3[8];
|
||||
|
||||
for(int j = 0; j < 8; j++){
|
||||
float cornerX = luaManager->getFloatFromTable("unitCornerPoints", vector<Index>{Index(to_string(i + 1), false), Index(to_string(j + 1), false), Index("x", true)});
|
||||
float cornerY = luaManager->getFloatFromTable("unitCornerPoints", vector<Index>{Index(to_string(i + 1), false), Index(to_string(j + 1), false), Index("y", true)});
|
||||
float cornerZ = luaManager->getFloatFromTable("unitCornerPoints", vector<Index>{Index(to_string(i + 1), false), Index(to_string(j + 1), false), Index("z", true)});
|
||||
unitCornerPoints[i][j] = Vector3(cornerX, cornerY, cornerZ);
|
||||
|
||||
float dimX = luaManager->getFloatFromTable("unitCuboidDimensions", vector<Index>{Index(to_string(i + 1), false), Index(to_string(j + 1), false), Index("x", true)});
|
||||
float dimY = luaManager->getFloatFromTable("unitCuboidDimensions", vector<Index>{Index(to_string(i + 1), false), Index(to_string(j + 1), false), Index("y", true)});
|
||||
float dimZ = luaManager->getFloatFromTable("unitCuboidDimensions", vector<Index>{Index(to_string(i + 1), false), Index(to_string(j + 1), false), Index("z", true)});
|
||||
unitCuboidDimensions[i][j] = Vector3(dimX, dimY, dimZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#ifndef UNIT_DATA_MANAGER_H
|
||||
#define UNIT_DATA_MANAGER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <vector.h>
|
||||
|
||||
namespace battleship{
|
||||
class UnitDataManager{
|
||||
public:
|
||||
static UnitDataManager* getSingleton();
|
||||
private:
|
||||
UnitDataManager();
|
||||
|
||||
enum class UnitType {VESSEL, DESTROYER, CRUISER, AIRCRAFT_CARRIER, SUBMARINE, MISSILE_JET, DEMO_JET};
|
||||
int numUnits;
|
||||
UnitType unitType;
|
||||
int *health;
|
||||
float *speed;
|
||||
float *destinationOffset;
|
||||
float *anglePrecision;
|
||||
int *cost;
|
||||
float *maxTurnAngle;
|
||||
float *range;
|
||||
vb01::Vector3 **unitCornerPoints;
|
||||
vb01::Vector3 **unitCuboidDimensions;
|
||||
float *unitAxisLength;
|
||||
float *lineOfSight;
|
||||
std::string *name;
|
||||
std::string *meshPath;
|
||||
std::string *basePath;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user