mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
Merge pull request #77 from devZoGok/imp-68-obj-lua-config
Imp 68 obj lua config
This commit is contained in:
@@ -83,7 +83,7 @@ function Player:issueBuildOrder()
|
||||
end
|
||||
|
||||
spawnPoint = self:getSpawnPoint()
|
||||
structure = GameObjectFactory.createUnit(self, 15, spawnPoint, Quaternion:new(1, 0, 0, 0), 0)
|
||||
structure = GameObjectFactory.createUnit(self, UnitId.LAND_FACTORY, spawnPoint, Quaternion:new(1, 0, 0, 0), 0)
|
||||
self:addUnit(structure)
|
||||
|
||||
self:issueOrder(1, Vector3:new(0, 0, 0), {Target:new(structure, Vector3:new(0, 0, 0))}, false)
|
||||
|
||||
@@ -1,47 +1,28 @@
|
||||
ProjectileId = {CRUISE_MISSILE = 0, TORPEDO = 1}
|
||||
ProjectileClass = {CRUISE_MISSILE = 0, TORPEDO = 1}
|
||||
|
||||
projectiles = {
|
||||
projectileClass = {
|
||||
ProjectileClass.CRUISE_MISSILE,
|
||||
ProjectileClass.TORPEDO,
|
||||
{
|
||||
projectileClass = ProjectileClass.CRUISE_MISSILE,
|
||||
size = {x = 1.2, y = 2.7, z = .54},
|
||||
speed = .5,
|
||||
rotAngle = .1,
|
||||
explosion = {damage = 100, radius = 20},
|
||||
directHitDamage = 450,
|
||||
rayLength = 1.25,
|
||||
name = "Cruise missile",
|
||||
basePath = PATH .. "Models/GameObjects/Projectiles/Missiles/",
|
||||
meshPath = "cruiseMissile.xml",
|
||||
},
|
||||
speed = {.5, .06},
|
||||
rotAngle = {.1, 0},
|
||||
explosion = {{damage = 100, radius = 20}, {damage = 20, radius = 3}},
|
||||
rayLength = {1.25, .75},
|
||||
directHitDamage = {450, 300},
|
||||
name = {
|
||||
"Cruise missile",
|
||||
"Torpedo"
|
||||
},
|
||||
basePath = {
|
||||
PATH .. "Models/GameObjects/Projectiles/Missiles/",
|
||||
PATH .. "Models/GameObjects/Projectiles/Torpedos/",
|
||||
},
|
||||
meshPath = {
|
||||
"cruiseMissile.xml",
|
||||
"torpedo.xml",
|
||||
},
|
||||
unitCornerPoints = {
|
||||
{
|
||||
{x = .592, y = -1.3475, z = -.2755},
|
||||
{x = -.592, y = -1.3475, z = -.2755},
|
||||
{x = -.592, y = -1.3475, z = .2755},
|
||||
{x = .592, y = -1.3475, z = .2755},
|
||||
{x = .592, y = 1.3475, z = -.2755},
|
||||
{x = -.592, y = 1.3475, z = -.2755},
|
||||
{x = -.592, y = 1.3475, z = .2755},
|
||||
{x = .592, y = 1.3475, z = .2755}
|
||||
},
|
||||
{
|
||||
{x = .1, y = -.796, z = -.1},
|
||||
{x = -.1, y = -.796, z = -.1},
|
||||
{x = -.1, y = -.796, z = .1},
|
||||
{x = .1, y = -.796, z = .1},
|
||||
{x = .1, y = .796, z = -.1},
|
||||
{x = -.1, y = .796, z = -.1},
|
||||
{x = -.1, y = .796, z = .1},
|
||||
{x = .1, y = .796, z = .1}
|
||||
}
|
||||
{
|
||||
projectileClass = ProjectileClass.TORPEDO,
|
||||
size = {x = .2, y = 1.6, z = .2},
|
||||
speed = .06,
|
||||
explosion = {damage = 20, radius = 3},
|
||||
directHitDamage = 450,
|
||||
rayLength = .75,
|
||||
name = "Torpedo",
|
||||
basePath = PATH .. "Models/GameObjects/Projectiles/Torpedos/",
|
||||
meshPath = "torpedo.xml",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
maxUnevenness = 0.5
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +0,0 @@
|
||||
units.speed = {.025, .025, .025, .025, .05, .05, .05, .1, .1, .1, .1, .1, .1, .15, .1, .1, .1}
|
||||
units.destinationOffset = {.75, .75, .75, .75, 1, 1, 1, .1, .1, .1, .1, .1, .5, .5, .75, .75}
|
||||
units.anglePrecision = {.1, .1, .1, .1, .1, .1, .1, .1, .1, .1, .1, .1, .2, .2, .1, .1, .1, .1, .1}
|
||||
units.maxTurnAngle = {.1, .1, .1, .1, .5, .5, .5, 1, 1, .5, .5, 1, 2, 2, .5, .5, .5, .5, .5}
|
||||
units.garrisonCategory = {1, 2, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}
|
||||
@@ -1,24 +1,9 @@
|
||||
resources = {
|
||||
meshPath = {
|
||||
"resource.xml"
|
||||
},
|
||||
name = {
|
||||
"Resource",
|
||||
},
|
||||
basePath = {
|
||||
PATH .. 'Models/GameObjects/Resources/'
|
||||
},
|
||||
unitCornerPoints = {
|
||||
{
|
||||
{x = 0, y = 0, z = 0},
|
||||
{x = 0, y = 0, z = 0},
|
||||
{x = 0, y = 0, z = 0},
|
||||
{x = 0, y = 0, z = 0},
|
||||
{x = 0, y = 0, z = 0},
|
||||
{x = 0, y = 0, z = 0},
|
||||
{x = 0, y = 0, z = 0},
|
||||
{x = 0, y = 0, z = 0},
|
||||
}
|
||||
},
|
||||
hitboxOffset = {{x = 0, y = 0, z = 0}}
|
||||
{
|
||||
name = 'Resource',
|
||||
size = {x = 0, y = 0, z = 0},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
basePath = PATH .. 'Models/GameObjects/Resources/',
|
||||
meshPath = 'resource.xml',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,51 +6,46 @@ gui = {
|
||||
{
|
||||
pos = {x = res.x - 200, y = res.y - 200},
|
||||
size = Size,
|
||||
name = 'Land factory',
|
||||
imagePath = '',
|
||||
guiType = GuiType.BUTTON,
|
||||
buttonType = ButtonType.BUILD,
|
||||
trigger = 76,
|
||||
structureId = 8
|
||||
structureId = UnitId.LAND_FACTORY
|
||||
},
|
||||
{
|
||||
pos = {x = res.x - Size.x - 200, y = res.y - 200},
|
||||
size = Size,
|
||||
name = 'Naval factory',
|
||||
imagePath = '',
|
||||
guiType = GuiType.BUTTON,
|
||||
buttonType = ButtonType.BUILD,
|
||||
trigger = 78,
|
||||
structureId = 9
|
||||
structureId = UnitId.NAVAL_FACTORY
|
||||
},
|
||||
{
|
||||
pos = {x = res.x - 2 * Size.x - 200, y = res.y - 200},
|
||||
size = {x = 100, y = 100},
|
||||
name = 'Market',
|
||||
imagePath = '',
|
||||
guiType = GuiType.BUTTON,
|
||||
buttonType = ButtonType.BUILD,
|
||||
trigger = 77,
|
||||
structureId = 10
|
||||
structureId = UnitId.MARKET
|
||||
},
|
||||
{
|
||||
pos = {x = res.x - 3 * Size.x - 200, y = res.y - 200},
|
||||
size = Size,
|
||||
name = 'Lab',
|
||||
imagePath = '',
|
||||
guiType = GuiType.BUTTON,
|
||||
buttonType = ButtonType.BUILD,
|
||||
trigger = 84,
|
||||
structureId = 11
|
||||
structureId = UnitId.LAB
|
||||
},
|
||||
{
|
||||
pos = {x = res.x - 4 * Size.x - 200, y = res.y - 200},
|
||||
size = Size,
|
||||
name = 'Point defense',
|
||||
imagePath = '',
|
||||
guiType = GuiType.BUTTON,
|
||||
buttonType = ButtonType.BUILD,
|
||||
trigger = 68,
|
||||
structureId = 12
|
||||
structureId = UnitId.POINT_DEFENSE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,21 +6,19 @@ gui = {
|
||||
{
|
||||
pos = {x = res.x - 200, y = res.y - 200},
|
||||
size = Size,
|
||||
name = 'Tank',
|
||||
imagePath = '',
|
||||
guiType = GuiType.BUTTON,
|
||||
buttonType = ButtonType.LAND_FACTORY_TRAIN,
|
||||
trigger = 84,
|
||||
unitId = 1
|
||||
unitId = UnitId.TANK
|
||||
},
|
||||
{
|
||||
pos = {x = res.x - Size.x - 200, y = res.y - 200},
|
||||
size = Size,
|
||||
name = 'Artillery',
|
||||
imagePath = '',
|
||||
guiType = GuiType.BUTTON,
|
||||
buttonType = ButtonType.LAND_FACTORY_TRAIN,
|
||||
trigger = 65,
|
||||
unitId = 2
|
||||
unitId = UnitId.ARTILLERY
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,10 @@ gui = {
|
||||
{
|
||||
pos = {x = res.x - 200, y = res.y - 200},
|
||||
size = {x = 100, y = 100},
|
||||
name = 'Transport',
|
||||
imagePath = '',
|
||||
guiType = GuiType.BUTTON,
|
||||
buttonType = ButtonType.NAVAL_FACTORY_TRAIN,
|
||||
trigger = 66,
|
||||
unitId = 4
|
||||
unitId = UnitId.SCOUT_TRANSPORT
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,244 +0,0 @@
|
||||
projectiles = {
|
||||
numberOfTypesOfWeapons = 2,
|
||||
g = 2.2,
|
||||
speed = {
|
||||
{
|
||||
{10,10,10,10,10,10,10,10,10,10,10}
|
||||
},
|
||||
{
|
||||
{10,10,10,10,10,10,10,10,10,10,10}
|
||||
},
|
||||
{
|
||||
{10, 10, 10, 10}
|
||||
},
|
||||
{
|
||||
{10, 10, 10, 10}
|
||||
},
|
||||
{
|
||||
{5,5}
|
||||
},
|
||||
{
|
||||
{7,7,7,7,7}
|
||||
},
|
||||
{},
|
||||
{},
|
||||
{.05},
|
||||
{
|
||||
{.1, .1},
|
||||
{.1, .1}
|
||||
}
|
||||
},
|
||||
length = {
|
||||
{
|
||||
{1,1,1,1,1,1,1,1,1,1,1,1,1}
|
||||
},
|
||||
{
|
||||
{1,1,1,1,1,1,1,1,1,1,1,1,1}
|
||||
},
|
||||
{
|
||||
{1,1,1,1}
|
||||
},
|
||||
{
|
||||
{1,1,1,1}
|
||||
},
|
||||
{
|
||||
{1,1}
|
||||
},
|
||||
{
|
||||
{1,1,1,1,1}
|
||||
},
|
||||
{},
|
||||
{},
|
||||
{
|
||||
{.5}
|
||||
},
|
||||
{
|
||||
{1,1},
|
||||
{1,1}
|
||||
},
|
||||
{}
|
||||
},
|
||||
scale = {
|
||||
{
|
||||
{1, 1, 1, .5, .5, .5, .5, .5, .5, .5, .5, .5, .5}
|
||||
},
|
||||
{
|
||||
{1, 1, 1, .23, .23, .23, .23, .23, .23, .23, .23, .23, .23}
|
||||
},
|
||||
{
|
||||
{.45, .45, .45, .45}
|
||||
},
|
||||
{
|
||||
{.5, .5, .5, .5}
|
||||
},
|
||||
{
|
||||
{.95, .95}
|
||||
},
|
||||
{
|
||||
{.6, .6, .6, .6, .6}
|
||||
}
|
||||
},
|
||||
pos = {
|
||||
{
|
||||
{
|
||||
{x = 0, y = 0, z = 1.05},
|
||||
{x = 0, y = 0, z = 1.05},
|
||||
{x = 0, y = 0, z = 1.05},
|
||||
{x = 0, y = 0, z = 1.5},
|
||||
{x = 0, y = 0, z = 2.5},
|
||||
{x = 0, y = 0, z = 2.5},
|
||||
{x = 0, y = 0, z = 2.5},
|
||||
{x = 0, y = 0, z = 2.5},
|
||||
{x = 0, y = 0, z = 2.5},
|
||||
{x = 0, y = 0, z = 2.5},
|
||||
{x = 0, y = 0, z = 2.5},
|
||||
{x = 0, y = 0, z = 2.5},
|
||||
{x = 0, y = 0, z = 2.5}
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
{x = 0, y = 0, z = 0.79254},
|
||||
{x = 0, y = 0, z = 0.79254},
|
||||
{x = 0, y = 0, z = 0.79254},
|
||||
{x = 0, y = 0, z = 0.17723},
|
||||
{x = 0, y = 0, z = 0.17723},
|
||||
{x = 0, y = 0, z = 0.17723},
|
||||
{x = 0, y = 0, z = 0.17723},
|
||||
{x = 0, y = 0, z = 0.17723},
|
||||
{x = 0, y = 0, z = 0.17723},
|
||||
{x = 0, y = 0, z = 0.17723},
|
||||
{x = 0, y = 0, z = 0.17723},
|
||||
{x = 0, y = 0, z = 0.17723},
|
||||
{x = 0, y = 0, z = 0.17723}
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
{x = 0, y = 0, z = -0.36178},
|
||||
{x = 0, y = 0, z = -0.36178},
|
||||
{x = 0, y = 0, z = -0.36178},
|
||||
{x = 0, y = 0, z = -0.36178}
|
||||
},
|
||||
{x = 0, y = -3, z = 0}
|
||||
},
|
||||
{
|
||||
{
|
||||
{x = 0, y = 0, z = -0.30074},
|
||||
{x = 0, y = 0, z = -0.30074},
|
||||
{x = 0, y = 0, z = -0.30074},
|
||||
{x = 0, y = 0, z = -0.30074}
|
||||
},
|
||||
{x = 0, y = -2, z = 0}
|
||||
},
|
||||
{
|
||||
{
|
||||
{x = 0, y = 0, z = -0.62118},
|
||||
{x = 0, y = 0, z = -0.62118}
|
||||
},
|
||||
{
|
||||
{x = 0.24482, y = 1.14985, z = 1.32775},
|
||||
{x = 0.24482, y = 1.14985, z = 1.62698},
|
||||
{x = 0.24482, y = 1.14985, z = 1.88017},
|
||||
{x = -0.24482, y = 1.14985, z = 1.32775},
|
||||
{x = -0.24482, y = 1.14985, z = 1.62698},
|
||||
{x = -0.24482, y = 1.14985, z = 1.88017}
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
{x = 0, y = 0, z = -0.59117},
|
||||
{x = 0, y = 0, z = -0.59117},
|
||||
{x = 0, y = 0, z = -0.59117},
|
||||
{x = 0, y = 0, z = -0.59117},
|
||||
{x = 0, y = 0, z = -0.59117}
|
||||
},
|
||||
{{x = 0.17192, y = 0.57858, z = 0.64471}, {x = -0.17192, y = 0.57858, z = 0.64471}}
|
||||
},
|
||||
{},
|
||||
{},
|
||||
{
|
||||
{x = 0, y =-.3, z =-1.5}
|
||||
},
|
||||
{
|
||||
{
|
||||
{x = -.25, y =0, z =0},
|
||||
{x = .25, y =0, z =0}
|
||||
},
|
||||
{
|
||||
{x = -.25, y =0, z =0},
|
||||
{x = .25, y =0, z =0}
|
||||
}
|
||||
},
|
||||
{}
|
||||
},
|
||||
damage = {
|
||||
{
|
||||
{50, 50, 50, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}
|
||||
},
|
||||
{
|
||||
{50, 50, 50, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}
|
||||
},
|
||||
{
|
||||
{50,50,50,50},
|
||||
{50}
|
||||
},
|
||||
{
|
||||
{50,50,50,50},
|
||||
{50}
|
||||
},
|
||||
{
|
||||
{10,10},
|
||||
{}
|
||||
},
|
||||
{
|
||||
{10,10,10,10,10},
|
||||
{}
|
||||
},
|
||||
{},
|
||||
{},
|
||||
{
|
||||
{}
|
||||
},
|
||||
{
|
||||
{50,50},
|
||||
{50,50}
|
||||
},
|
||||
{}
|
||||
},
|
||||
projectileName = {
|
||||
{"shell"},
|
||||
{"shell"},
|
||||
{"shell"},
|
||||
{"shell"},
|
||||
{"shell","guidedMissile"},
|
||||
{"shell","guidedMissile"},
|
||||
{""},
|
||||
{""},
|
||||
{"torpedo"},
|
||||
{"missile","missile"},
|
||||
},
|
||||
meshPath = {
|
||||
{PATH .. "Models/GameObjects/Shell/shell.x"},
|
||||
{PATH .. "Models/GameObjects/Shell/shell.x"},
|
||||
{PATH .. "Models/GameObjects/Shell/shell.x", PATH .. "Models/GameObjects/Depth charge/depthCharge.x"},
|
||||
{PATH .. "Models/GameObjects/Shell/shell.x", PATH .. "Models/GameObjects/Depth charge/depthCharge.x"},
|
||||
{PATH .. "Models/GameObjects/Shell/shell.x", PATH .. "Models/GameObjects/Guided missile/guidedMissile.x"},
|
||||
{PATH .. "Models/GameObjects/Shell/shell.x", PATH .. "Models/GameObjects/Guided missile/guidedMissile.x"},
|
||||
{},
|
||||
{},
|
||||
{PATH .. "Models/GameObjects/Torpedo/torpedo.x"},
|
||||
{PATH .. "Models/GameObjects/Jets/aam.x", PATH .. "Models/GameObjects/Jets/awm.x"}
|
||||
},
|
||||
diffuseMapTextPath = {
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{}
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -12,6 +12,7 @@
|
||||
namespace battleship{
|
||||
using namespace gameBase;
|
||||
using namespace vb01;
|
||||
using namespace std;
|
||||
|
||||
//TODO implement structure build status argument
|
||||
void AddUnitCommand::validate(){
|
||||
@@ -26,8 +27,9 @@ namespace battleship{
|
||||
unitId = atoi(arguments[1].c_str());
|
||||
|
||||
sol::state_view SOL_LUA_VIEW = generateView();
|
||||
SOL_LUA_VIEW.script("numUnits = #units.unitClass");
|
||||
int numUnits = SOL_LUA_VIEW["numUnits"];
|
||||
string varName = "numUnits";
|
||||
SOL_LUA_VIEW.script(varName + " = #units");
|
||||
int numUnits = SOL_LUA_VIEW[varName];
|
||||
|
||||
if(!(0 <= unitId && unitId <= numUnits))
|
||||
return;
|
||||
|
||||
+18
-4
@@ -51,7 +51,9 @@ namespace battleship{
|
||||
sol::table sizeTable = guiTable["size"];
|
||||
Vector2 size = Vector2(sizeTable["x"], sizeTable["y"]);
|
||||
|
||||
string name = guiTable["name"];
|
||||
string nk = "name";
|
||||
sol::optional<string> nameOpt = guiTable[nk];
|
||||
string name = (nameOpt != sol::nullopt ? (string)guiTable[nk] : "");
|
||||
ButtonType type = (ButtonType)guiTable["buttonType"];
|
||||
|
||||
Button *button = nullptr;
|
||||
@@ -160,14 +162,26 @@ namespace battleship{
|
||||
break;
|
||||
}
|
||||
case BUILD:
|
||||
button = new BuildButton(pos, size, (int)guiTable["structureId"], name, (int)guiTable["trigger"], (string)guiTable["imagePath"]);
|
||||
{
|
||||
int strId = guiTable["structureId"];
|
||||
string buttonName = SOL_LUA_STATE["units"][strId + 1]["name"];
|
||||
button = new BuildButton(pos, size, strId, buttonName, (int)guiTable["trigger"], (string)guiTable["imagePath"]);
|
||||
break;
|
||||
}
|
||||
case LAND_FACTORY_TRAIN:
|
||||
button = new TrainButton(pos, size, name, (int)guiTable["trigger"], (string)guiTable["imagePath"], (int)UnitClass::LAND_FACTORY, (int)guiTable["unitId"]);
|
||||
{
|
||||
int unitId = guiTable["unitId"];
|
||||
string buttonName = SOL_LUA_STATE["units"][unitId + 1]["name"];
|
||||
button = new TrainButton(pos, size, buttonName, (int)guiTable["trigger"], (string)guiTable["imagePath"], (int)SOL_LUA_STATE["UnitId"]["LAND_FACTORY"], unitId);
|
||||
break;
|
||||
}
|
||||
case NAVAL_FACTORY_TRAIN:
|
||||
button = new TrainButton(pos, size, name, (int)guiTable["trigger"], (string)guiTable["imagePath"], (int)UnitClass::NAVAL_FACTORY, (int)guiTable["unitId"]);
|
||||
{
|
||||
int unitId = guiTable["unitId"];
|
||||
string buttonName = SOL_LUA_STATE["units"][unitId + 1]["name"];
|
||||
button = new TrainButton(pos, size, buttonName, (int)guiTable["trigger"], (string)guiTable["imagePath"], (int)SOL_LUA_STATE["UnitId"]["NAVAL_FACTORY"], unitId);
|
||||
break;
|
||||
}
|
||||
case STATISTICS:
|
||||
button = new StatsButton(pos, size, name, (int)guiTable["trigger"], (string)guiTable["imagePath"]);
|
||||
break;
|
||||
|
||||
+2
-6
@@ -36,11 +36,9 @@ namespace battleship{
|
||||
CORE_MAIN,
|
||||
GUI_MAIN,
|
||||
OPTIONS,
|
||||
UNIT_DATA,
|
||||
VEHICLE_DATA,
|
||||
STRUCTURE_DATA,
|
||||
RESOURCE_DATA,
|
||||
PROJECTILE_DATA,
|
||||
UNIT_DATA,
|
||||
AI_AGENT,
|
||||
PLAYER
|
||||
};
|
||||
@@ -48,11 +46,9 @@ namespace battleship{
|
||||
"Scripts/Core/main.lua",
|
||||
"Scripts/Gui/main.lua",
|
||||
"Scripts/Core/options.lua",
|
||||
"Scripts/GameObjects/Units/unitData.lua",
|
||||
"Scripts/GameObjects/Units/vehicleData.lua",
|
||||
"Scripts/GameObjects/Units/structureData.lua",
|
||||
"Scripts/GameObjects/resourceData.lua",
|
||||
"Scripts/GameObjects/Projectiles/projectileData.lua",
|
||||
"Scripts/GameObjects/Units/unitData.lua",
|
||||
"Scripts/aiAgent.lua",
|
||||
"Scripts/Core/player.lua"
|
||||
};
|
||||
|
||||
+21
-17
@@ -38,13 +38,12 @@ namespace battleship{
|
||||
|
||||
//TODO remove neccessity to create a material for an invisible mesh
|
||||
void GameObject::initHitbox(){
|
||||
sol::table SOL_LUA_STATE = generateView()[GameObject::getGameObjTableName()];
|
||||
sol::table offsetPosTable = SOL_LUA_STATE["hitboxOffset"][id + 1];
|
||||
|
||||
Box *box = new Box(Vector3(width, height, length));
|
||||
box->setMaterial(new Material(Root::getSingleton()->getLibPath() + "texture"));
|
||||
box->setWireframe(false);
|
||||
|
||||
sol::table gameObjTable = generateView()[GameObject::getGameObjTableName()][id + 1];
|
||||
sol::table offsetPosTable = gameObjTable["hitboxOffset"];
|
||||
hitbox = new Node(Vector3(offsetPosTable["x"], offsetPosTable["y"], offsetPosTable["z"]));
|
||||
hitbox->attachMesh(box);
|
||||
hitbox->setVisible(false);
|
||||
@@ -58,16 +57,10 @@ namespace battleship{
|
||||
}
|
||||
|
||||
void GameObject::initProperties(){
|
||||
sol::table SOL_LUA_STATE = generateView()[GameObject::getGameObjTableName()];
|
||||
|
||||
for(int i = 0; i < 8; i++){
|
||||
sol::table cornerTable = SOL_LUA_STATE["unitCornerPoints"][id + 1][i + 1];
|
||||
corners[i] = Vector3(cornerTable["x"], cornerTable["y"], cornerTable["z"]);
|
||||
}
|
||||
|
||||
width = corners[0].x - corners[1].x;
|
||||
height = corners[4].y - corners[0].y;
|
||||
length = corners[3].z - corners[0].z;
|
||||
sol::table sizeTable = generateView()[GameObject::getGameObjTableName()][id + 1]["size"];
|
||||
width = sizeTable["x"];
|
||||
height = sizeTable["y"];
|
||||
length = sizeTable["z"];
|
||||
}
|
||||
|
||||
void GameObject::destroyModel(){
|
||||
@@ -76,9 +69,9 @@ namespace battleship{
|
||||
}
|
||||
|
||||
void GameObject::initModel(bool textured){
|
||||
sol::table SOL_LUA_STATE = generateView()[GameObject::getGameObjTableName()];
|
||||
string basePath = SOL_LUA_STATE["basePath"][id + 1];
|
||||
string meshPath = SOL_LUA_STATE["meshPath"][id + 1];
|
||||
sol::table gameObjTable = generateView()[GameObject::getGameObjTableName()][id + 1];
|
||||
string basePath = gameObjTable["basePath"];
|
||||
string meshPath = gameObjTable["meshPath"];
|
||||
|
||||
model = new Model(basePath + meshPath);
|
||||
Root *root = Root::getSingleton();
|
||||
@@ -121,7 +114,7 @@ namespace battleship{
|
||||
|
||||
void GameObject::initSound(){
|
||||
deathSfxBuffer = new sf::SoundBuffer();
|
||||
string sfxPath = generateView()[getGameObjTableName()]["deathSfx"][id + 1];
|
||||
string sfxPath = generateView()[getGameObjTableName()][id + 1]["deathSfx"];
|
||||
deathSfx = prepareSfx(deathSfxBuffer, sfxPath);
|
||||
}
|
||||
|
||||
@@ -152,6 +145,17 @@ namespace battleship{
|
||||
|
||||
Vector2 GameObject::calculateSelectionRect(){
|
||||
const int NUM_CORNERS = 8;
|
||||
Vector3 corners[NUM_CORNERS]{
|
||||
Vector3(-.5 * width, -.5 * height, -.5 * length),
|
||||
Vector3(-.5 * width, -.5 * height, .5 * length),
|
||||
Vector3(.5 * width, -.5 * height, .5 * length),
|
||||
Vector3(.5 * width, -.5 * height, -.5 * length),
|
||||
Vector3(-.5 * width, .5 * height, -.5 * length),
|
||||
Vector3(-.5 * width, .5 * height, .5 * length),
|
||||
Vector3(.5 * width, .5 * height, .5 * length),
|
||||
Vector3(.5 * width, .5 * height, -.5 * length)
|
||||
};
|
||||
|
||||
vector<Vector2> cornersOnScreen;
|
||||
|
||||
for(int i = 0; i < NUM_CORNERS; i++){
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace battleship{
|
||||
using namespace gameBase;
|
||||
|
||||
Unit* GameObjectFactory::createUnit(Player *player, int id, Vector3 pos, Quaternion rot, int buildStatus){
|
||||
sol::state_view SOL_LUA_STATE = generateView();
|
||||
int unitClass = SOL_LUA_STATE["units"]["unitClass"][id + 1];
|
||||
sol::state_view SOL_LUA_VIEW = generateView();
|
||||
int unitClass = SOL_LUA_VIEW["units"][id + 1]["unitClass"];
|
||||
|
||||
switch((UnitClass)unitClass){
|
||||
case UnitClass::LAND_FACTORY:
|
||||
@@ -45,8 +45,8 @@ namespace battleship{
|
||||
}
|
||||
|
||||
Projectile* GameObjectFactory::createProjectile(Unit *unit, int id, Vector3 pos, Quaternion rot){
|
||||
sol::state_view SOL_LUA_STATE = generateView();
|
||||
int projectileClass = SOL_LUA_STATE["projectiles"]["projectileClass"][id + 1];
|
||||
sol::state_view SOL_LUA_VIEW = generateView();
|
||||
int projectileClass = SOL_LUA_VIEW["projectiles"][id + 1]["projectileClass"];
|
||||
|
||||
switch((ProjectileClass)projectileClass){
|
||||
case ProjectileClass::CRUISE_MISSILE:
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace battleship{
|
||||
MeshData::Vertex *verts = meshData.vertices;
|
||||
int numVerts = 3 * meshData.numTris;
|
||||
|
||||
float maxUnevenness = generateView()["maxUnevenness"], unevenness = 0;
|
||||
float maxUnevenness = .5, unevenness = 0;
|
||||
|
||||
for(int i = 0; i < numVerts; i++){
|
||||
float diffX = fabs(s.getPos().x - verts[i].pos.x);
|
||||
@@ -101,9 +101,8 @@ namespace battleship{
|
||||
if(results.empty()) return;
|
||||
|
||||
Vector3 newPos, rowEnd;
|
||||
sol::table unitTable = generateView()[gameObjectFrames[0].getGameObjTableName()]["unitCornerPoints"][gameObjectFrames[0].getId() + 1];
|
||||
float width = (float)unitTable[1]["x"] - (float)unitTable[2]["x"];
|
||||
float length = (float)unitTable[4]["z"] - (float)unitTable[1]["z"];
|
||||
sol::table sizeTable = generateView()[gameObjectFrames[0].getGameObjTableName()][gameObjectFrames[0].getId() + 1]["size"];
|
||||
float width = sizeTable["x"], length = sizeTable["z"];
|
||||
|
||||
if(paintSelecting)
|
||||
paintSelect(results[0].pos, width, length);
|
||||
|
||||
+8
-7
@@ -39,14 +39,15 @@ namespace battleship{
|
||||
void Projectile::initProperties(){
|
||||
GameObject::initProperties();
|
||||
|
||||
sol::table projTable = generateView()[GameObject::getGameObjTableName()];
|
||||
rayLength = projTable["rayLength"][id + 1];
|
||||
directHitDamage = projTable["directHitDamage"][id + 1];
|
||||
sol::table projTable = generateView()[GameObject::getGameObjTableName()][id + 1];
|
||||
rayLength = projTable["rayLength"];
|
||||
directHitDamage = projTable["directHitDamage"];
|
||||
|
||||
string explKey = "explosion";
|
||||
explosionDamage = projTable[explKey][id + 1]["damage"];
|
||||
explosionRadius = projTable[explKey][id + 1]["radius"];
|
||||
speed = projTable["speed"][id + 1];
|
||||
rotAngle = projTable["rotAngle"][id + 1];;
|
||||
explosionDamage = projTable[explKey]["damage"];
|
||||
explosionRadius = projTable[explKey]["radius"];
|
||||
speed = projTable["speed"];
|
||||
rotAngle = projTable["rotAngle"].get_or(0.0);
|
||||
}
|
||||
|
||||
void Projectile::initSound(){
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ namespace battleship{
|
||||
void TrainButton::onClick(){
|
||||
ActiveGameState *activeState = (ActiveGameState*)(GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::ACTIVE_STATE));
|
||||
Player *player = activeState->getPlayer();
|
||||
UnitClass facClass = (UnitClass)generateView()["units"]["unitClass"][factoryId + 1];
|
||||
UnitClass facClass = (UnitClass)generateView()["units"][factoryId + 1]["unitClass"];
|
||||
vector<Unit*> factories = player->getSelectedUnitsByClass(facClass);
|
||||
|
||||
for(Unit *fac : factories)
|
||||
|
||||
@@ -42,12 +42,12 @@ namespace battleship{
|
||||
if(proj != sol::nullopt){
|
||||
projId = weaponTable[projTableKey]["id"];
|
||||
sol::table projTable = generateView()["projectiles"];
|
||||
ProjectileClass pc = (ProjectileClass)projTable["projectileClass"][projId + 1];
|
||||
ProjectileClass pc = (ProjectileClass)projTable[projId + 1]["projectileClass"];
|
||||
|
||||
if(pc == ProjectileClass::CRUISE_MISSILE){
|
||||
minRange = 0;
|
||||
float rotAngle = projTable["rotAngle"][projId + 1];
|
||||
float speed = projTable["speed"][projId + 1];
|
||||
float rotAngle = projTable[projId + 1]["rotAngle"];
|
||||
float speed = projTable[projId + 1]["speed"];
|
||||
float base = PI / 2, alpha = 0;
|
||||
|
||||
while(base - alpha > .001){
|
||||
@@ -130,46 +130,66 @@ namespace battleship{
|
||||
GameObject::initProperties();
|
||||
|
||||
sol::state_view SOL_LUA_VIEW = generateView();
|
||||
sol::table SOL_LUA_STATE = SOL_LUA_VIEW[GameObject::getGameObjTableName()];
|
||||
string name = SOL_LUA_STATE["name"][id + 1];
|
||||
health = SOL_LUA_STATE["health"][id + 1];
|
||||
string objType = GameObject::getGameObjTableName();
|
||||
sol::table unitTable = SOL_LUA_VIEW[objType][id + 1];
|
||||
string name = unitTable["name"];
|
||||
health = unitTable["health"];
|
||||
vehicle = unitTable["isVehicle"];
|
||||
maxHealth = health;
|
||||
|
||||
lineOfSight = SOL_LUA_STATE["lineOfSight"][id + 1];
|
||||
unitClass = (UnitClass)SOL_LUA_STATE["unitClass"][id + 1];
|
||||
type = (UnitType)SOL_LUA_STATE["unitType"][id + 1];
|
||||
lineOfSight = unitTable["lineOfSight"];
|
||||
unitClass = (UnitClass)unitTable["unitClass"];
|
||||
type = (UnitType)unitTable["unitType"];
|
||||
|
||||
SOL_LUA_VIEW.script("numGarrisonSlots = #units.garrisonCapacity[" + to_string(id + 1) + "]");
|
||||
int numGarrisonSlots = SOL_LUA_VIEW["numGarrisonSlots"];
|
||||
string tblName = "garrisonCapacity";
|
||||
sol::optional<sol::table> gc = unitTable[tblName];
|
||||
|
||||
for(int i = 0; i < numGarrisonSlots; i++){
|
||||
Vector2 size = 10 * Vector2::VEC_IJ;
|
||||
Vector2 pos = Vector2(1.5 * size.x * i, 20);
|
||||
Node *bg = createBar(pos, size, Vector4(0, 0, 0, 1));
|
||||
Node *fg = createBar(pos, size, Vector4(0, 1, 0, 1));
|
||||
int category = SOL_LUA_STATE["garrisonCapacity"][id + 1][i + 1];
|
||||
garrisonSlots.push_back(GarrisonSlot(bg, fg, pos, category));
|
||||
if(gc != sol::nullopt){
|
||||
string varName = "numGarrisonSlots";
|
||||
SOL_LUA_VIEW.script(varName + " = #" + objType + "[" + to_string(id + 1) + "]." + tblName);
|
||||
int numGarrisonSlots = SOL_LUA_VIEW[varName];
|
||||
|
||||
for(int i = 0; i < numGarrisonSlots; i++){
|
||||
Vector2 size = 10 * Vector2::VEC_IJ;
|
||||
Vector2 pos = Vector2(1.5 * size.x * i, 20);
|
||||
Node *bg = createBar(pos, size, Vector4(0, 0, 0, 1));
|
||||
Node *fg = createBar(pos, size, Vector4(0, 1, 0, 1));
|
||||
int category = unitTable[tblName][i + 1];
|
||||
garrisonSlots.push_back(GarrisonSlot(bg, fg, pos, category));
|
||||
}
|
||||
}
|
||||
|
||||
SOL_LUA_VIEW.script("numArmorTypes = #units.armor[" + to_string(id + 1) + "]");
|
||||
int numArmorTypes = SOL_LUA_VIEW["numArmorTypes"];
|
||||
tblName = "armor";
|
||||
sol::optional<sol::table> at = unitTable[tblName];
|
||||
|
||||
for(int i = 0; i < numArmorTypes; i++){
|
||||
Armor arm = (Armor)SOL_LUA_STATE["armor"][id + 1][i + 1];
|
||||
armorTypes.push_back(arm);
|
||||
if(at != sol::nullopt){
|
||||
string varName = "numArmorTypes";
|
||||
SOL_LUA_VIEW.script(varName + " = #" + objType + "[" + to_string(id + 1) + "]." + tblName);
|
||||
int numArmorTypes = SOL_LUA_VIEW[varName];
|
||||
|
||||
for(int i = 0; i < numArmorTypes; i++){
|
||||
Armor arm = (Armor)unitTable[tblName][i + 1];
|
||||
armorTypes.push_back(arm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::initWeapons(){
|
||||
sol::state_view SOL_STATE_VIEW = generateView();
|
||||
sol::table unitTable = SOL_STATE_VIEW[GameObject::getGameObjTableName()];
|
||||
string objType = GameObject::getGameObjTableName();
|
||||
sol::table unitTable = SOL_STATE_VIEW[objType][id + 1];
|
||||
|
||||
string varName = "numWeapons", tblName = "weapons";
|
||||
SOL_STATE_VIEW.script(varName + " = #units." + tblName + "[" + to_string(id + 1) + "]");
|
||||
int numWeapons = SOL_STATE_VIEW[varName];
|
||||
string tblName = "weapons";
|
||||
sol::optional<sol::table> wt = unitTable[tblName];
|
||||
|
||||
for(int i = 0; i < numWeapons; i++)
|
||||
weapons.push_back(new Weapon(this, unitTable[tblName][id + 1][i + 1]));
|
||||
if(wt != sol::nullopt){
|
||||
string varName = "numWeapons";
|
||||
SOL_STATE_VIEW.script(varName + " = #" + objType + "[" + to_string(id + 1) + "]." + tblName);
|
||||
int numWeapons = SOL_STATE_VIEW[varName];
|
||||
|
||||
for(int i = 0; i < numWeapons; i++)
|
||||
weapons.push_back(new Weapon(this, unitTable[tblName][i + 1]));
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::destroyWeapons(){
|
||||
@@ -188,7 +208,7 @@ namespace battleship{
|
||||
void Unit::initSound(){
|
||||
GameObject::initSound();
|
||||
selectionSfxBuffer = new sf::SoundBuffer();
|
||||
string sfxPath = generateView()[getGameObjTableName()]["selectionSfx"][id + 1];
|
||||
string sfxPath = generateView()[getGameObjTableName()][id + 1]["selectionSfx"];
|
||||
selectionSfx = GameObject::prepareSfx(selectionSfxBuffer, sfxPath);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,8 +64,7 @@ namespace battleship{
|
||||
RESOURCE_ROVER,
|
||||
CRUISER,
|
||||
CARRIER,
|
||||
MISSILE_SUBMARINE,
|
||||
STEALTH_SUBMARINE,
|
||||
SUBMARINE,
|
||||
LAND_FACTORY,
|
||||
NAVAL_FACTORY,
|
||||
MARKET,
|
||||
@@ -141,7 +140,7 @@ namespace battleship{
|
||||
inline int getPlayerId() {return playerId;}
|
||||
inline int getHealth(){return health;}
|
||||
inline int getDeathHp(){return DEATH_HP;}
|
||||
inline bool isVehicle(){return gameBase::generateView()["units"]["isVehicle"][id + 1];}
|
||||
inline bool isVehicle(){return vehicle;}
|
||||
inline bool isTargetToTheRight(vb01::Vector3 dir, vb01::Vector3 lv){return lv.getAngleBetween(dir) > vb01::PI / 2;}
|
||||
inline Order getOrder(int i){return orders[i];}
|
||||
inline int getNumOrders(){return orders.size();}
|
||||
@@ -157,6 +156,7 @@ namespace battleship{
|
||||
sf::SoundBuffer *selectionSfxBuffer;
|
||||
sf::Sound *selectionSfx = nullptr;
|
||||
vb01::Node *hpBackgroundNode = nullptr, *hpForegroundNode = nullptr;
|
||||
bool vehicle;
|
||||
protected:
|
||||
UnitClass unitClass;
|
||||
UnitType type;
|
||||
|
||||
+5
-6
@@ -83,14 +83,13 @@ namespace battleship{
|
||||
}
|
||||
|
||||
void Vehicle::initProperties(){
|
||||
sol::table SOL_LUA_STATE = generateView()[GameObject::getGameObjTableName()];
|
||||
maxTurnAngle = SOL_LUA_STATE["maxTurnAngle"][id + 1];
|
||||
speed = SOL_LUA_STATE["speed"][id + 1];
|
||||
anglePrecision = SOL_LUA_STATE["anglePrecision"][id + 1];
|
||||
garrisonCategory = SOL_LUA_STATE["garrisonCategory"][id + 1];
|
||||
sol::table unitTable = generateView()[GameObject::getGameObjTableName()][id + 1];
|
||||
maxTurnAngle = unitTable["maxTurnAngle"];
|
||||
speed = unitTable["speed"];
|
||||
anglePrecision = unitTable["anglePrecision"];
|
||||
garrisonCategory = unitTable["garrisonCategory"];
|
||||
}
|
||||
|
||||
|
||||
void Vehicle::navigate(float destOffset){
|
||||
Vector3 hypVec = (pathPoints[0] - pos);
|
||||
float hypAngle = hypVec.norm().getAngleBetween(upVec) - PI / 2;
|
||||
|
||||
Reference in New Issue
Block a user