mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
factories and engineers produce and build units by their specific buildable unit tables
This commit is contained in:
@@ -38,7 +38,7 @@ function Player:trainEngineers()
|
|||||||
dirToCenter = Vector3:new(0, 0, 0):subtr(fort:getPos()):norm()
|
dirToCenter = Vector3:new(0, 0, 0):subtr(fort:getPos()):norm()
|
||||||
|
|
||||||
while #fort:getQueue() + #self:getUnitsByClass(UnitClass.ENGINEER, -1) < self.numStartEngis do
|
while #fort:getQueue() + #self:getUnitsByClass(UnitClass.ENGINEER, -1) < self.numStartEngis do
|
||||||
fort:appendToQueue(UnitId.ENGINEER)
|
fort:appendToQueue(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
return #self:getUnitsByClass(UnitClass.ENGINEER, -1) == self.numStartEngis
|
return #self:getUnitsByClass(UnitClass.ENGINEER, -1) == self.numStartEngis
|
||||||
@@ -132,7 +132,7 @@ function Player:buildHarvester()
|
|||||||
factory = landFactories[1]:toFactory()
|
factory = landFactories[1]:toFactory()
|
||||||
|
|
||||||
if #factory:getQueue() == 0 then
|
if #factory:getQueue() == 0 then
|
||||||
factory:appendToQueue(UnitId.RESOURCE_ROVER)
|
factory:appendToQueue(3)
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@@ -157,10 +157,10 @@ function Player:startHarvesting()
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function Player:buildTaskforceUnitGroup(numUnits, currNumUnits, factory, unitId)
|
function Player:buildTaskforceUnitGroup(numUnits, currNumUnits, factory, buId)
|
||||||
if currNumUnits < numUnits then
|
if currNumUnits < numUnits then
|
||||||
for i = 1, numUnits - currNumUnits do
|
for i = 1, numUnits - currNumUnits do
|
||||||
factory:appendToQueue(unitId)
|
factory:appendToQueue(buId)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -175,9 +175,9 @@ function Player:buildTaskforce()
|
|||||||
currLandFactories = self:getUnitsByClass(UnitClass.LAND_FACTORY, -1)
|
currLandFactories = self:getUnitsByClass(UnitClass.LAND_FACTORY, -1)
|
||||||
|
|
||||||
for i = 1, #currLandFactories do
|
for i = 1, #currLandFactories do
|
||||||
currNumWarMechs = currNumWarMechs + currLandFactories[i]:toFactory():getNumQueueUnitsById(UnitId.WAR_MECH)
|
currNumWarMechs = currNumWarMechs + currLandFactories[i]:toFactory():getNumQueueUnitsById(0)
|
||||||
currNumTanks = currNumTanks + currLandFactories[i]:toFactory():getNumQueueUnitsById(UnitId.TANK)
|
currNumTanks = currNumTanks + currLandFactories[i]:toFactory():getNumQueueUnitsById(1)
|
||||||
currNumArtillery = currNumArtillery + currLandFactories[i]:toFactory():getNumQueueUnitsById(UnitId.ARTILLERY)
|
currNumArtillery = currNumArtillery + currLandFactories[i]:toFactory():getNumQueueUnitsById(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
numWarMechs = self.numDefWarMechs + self.numTaskForceWarMechs
|
numWarMechs = self.numDefWarMechs + self.numTaskForceWarMechs
|
||||||
@@ -190,9 +190,9 @@ function Player:buildTaskforce()
|
|||||||
|
|
||||||
landFactory = currLandFactories[1]:toFactory()
|
landFactory = currLandFactories[1]:toFactory()
|
||||||
|
|
||||||
self:buildTaskforceUnitGroup(numWarMechs, currNumWarMechs, landFactory, UnitId.WAR_MECH)
|
self:buildTaskforceUnitGroup(numWarMechs, currNumWarMechs, landFactory, 0)
|
||||||
self:buildTaskforceUnitGroup(numTanks, currNumTanks, landFactory, UnitId.TANK)
|
self:buildTaskforceUnitGroup(numTanks, currNumTanks, landFactory, 1)
|
||||||
self:buildTaskforceUnitGroup(numArtillery, currNumArtillery, landFactory, UnitId.ARTILLERY)
|
self:buildTaskforceUnitGroup(numArtillery, currNumArtillery, landFactory, 2)
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ units = {
|
|||||||
destinationOffset = .1,
|
destinationOffset = .1,
|
||||||
anglePrecision = .1,
|
anglePrecision = .1,
|
||||||
maxTurnAngle = .1,
|
maxTurnAngle = .1,
|
||||||
|
guiScreen = '',
|
||||||
garrisonCategory = 1
|
garrisonCategory = 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -96,6 +97,7 @@ units = {
|
|||||||
destinationOffset = .1,
|
destinationOffset = .1,
|
||||||
anglePrecision = .1,
|
anglePrecision = .1,
|
||||||
maxTurnAngle = .1,
|
maxTurnAngle = .1,
|
||||||
|
guiScreen = '',
|
||||||
garrisonCategory = 2
|
garrisonCategory = 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -119,12 +121,21 @@ units = {
|
|||||||
destinationOffset = .1,
|
destinationOffset = .1,
|
||||||
anglePrecision = .1,
|
anglePrecision = .1,
|
||||||
maxTurnAngle = .1,
|
maxTurnAngle = .1,
|
||||||
|
guiScreen = '',
|
||||||
garrisonCategory = 2
|
garrisonCategory = 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
weapons = {
|
weapons = {
|
||||||
{type = WeaponClass.HITSCAN, rateOfFire = 2000, fireSfx = PATH .. 'Sounds/Units/WarMechs/fire.ogg', damage = 20, maxRange = 8},
|
{type = WeaponClass.HITSCAN, rateOfFire = 2000, fireSfx = PATH .. 'Sounds/Units/WarMechs/fire.ogg', damage = 20, maxRange = 8},
|
||||||
},
|
},
|
||||||
|
buildableUnits = {
|
||||||
|
{id = UnitId.LAND_FACTORY, buildable = true},
|
||||||
|
{id = UnitId.NAVAL_FACTORY, buildable = true},
|
||||||
|
{id = UnitId.MARKET, buildable = true},
|
||||||
|
{id = UnitId.LAB, buildable = true},
|
||||||
|
{id = UnitId.POINT_DEFENSE, buildable = true},
|
||||||
|
{id = UnitId.FORT, buildable = true},
|
||||||
|
},
|
||||||
unitClass = UnitClass.ENGINEER,
|
unitClass = UnitClass.ENGINEER,
|
||||||
unitType = UnitType.HOVER,
|
unitType = UnitType.HOVER,
|
||||||
armor = {ArmorType.MECHANIC},
|
armor = {ArmorType.MECHANIC},
|
||||||
@@ -140,6 +151,7 @@ units = {
|
|||||||
name = 'Engineer',
|
name = 'Engineer',
|
||||||
basePath = PATH .. vehiclePrefix .. 'Engineers/',
|
basePath = PATH .. vehiclePrefix .. 'Engineers/',
|
||||||
meshPath = 'engineer.xml',
|
meshPath = 'engineer.xml',
|
||||||
|
guiScreen = 'engineerCommands.lua',
|
||||||
selectionSfx = PATH .. 'Sounds/Units/Engineers/selection.ogg',
|
selectionSfx = PATH .. 'Sounds/Units/Engineers/selection.ogg',
|
||||||
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
||||||
speed = .1,
|
speed = .1,
|
||||||
@@ -169,6 +181,7 @@ units = {
|
|||||||
destinationOffset = .1,
|
destinationOffset = .1,
|
||||||
anglePrecision = .1,
|
anglePrecision = .1,
|
||||||
maxTurnAngle = .1,
|
maxTurnAngle = .1,
|
||||||
|
guiScreen = '',
|
||||||
garrisonCategory = 3
|
garrisonCategory = 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -193,6 +206,7 @@ units = {
|
|||||||
destinationOffset = .1,
|
destinationOffset = .1,
|
||||||
anglePrecision = .1,
|
anglePrecision = .1,
|
||||||
maxTurnAngle = .1,
|
maxTurnAngle = .1,
|
||||||
|
guiScreen = '',
|
||||||
garrisonCategory = 3
|
garrisonCategory = 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -219,6 +233,7 @@ units = {
|
|||||||
destinationOffset = .1,
|
destinationOffset = .1,
|
||||||
anglePrecision = .1,
|
anglePrecision = .1,
|
||||||
maxTurnAngle = .1,
|
maxTurnAngle = .1,
|
||||||
|
guiScreen = '',
|
||||||
garrisonCategory = 3
|
garrisonCategory = 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -242,6 +257,7 @@ units = {
|
|||||||
destinationOffset = .1,
|
destinationOffset = .1,
|
||||||
anglePrecision = .1,
|
anglePrecision = .1,
|
||||||
maxTurnAngle = .1,
|
maxTurnAngle = .1,
|
||||||
|
guiScreen = '',
|
||||||
garrisonCategory = 3
|
garrisonCategory = 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -266,6 +282,7 @@ units = {
|
|||||||
destinationOffset = .1,
|
destinationOffset = .1,
|
||||||
anglePrecision = .1,
|
anglePrecision = .1,
|
||||||
maxTurnAngle = .1,
|
maxTurnAngle = .1,
|
||||||
|
guiScreen = '',
|
||||||
garrisonCategory = 3
|
garrisonCategory = 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -289,6 +306,7 @@ units = {
|
|||||||
destinationOffset = .1,
|
destinationOffset = .1,
|
||||||
anglePrecision = .1,
|
anglePrecision = .1,
|
||||||
maxTurnAngle = .1,
|
maxTurnAngle = .1,
|
||||||
|
guiScreen = '',
|
||||||
garrisonCategory = 3
|
garrisonCategory = 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -312,6 +330,7 @@ units = {
|
|||||||
destinationOffset = .1,
|
destinationOffset = .1,
|
||||||
anglePrecision = .1,
|
anglePrecision = .1,
|
||||||
maxTurnAngle = .1,
|
maxTurnAngle = .1,
|
||||||
|
guiScreen = '',
|
||||||
garrisonCategory = 3
|
garrisonCategory = 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -334,6 +353,7 @@ units = {
|
|||||||
destinationOffset = .1,
|
destinationOffset = .1,
|
||||||
anglePrecision = .1,
|
anglePrecision = .1,
|
||||||
maxTurnAngle = .1,
|
maxTurnAngle = .1,
|
||||||
|
guiScreen = '',
|
||||||
garrisonCategory = 3
|
garrisonCategory = 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -365,6 +385,7 @@ units = {
|
|||||||
destinationOffset = .1,
|
destinationOffset = .1,
|
||||||
anglePrecision = .1,
|
anglePrecision = .1,
|
||||||
maxTurnAngle = .1,
|
maxTurnAngle = .1,
|
||||||
|
guiScreen = '',
|
||||||
garrisonCategory = 3
|
garrisonCategory = 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -403,6 +424,7 @@ units = {
|
|||||||
destinationOffset = .1,
|
destinationOffset = .1,
|
||||||
anglePrecision = .1,
|
anglePrecision = .1,
|
||||||
maxTurnAngle = .1,
|
maxTurnAngle = .1,
|
||||||
|
guiScreen = '',
|
||||||
garrisonCategory = 3
|
garrisonCategory = 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -434,9 +456,16 @@ units = {
|
|||||||
destinationOffset = .1,
|
destinationOffset = .1,
|
||||||
anglePrecision = .1,
|
anglePrecision = .1,
|
||||||
maxTurnAngle = .1,
|
maxTurnAngle = .1,
|
||||||
|
guiScreen = '',
|
||||||
garrisonCategory = 3
|
garrisonCategory = 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
buildableUnits = {
|
||||||
|
{id = UnitId.WAR_MECH, buildable = true},
|
||||||
|
{id = UnitId.TANK, buildable = true},
|
||||||
|
{id = UnitId.ARTILLERY, buildable = true},
|
||||||
|
{id = UnitId.RESOURCE_ROVER, buildable = true}
|
||||||
|
},
|
||||||
unitClass = UnitClass.LAND_FACTORY,
|
unitClass = UnitClass.LAND_FACTORY,
|
||||||
unitType = UnitType.LAND,
|
unitType = UnitType.LAND,
|
||||||
isVehicle = false,
|
isVehicle = false,
|
||||||
@@ -449,6 +478,7 @@ units = {
|
|||||||
name = 'Land factory',
|
name = 'Land factory',
|
||||||
basePath = PATH .. structurePrefix .. 'LandFactories/',
|
basePath = PATH .. structurePrefix .. 'LandFactories/',
|
||||||
meshPath = 'landFactory.xml',
|
meshPath = 'landFactory.xml',
|
||||||
|
guiScreen = 'landFactoryCommands.lua',
|
||||||
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
|
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
|
||||||
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
||||||
},
|
},
|
||||||
@@ -465,6 +495,7 @@ units = {
|
|||||||
name = 'Naval factory',
|
name = 'Naval factory',
|
||||||
basePath = PATH .. structurePrefix .. 'NavalFactories/',
|
basePath = PATH .. structurePrefix .. 'NavalFactories/',
|
||||||
meshPath = 'navalFactory.xml',
|
meshPath = 'navalFactory.xml',
|
||||||
|
guiScreen = 'navalFactoryCommands.lua',
|
||||||
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
|
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
|
||||||
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
||||||
},
|
},
|
||||||
@@ -482,6 +513,7 @@ units = {
|
|||||||
basePath = PATH .. structurePrefix .. 'Markets/',
|
basePath = PATH .. structurePrefix .. 'Markets/',
|
||||||
meshPath = 'market.xml',
|
meshPath = 'market.xml',
|
||||||
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
|
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
|
||||||
|
guiScreen = '',
|
||||||
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -500,6 +532,7 @@ units = {
|
|||||||
name = 'Lab',
|
name = 'Lab',
|
||||||
basePath = PATH .. structurePrefix .. 'Labs/',
|
basePath = PATH .. structurePrefix .. 'Labs/',
|
||||||
meshPath = 'lab.xml',
|
meshPath = 'lab.xml',
|
||||||
|
guiScreen = '',
|
||||||
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
|
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
|
||||||
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
||||||
},
|
},
|
||||||
@@ -518,6 +551,7 @@ units = {
|
|||||||
basePath = PATH .. structurePrefix .. 'PointDefenses/',
|
basePath = PATH .. structurePrefix .. 'PointDefenses/',
|
||||||
meshPath = 'pointDefense.xml',
|
meshPath = 'pointDefense.xml',
|
||||||
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
|
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
|
||||||
|
guiScreen = '',
|
||||||
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -536,6 +570,7 @@ units = {
|
|||||||
basePath = PATH .. structurePrefix .. 'Extractors/',
|
basePath = PATH .. structurePrefix .. 'Extractors/',
|
||||||
meshPath = 'extractor.xml',
|
meshPath = 'extractor.xml',
|
||||||
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
|
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
|
||||||
|
guiScreen = '',
|
||||||
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -551,10 +586,12 @@ units = {
|
|||||||
name = 'Refinery',
|
name = 'Refinery',
|
||||||
basePath = PATH .. structurePrefix .. 'Refineries/',
|
basePath = PATH .. structurePrefix .. 'Refineries/',
|
||||||
meshPath = 'refinery.xml',
|
meshPath = 'refinery.xml',
|
||||||
|
guiScreen = '',
|
||||||
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
|
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
|
||||||
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
buildableUnits = {{id = UnitId.ENGINEER, buildable = true}},
|
||||||
unitClass = UnitClass.FORT,
|
unitClass = UnitClass.FORT,
|
||||||
unitType = UnitType.LAND,
|
unitType = UnitType.LAND,
|
||||||
isVehicle = false,
|
isVehicle = false,
|
||||||
@@ -567,6 +604,7 @@ units = {
|
|||||||
name = 'Fort',
|
name = 'Fort',
|
||||||
basePath = PATH .. structurePrefix .. 'Forts/',
|
basePath = PATH .. structurePrefix .. 'Forts/',
|
||||||
meshPath = 'fort.xml',
|
meshPath = 'fort.xml',
|
||||||
|
guiScreen = 'fortCommands.lua',
|
||||||
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
|
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
|
||||||
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ gui = {
|
|||||||
guiType = GuiType.BUTTON,
|
guiType = GuiType.BUTTON,
|
||||||
buttonType = ButtonType.BUILD,
|
buttonType = ButtonType.BUILD,
|
||||||
trigger = 76,
|
trigger = 76,
|
||||||
structureId = UnitId.LAND_FACTORY
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos = {x = res.x - Size.x - 200, y = res.y - 200},
|
pos = {x = res.x - Size.x - 200, y = res.y - 200},
|
||||||
@@ -18,7 +17,6 @@ gui = {
|
|||||||
guiType = GuiType.BUTTON,
|
guiType = GuiType.BUTTON,
|
||||||
buttonType = ButtonType.BUILD,
|
buttonType = ButtonType.BUILD,
|
||||||
trigger = 78,
|
trigger = 78,
|
||||||
structureId = UnitId.NAVAL_FACTORY
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos = {x = res.x - 2 * Size.x - 200, y = res.y - 200},
|
pos = {x = res.x - 2 * Size.x - 200, y = res.y - 200},
|
||||||
@@ -27,7 +25,6 @@ gui = {
|
|||||||
guiType = GuiType.BUTTON,
|
guiType = GuiType.BUTTON,
|
||||||
buttonType = ButtonType.BUILD,
|
buttonType = ButtonType.BUILD,
|
||||||
trigger = 77,
|
trigger = 77,
|
||||||
structureId = UnitId.MARKET
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos = {x = res.x - 3 * Size.x - 200, y = res.y - 200},
|
pos = {x = res.x - 3 * Size.x - 200, y = res.y - 200},
|
||||||
@@ -36,7 +33,6 @@ gui = {
|
|||||||
guiType = GuiType.BUTTON,
|
guiType = GuiType.BUTTON,
|
||||||
buttonType = ButtonType.BUILD,
|
buttonType = ButtonType.BUILD,
|
||||||
trigger = 84,
|
trigger = 84,
|
||||||
structureId = UnitId.LAB
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos = {x = res.x - 4 * Size.x - 200, y = res.y - 200},
|
pos = {x = res.x - 4 * Size.x - 200, y = res.y - 200},
|
||||||
@@ -45,7 +41,6 @@ gui = {
|
|||||||
guiType = GuiType.BUTTON,
|
guiType = GuiType.BUTTON,
|
||||||
buttonType = ButtonType.BUILD,
|
buttonType = ButtonType.BUILD,
|
||||||
trigger = 68,
|
trigger = 68,
|
||||||
structureId = UnitId.POINT_DEFENSE
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos = {x = res.x - 5 * Size.x - 200, y = res.y - 200},
|
pos = {x = res.x - 5 * Size.x - 200, y = res.y - 200},
|
||||||
@@ -54,6 +49,5 @@ gui = {
|
|||||||
guiType = GuiType.BUTTON,
|
guiType = GuiType.BUTTON,
|
||||||
buttonType = ButtonType.BUILD,
|
buttonType = ButtonType.BUILD,
|
||||||
trigger = 70,
|
trigger = 70,
|
||||||
structureId = UnitId.FORT
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ gui = {
|
|||||||
imagePath = '',
|
imagePath = '',
|
||||||
guiType = GuiType.BUTTON,
|
guiType = GuiType.BUTTON,
|
||||||
buttonType = ButtonType.FORT_TRAIN,
|
buttonType = ButtonType.FORT_TRAIN,
|
||||||
trigger = 82,
|
trigger = 82
|
||||||
unitId = UnitId.ENGINEER
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
numGui = 2
|
|
||||||
res = graphics.resolution
|
res = graphics.resolution
|
||||||
Size = {x = 100, y = 100}
|
Size = {x = 100, y = 100}
|
||||||
|
|
||||||
@@ -9,8 +8,7 @@ gui = {
|
|||||||
imagePath = '',
|
imagePath = '',
|
||||||
guiType = GuiType.BUTTON,
|
guiType = GuiType.BUTTON,
|
||||||
buttonType = ButtonType.LAND_FACTORY_TRAIN,
|
buttonType = ButtonType.LAND_FACTORY_TRAIN,
|
||||||
trigger = 84,
|
trigger = 87
|
||||||
unitId = UnitId.TANK
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pos = {x = res.x - Size.x - 200, y = res.y - 200},
|
pos = {x = res.x - Size.x - 200, y = res.y - 200},
|
||||||
@@ -18,7 +16,14 @@ gui = {
|
|||||||
imagePath = '',
|
imagePath = '',
|
||||||
guiType = GuiType.BUTTON,
|
guiType = GuiType.BUTTON,
|
||||||
buttonType = ButtonType.LAND_FACTORY_TRAIN,
|
buttonType = ButtonType.LAND_FACTORY_TRAIN,
|
||||||
trigger = 65,
|
trigger = 84
|
||||||
unitId = UnitId.ARTILLERY
|
},
|
||||||
|
{
|
||||||
|
pos = {x = res.x - 2 * Size.x - 200, y = res.y - 200},
|
||||||
|
size = Size,
|
||||||
|
imagePath = '',
|
||||||
|
guiType = GuiType.BUTTON,
|
||||||
|
buttonType = ButtonType.LAND_FACTORY_TRAIN,
|
||||||
|
trigger = 65
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
numGui = 1
|
|
||||||
res = graphics.resolution
|
res = graphics.resolution
|
||||||
|
|
||||||
gui = {
|
gui = {
|
||||||
@@ -8,7 +7,6 @@ gui = {
|
|||||||
imagePath = '',
|
imagePath = '',
|
||||||
guiType = GuiType.BUTTON,
|
guiType = GuiType.BUTTON,
|
||||||
buttonType = ButtonType.NAVAL_FACTORY_TRAIN,
|
buttonType = ButtonType.NAVAL_FACTORY_TRAIN,
|
||||||
trigger = 66,
|
trigger = 66
|
||||||
unitId = UnitId.SCOUT_TRANSPORT
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-9
@@ -161,6 +161,7 @@ namespace battleship{
|
|||||||
|
|
||||||
ConcreteGuiManager::getSingleton()->removeAllButtons();
|
ConcreteGuiManager::getSingleton()->removeAllButtons();
|
||||||
buttons.clear();
|
buttons.clear();
|
||||||
|
unitGuiScreen = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ActiveGameState::selectedUnitsAmongst(vector<Unit*> units){
|
bool ActiveGameState::selectedUnitsAmongst(vector<Unit*> units){
|
||||||
@@ -193,6 +194,7 @@ namespace battleship{
|
|||||||
guiManager->getText("wealth"),
|
guiManager->getText("wealth"),
|
||||||
guiManager->getText("research")
|
guiManager->getText("research")
|
||||||
};
|
};
|
||||||
|
vector<Unit*> selUnits = mainPlayer->getSelectedUnits();
|
||||||
|
|
||||||
|
|
||||||
for (Unit *u : units) {
|
for (Unit *u : units) {
|
||||||
@@ -200,16 +202,11 @@ namespace battleship{
|
|||||||
Vector3 dragboxSize = ((Quad*)dragboxNode->getMesh(0))->getSize();
|
Vector3 dragboxSize = ((Quad*)dragboxNode->getMesh(0))->getSize();
|
||||||
Vector3 dragboxOrigin = dragboxNode->getPosition(), dragboxEnd = dragboxOrigin + dragboxSize;
|
Vector3 dragboxOrigin = dragboxNode->getPosition(), dragboxEnd = dragboxOrigin + dragboxSize;
|
||||||
Vector2 pos = u->getScreenPos();
|
Vector2 pos = u->getScreenPos();
|
||||||
|
string guiScreen = u->getBuildableUnitGuiScreen();
|
||||||
|
|
||||||
if(buttons.empty()){
|
if(!selUnits.empty() && u == selUnits[0] && guiScreen != "" && guiScreen != unitGuiScreen){
|
||||||
if(selectedUnitsAmongst(mainPlayer->getUnitsByClass(UnitClass::ENGINEER)))
|
guiManager->readLuaScreenScript(u->getBuildableUnitGuiScreen(), buttons, listboxes, checkboxes, sliders, textboxes, guiRects, texts);
|
||||||
guiManager->readLuaScreenScript("engineerCommands.lua", buttons, listboxes, checkboxes, sliders, textboxes, guiRects, texts);
|
unitGuiScreen = guiScreen;
|
||||||
else if(selectedUnitsAmongst(mainPlayer->getUnitsByClass(UnitClass::FORT)))
|
|
||||||
guiManager->readLuaScreenScript("fortCommands.lua", buttons, listboxes, checkboxes, sliders, textboxes, guiRects, texts);
|
|
||||||
else if(selectedUnitsAmongst(mainPlayer->getUnitsByClass(UnitClass::LAND_FACTORY)))
|
|
||||||
guiManager->readLuaScreenScript("landFactoryCommands.lua", buttons, listboxes, checkboxes, sliders, textboxes, guiRects, texts);
|
|
||||||
else if(selectedUnitsAmongst(mainPlayer->getUnitsByClass(UnitClass::NAVAL_FACTORY)))
|
|
||||||
guiManager->readLuaScreenScript("navalFactoryCommands.lua", buttons, listboxes, checkboxes, sliders, textboxes, guiRects, texts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isSelectionBox && fabs(pos.x - dragboxOrigin.x) < .5 * dragboxSize.x && fabs(pos.y - dragboxOrigin.y) < .5 * dragboxSize.y){
|
if(isSelectionBox && fabs(pos.x - dragboxOrigin.x) < .5 * dragboxSize.x && fabs(pos.y - dragboxOrigin.y) < .5 * dragboxSize.y){
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ namespace battleship{
|
|||||||
|
|
||||||
GuiAppState *guiState;
|
GuiAppState *guiState;
|
||||||
Player *mainPlayer;
|
Player *mainPlayer;
|
||||||
|
std::string unitGuiScreen = "";
|
||||||
GameObject *gameObjHoveredOn = nullptr;
|
GameObject *gameObjHoveredOn = nullptr;
|
||||||
vb01::Node *dragboxNode = nullptr;
|
vb01::Node *dragboxNode = nullptr;
|
||||||
vb01::Vector2 clickPoint;
|
vb01::Vector2 clickPoint;
|
||||||
|
|||||||
+13
-4
@@ -1,8 +1,12 @@
|
|||||||
#include "buildButton.h"
|
#include "buildButton.h"
|
||||||
#include "gameManager.h"
|
#include "gameManager.h"
|
||||||
#include "gameObject.h"
|
#include "gameObject.h"
|
||||||
|
#include "unit.h"
|
||||||
|
#include "activeGameState.h"
|
||||||
|
#include "buildableUnit.h"
|
||||||
#include "gameObjectFrameController.h"
|
#include "gameObjectFrameController.h"
|
||||||
|
|
||||||
|
#include <stateManager.h>
|
||||||
#include <solUtil.h>
|
#include <solUtil.h>
|
||||||
|
|
||||||
namespace battleship{
|
namespace battleship{
|
||||||
@@ -12,13 +16,18 @@ namespace battleship{
|
|||||||
using namespace vb01Gui;
|
using namespace vb01Gui;
|
||||||
using namespace gameBase;
|
using namespace gameBase;
|
||||||
|
|
||||||
BuildButton::BuildButton(Vector2 pos, Vector2 size, int structureId, string name, int trigger, string imagePath) : UnitButton(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, imagePath){
|
BuildButton::BuildButton(Vector2 pos, Vector2 size, string name, int trigger, string imagePath, int uid, int slId) :
|
||||||
this->structureId = structureId;
|
UnitButton(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, imagePath, uid), slotId(slId){}
|
||||||
}
|
|
||||||
|
|
||||||
void BuildButton::onClick(){
|
void BuildButton::onClick(){
|
||||||
|
ActiveGameState *activeState = (ActiveGameState*)(GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::ACTIVE_STATE));
|
||||||
|
Player *player = activeState->getPlayer();
|
||||||
|
Unit* builder = player->getUnitsById(unitId)[0];
|
||||||
|
|
||||||
|
if(builder->getBuildableUnit(slotId).buildable){
|
||||||
GameObjectFrameController *ufCtr = GameObjectFrameController::getSingleton();
|
GameObjectFrameController *ufCtr = GameObjectFrameController::getSingleton();
|
||||||
ufCtr->addGameObjectFrame(GameObjectFrame(structureId, GameObject::Type::UNIT));
|
ufCtr->addGameObjectFrame(GameObjectFrame(builder->getBuildableUnit(slotId).id, GameObject::Type::UNIT));
|
||||||
ufCtr->setPlacingFrames(true);
|
ufCtr->setPlacingFrames(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
+2
-2
@@ -6,10 +6,10 @@
|
|||||||
namespace battleship{
|
namespace battleship{
|
||||||
class BuildButton : public UnitButton{
|
class BuildButton : public UnitButton{
|
||||||
public:
|
public:
|
||||||
BuildButton(vb01::Vector2, vb01::Vector2, int, std::string, int, std::string);
|
BuildButton(vb01::Vector2, vb01::Vector2, std::string, int, std::string, int, int);
|
||||||
void onClick();
|
void onClick();
|
||||||
private:
|
private:
|
||||||
int structureId;
|
int slotId;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-8
@@ -163,30 +163,34 @@ namespace battleship{
|
|||||||
}
|
}
|
||||||
case BUILD:
|
case BUILD:
|
||||||
{
|
{
|
||||||
int strId = guiTable["structureId"];
|
int unitId = SOL_LUA_STATE["UnitId"]["ENGINEER"];
|
||||||
|
int strId = SOL_LUA_STATE["units"][unitId + 1]["buildableUnits"][guiId + 1]["id"];
|
||||||
string buttonName = SOL_LUA_STATE["units"][strId + 1]["name"];
|
string buttonName = SOL_LUA_STATE["units"][strId + 1]["name"];
|
||||||
button = new BuildButton(pos, size, strId, buttonName, (int)guiTable["trigger"], (string)guiTable["imagePath"]);
|
button = new BuildButton(pos, size, buttonName, (int)guiTable["trigger"], (string)guiTable["imagePath"], unitId, guiId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LAND_FACTORY_TRAIN:
|
case LAND_FACTORY_TRAIN:
|
||||||
{
|
{
|
||||||
int unitId = guiTable["unitId"];
|
int facId = SOL_LUA_STATE["UnitId"]["LAND_FACTORY"];
|
||||||
|
int unitId = SOL_LUA_STATE["units"][facId + 1]["buildableUnits"][guiId + 1]["id"];
|
||||||
string buttonName = SOL_LUA_STATE["units"][unitId + 1]["name"];
|
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);
|
button = new TrainButton(pos, size, buttonName, (int)guiTable["trigger"], (string)guiTable["imagePath"], facId, guiId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NAVAL_FACTORY_TRAIN:
|
case NAVAL_FACTORY_TRAIN:
|
||||||
{
|
{
|
||||||
int unitId = guiTable["unitId"];
|
int facId = SOL_LUA_STATE["UnitId"]["NAVAL_FACTORY"];
|
||||||
|
int unitId = SOL_LUA_STATE["units"][facId + 1]["buildableUnits"][guiId + 1]["id"];
|
||||||
string buttonName = SOL_LUA_STATE["units"][unitId + 1]["name"];
|
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);
|
button = new TrainButton(pos, size, buttonName, (int)guiTable["trigger"], (string)guiTable["imagePath"], facId, guiId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FORT_TRAIN:
|
case FORT_TRAIN:
|
||||||
{
|
{
|
||||||
int unitId = guiTable["unitId"];
|
int facId = SOL_LUA_STATE["UnitId"]["FORT"];
|
||||||
|
int unitId = SOL_LUA_STATE["units"][facId + 1]["buildableUnits"][guiId + 1]["id"];
|
||||||
string buttonName = SOL_LUA_STATE["units"][unitId + 1]["name"];
|
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"]["FORT"], unitId);
|
button = new TrainButton(pos, size, buttonName, (int)guiTable["trigger"], (string)guiTable["imagePath"], facId, guiId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case STATISTICS:
|
case STATISTICS:
|
||||||
|
|||||||
+14
@@ -1,5 +1,6 @@
|
|||||||
#include "factory.h"
|
#include "factory.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
#include "game.h"
|
||||||
#include "gameObjectFactory.h"
|
#include "gameObjectFactory.h"
|
||||||
#include "activeGameState.h"
|
#include "activeGameState.h"
|
||||||
|
|
||||||
@@ -24,6 +25,14 @@ namespace battleship{
|
|||||||
train();
|
train();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO replace repetetive string literals
|
||||||
|
void Factory::initProperties(){
|
||||||
|
Structure::initProperties();
|
||||||
|
Game *game = Game::getSingleton();
|
||||||
|
vector<int> currTechs = player->getTechnologies();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int Factory::getNumQueueUnitsById(int unitId){
|
int Factory::getNumQueueUnitsById(int unitId){
|
||||||
int numUnits = 0;
|
int numUnits = 0;
|
||||||
|
|
||||||
@@ -34,6 +43,11 @@ namespace battleship{
|
|||||||
return numUnits;
|
return numUnits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Factory::appendToQueue(int buId){
|
||||||
|
if(buId < buildableUnits.size() && buildableUnits[buId].buildable)
|
||||||
|
unitQueue.push_back(buildableUnits[buId].id);
|
||||||
|
}
|
||||||
|
|
||||||
void Factory::train(){
|
void Factory::train(){
|
||||||
bool training = !unitQueue.empty();
|
bool training = !unitQueue.empty();
|
||||||
buildStatusForeground->setVisible(training);
|
buildStatusForeground->setVisible(training);
|
||||||
|
|||||||
@@ -19,14 +19,14 @@ namespace battleship{
|
|||||||
~Factory(){}
|
~Factory(){}
|
||||||
void update();
|
void update();
|
||||||
int getNumQueueUnitsById(int);
|
int getNumQueueUnitsById(int);
|
||||||
void appendToQueue(int uid){unitQueue.push_back(uid);}
|
void appendToQueue(int);
|
||||||
inline std::vector<int> getQueue(){return unitQueue;}
|
inline std::vector<int> getQueue(){return unitQueue;}
|
||||||
private:
|
private:
|
||||||
const int MAX_LEN_QUEUE = 10;
|
|
||||||
int trainingStatus = 0;
|
|
||||||
vb01::s64 lastTrainTime = 0;
|
|
||||||
std::vector<int> unitQueue;
|
std::vector<int> unitQueue;
|
||||||
|
int maxLenQueue, trainingStatus = 0;
|
||||||
|
vb01::s64 lastTrainTime = 0;
|
||||||
|
|
||||||
|
void initProperties();
|
||||||
void train();
|
void train();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-8
@@ -1,5 +1,6 @@
|
|||||||
#include "trainButton.h"
|
#include "trainButton.h"
|
||||||
#include "activeGameState.h"
|
#include "activeGameState.h"
|
||||||
|
#include "buildableUnit.h"
|
||||||
#include "factory.h"
|
#include "factory.h"
|
||||||
|
|
||||||
#include <stateManager.h>
|
#include <stateManager.h>
|
||||||
@@ -10,19 +11,17 @@ namespace battleship{
|
|||||||
using namespace vb01;
|
using namespace vb01;
|
||||||
using namespace gameBase;
|
using namespace gameBase;
|
||||||
|
|
||||||
TrainButton::TrainButton(Vector2 pos, Vector2 size, string name, int trigger, string imagePath, int fid, int tuid) :
|
TrainButton::TrainButton(Vector2 pos, Vector2 size, string name, int trigger, string imagePath, int uid, int slId) :
|
||||||
factoryId(fid),
|
UnitButton(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, imagePath, uid),
|
||||||
trainableUnitId(tuid),
|
slotId(slId) {}
|
||||||
UnitButton(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, imagePath){}
|
|
||||||
|
|
||||||
void TrainButton::onClick(){
|
void TrainButton::onClick(){
|
||||||
ActiveGameState *activeState = (ActiveGameState*)(GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::ACTIVE_STATE));
|
ActiveGameState *activeState = (ActiveGameState*)(GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::ACTIVE_STATE));
|
||||||
Player *player = activeState->getPlayer();
|
Player *player = activeState->getPlayer();
|
||||||
UnitClass facClass = (UnitClass)generateView()["units"][factoryId + 1]["unitClass"];
|
vector<Unit*> selUnits = player->getSelectedUnits(), factories = player->getUnitsById(unitId);
|
||||||
vector<Unit*> selUnits = player->getSelectedUnits(), factories = player->getUnitsByClass(facClass);
|
|
||||||
|
|
||||||
for(Unit *fac : factories)
|
for(Unit *fac : factories)
|
||||||
if(find(selUnits.begin(), selUnits.end(), fac) != selUnits.end())
|
if(fac->getBuildableUnit(slotId).buildable && find(selUnits.begin(), selUnits.end(), fac) != selUnits.end())
|
||||||
((Factory*)fac)->appendToQueue(trainableUnitId);
|
((Factory*)fac)->appendToQueue(slotId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ namespace battleship{
|
|||||||
TrainButton(vb01::Vector2, vb01::Vector2, std::string, int, std::string, int, int);
|
TrainButton(vb01::Vector2, vb01::Vector2, std::string, int, std::string, int, int);
|
||||||
void onClick();
|
void onClick();
|
||||||
private:
|
private:
|
||||||
int factoryId, trainableUnitId;
|
int slotId;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
#include "vehicle.h"
|
#include "vehicle.h"
|
||||||
#include "gameObjectFactory.h"
|
#include "gameObjectFactory.h"
|
||||||
#include "activeGameState.h"
|
#include "activeGameState.h"
|
||||||
|
#include "gameManager.h"
|
||||||
|
#include "projectile.h"
|
||||||
#include "defConfigs.h"
|
#include "defConfigs.h"
|
||||||
#include "pathfinder.h"
|
#include "pathfinder.h"
|
||||||
#include "ability.h"
|
#include "ability.h"
|
||||||
@@ -171,6 +173,20 @@ namespace battleship{
|
|||||||
armorTypes.push_back(arm);
|
armorTypes.push_back(arm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tblName = "buildableUnits";
|
||||||
|
sol::optional<sol::table> bu = unitTable[tblName];
|
||||||
|
|
||||||
|
if(bu != sol::nullopt){
|
||||||
|
SOL_LUA_VIEW.script("numBuildableUnits = #units[" + to_string(id + 1) + "]." + tblName);
|
||||||
|
int numBuildableUnits = SOL_LUA_VIEW["numBuildableUnits"];
|
||||||
|
buildableUnitGuiScreen = unitTable["guiScreen"];
|
||||||
|
|
||||||
|
for(int i = 0; i < numBuildableUnits; i++){
|
||||||
|
sol::table buTable = unitTable[tblName][i + 1];
|
||||||
|
buildableUnits.push_back(BuildableUnit(buTable["id"], buTable["buildable"]));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::initWeapons(){
|
void Unit::initWeapons(){
|
||||||
|
|||||||
@@ -8,9 +8,8 @@
|
|||||||
|
|
||||||
#include <solUtil.h>
|
#include <solUtil.h>
|
||||||
|
|
||||||
#include "gameManager.h"
|
|
||||||
#include "gameObject.h"
|
#include "gameObject.h"
|
||||||
#include "projectile.h"
|
#include "buildableUnit.h"
|
||||||
|
|
||||||
namespace sf{
|
namespace sf{
|
||||||
class SoundBuffer;
|
class SoundBuffer;
|
||||||
@@ -31,8 +30,9 @@ namespace battleship{
|
|||||||
class Structure;
|
class Structure;
|
||||||
class Factory;
|
class Factory;
|
||||||
class Cruiser;
|
class Cruiser;
|
||||||
class PointDefense;
|
|
||||||
class Engineer;
|
class Engineer;
|
||||||
|
class PointDefense;
|
||||||
|
class Projectile;
|
||||||
|
|
||||||
struct Order {
|
struct Order {
|
||||||
enum class TYPE {ATTACK, BUILD, MOVE, GARRISON, EJECT, PATROL, LAUNCH, SUPPLY, HACK};
|
enum class TYPE {ATTACK, BUILD, MOVE, GARRISON, EJECT, PATROL, LAUNCH, SUPPLY, HACK};
|
||||||
@@ -149,6 +149,8 @@ namespace battleship{
|
|||||||
inline bool isTargetToTheRight(vb01::Vector3 dir, vb01::Vector3 lv){return lv.getAngleBetween(dir) > vb01::PI / 2;}
|
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 Order getOrder(int i){return orders[i];}
|
||||||
inline int getNumOrders(){return orders.size();}
|
inline int getNumOrders(){return orders.size();}
|
||||||
|
inline std::string getBuildableUnitGuiScreen(){return buildableUnitGuiScreen;}
|
||||||
|
inline BuildableUnit getBuildableUnit(int i){return buildableUnits[i];}
|
||||||
private:
|
private:
|
||||||
void renderOrderLine(bool);
|
void renderOrderLine(bool);
|
||||||
void updateScreenCoordinates();
|
void updateScreenCoordinates();
|
||||||
@@ -165,12 +167,14 @@ namespace battleship{
|
|||||||
UnitClass unitClass;
|
UnitClass unitClass;
|
||||||
UnitType type;
|
UnitType type;
|
||||||
std::vector<Order> orders;
|
std::vector<Order> orders;
|
||||||
|
std::string buildableUnitGuiScreen = "";
|
||||||
int health, maxHealth, playerId, lenHpBar = 200;
|
int health, maxHealth, playerId, lenHpBar = 200;
|
||||||
s64 orderLineDispTime = 0, lastFireTime = 0;
|
vb01::s64 orderLineDispTime = 0, lastFireTime = 0;
|
||||||
float lineOfSight;
|
float lineOfSight;
|
||||||
std::vector<GarrisonSlot> garrisonSlots;
|
|
||||||
std::vector<Armor> armorTypes;
|
std::vector<Armor> armorTypes;
|
||||||
std::vector<Weapon*> weapons;
|
std::vector<Weapon*> weapons;
|
||||||
|
std::vector<GarrisonSlot> garrisonSlots;
|
||||||
|
std::vector<BuildableUnit> buildableUnits;
|
||||||
State state = State::STAND_GROUND;
|
State state = State::STAND_GROUND;
|
||||||
|
|
||||||
std::vector<Player*> getSelectingPlayers();
|
std::vector<Player*> getSelectingPlayers();
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ namespace battleship{
|
|||||||
using namespace vb01Gui;
|
using namespace vb01Gui;
|
||||||
using namespace gameBase;
|
using namespace gameBase;
|
||||||
|
|
||||||
UnitButton::UnitButton(Vector2 pos, Vector2 size, string name, string fontPath, int trigger, string imagePath) : Button(pos, size, name, fontPath, trigger, true, imagePath){
|
UnitButton::UnitButton(Vector2 pos, Vector2 size, string name, string fontPath, int trigger, string imagePath, int uid) : Button(pos, size, name, fontPath, trigger, true, imagePath), unitId(uid){
|
||||||
StateManager *stateManager = GameManager::getSingleton()->getStateManager();
|
StateManager *stateManager = GameManager::getSingleton()->getStateManager();
|
||||||
ActiveGameState *activeState = (ActiveGameState*)stateManager->getAppStateByType((int)AppStateType::ACTIVE_STATE);
|
ActiveGameState *activeState = (ActiveGameState*)stateManager->getAppStateByType((int)AppStateType::ACTIVE_STATE);
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -8,8 +8,9 @@ namespace battleship{
|
|||||||
|
|
||||||
class UnitButton : public vb01Gui::Button{
|
class UnitButton : public vb01Gui::Button{
|
||||||
public:
|
public:
|
||||||
UnitButton(vb01::Vector2, vb01::Vector2, std::string, std::string, int, std::string);
|
UnitButton(vb01::Vector2, vb01::Vector2, std::string, std::string, int, std::string, int);
|
||||||
protected:
|
protected:
|
||||||
|
int unitId;
|
||||||
std::vector<Unit*> units;
|
std::vector<Unit*> units;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user