mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
structures work only once complete
research structures research when they have min 30% HP
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
#ifndef BUILDABLE_UNIT_H
|
||||
#define BUILDABLE_UNIT_H
|
||||
|
||||
namespace battleship{
|
||||
struct BuildableUnit{
|
||||
int id;
|
||||
bool buildable;
|
||||
|
||||
BuildableUnit(int i, bool build) : id(i), buildable(build){}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -18,6 +18,8 @@ namespace battleship{
|
||||
void Factory::update(){
|
||||
Structure::update();
|
||||
|
||||
if(!isComplete()) return;
|
||||
|
||||
if(!unitQueue.empty())
|
||||
train();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace battleship{
|
||||
}
|
||||
|
||||
void PointDefense::attack(Order order){
|
||||
if(!isComplete()) return;
|
||||
|
||||
Unit *targUnit = order.targets[0].unit;
|
||||
Vector3 targDir = (targUnit ? targUnit->getPos() : order.targets[0].pos) - pos;
|
||||
|
||||
|
||||
+3
-1
@@ -16,7 +16,9 @@ namespace battleship{
|
||||
void ResearchStruct::update(){
|
||||
Structure::update();
|
||||
|
||||
if(player->getRefineds() >= researchCost && canGenerateResearch()){
|
||||
if(!isComplete()) return;
|
||||
|
||||
if(health > .3 * maxHealth && player->getRefineds() >= researchCost && canGenerateResearch()){
|
||||
player->addResearch(generationSpeed);
|
||||
player->subtractRefineds(researchCost);
|
||||
lastGenTime = getTime();
|
||||
|
||||
+2
-2
@@ -109,7 +109,7 @@ namespace battleship{
|
||||
int minDistId = -1;
|
||||
|
||||
for(int i = 0; i < structs.size(); i++)
|
||||
if(structs[i]->getBuildStatus() == 100){
|
||||
if(structs[i]->isComplete()){
|
||||
minDistId = i;
|
||||
break;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ namespace battleship{
|
||||
if(minDistId == -1) return nullptr;
|
||||
|
||||
for(int i = 0; i < structs.size(); i++)
|
||||
if(structs[i]->getBuildStatus() == 100 && structs[minDistId]->getPos().getDistanceFrom(pos) > structs[i]->getPos().getDistanceFrom(pos))
|
||||
if(structs[i]->isComplete() && structs[minDistId]->getPos().getDistanceFrom(pos) > structs[i]->getPos().getDistanceFrom(pos))
|
||||
minDistId = i;
|
||||
|
||||
return structs[minDistId];
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace battleship{
|
||||
Structure(Player*, int, vb01::Vector3, vb01::Quaternion, int = 0, Unit::State = Unit::State::STAND_GROUND);
|
||||
~Structure();
|
||||
virtual void update();
|
||||
inline bool isComplete(){return buildStatus == 100;}
|
||||
inline int getBuildStatus(){return buildStatus;}
|
||||
inline void incrementBuildStatus(){buildStatus++;}
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user