mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
unit unlock research
This commit is contained in:
@@ -18,7 +18,8 @@ namespace battleship{
|
|||||||
LOAD_SPEED,
|
LOAD_SPEED,
|
||||||
DRAW_RATE,
|
DRAW_RATE,
|
||||||
DRAW_SPEED,
|
DRAW_SPEED,
|
||||||
HACK_RANGE
|
HACK_RANGE,
|
||||||
|
UNIT_UNLOCK
|
||||||
};
|
};
|
||||||
|
|
||||||
Type type;
|
Type type;
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ namespace battleship{
|
|||||||
|
|
||||||
Ability ability;
|
Ability ability;
|
||||||
ability.type = techTable["type"];
|
ability.type = techTable["type"];
|
||||||
ability.ammount = techTable["ammount"].get_or(0);
|
ability.ammount = techTable["ammount"].get_or(0.0);
|
||||||
ability.gameObjType = techTable["gameObjType"];
|
ability.gameObjType = techTable["gameObjType"];
|
||||||
ability.gameObjIds = parseTechTable(i, techKey, "numGameObjIds", "gameObjIds");
|
ability.gameObjIds = parseTechTable(i, techKey, "numGameObjIds", "gameObjIds");
|
||||||
abilities.push_back(ability);
|
abilities.push_back(ability);
|
||||||
@@ -287,4 +287,17 @@ namespace battleship{
|
|||||||
|
|
||||||
return ammount;
|
return ammount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Game::isUnitUnlocked(vector<int> techResearch, int unitId){
|
||||||
|
for(int techId : techResearch){
|
||||||
|
for(int abilId : technologies[techId].abilities){
|
||||||
|
vector<int> ids = abilities[abilId].gameObjIds;
|
||||||
|
|
||||||
|
if(find(ids.begin(), ids.end(), unitId) != ids.end())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,12 +27,14 @@ namespace battleship{
|
|||||||
void changeUnitPlayer(Unit*, Player*);
|
void changeUnitPlayer(Unit*, Player*);
|
||||||
void initTechnologies();
|
void initTechnologies();
|
||||||
float calcAbilFromTech(Ability::Type, std::vector<int>, int, int);
|
float calcAbilFromTech(Ability::Type, std::vector<int>, int, int);
|
||||||
|
bool isUnitUnlocked(std::vector<int>, int);
|
||||||
inline void addFx(Fx f){fx.push_back(f);}
|
inline void addFx(Fx f){fx.push_back(f);}
|
||||||
inline void addPlayer(Player *pl){players.push_back(pl);}
|
inline void addPlayer(Player *pl){players.push_back(pl);}
|
||||||
inline std::vector<Player*>& getPlayers(){return players;}
|
inline std::vector<Player*>& getPlayers(){return players;}
|
||||||
inline Player* getPlayer(int id){return players[id];}
|
inline Player* getPlayer(int id){return players[id];}
|
||||||
inline int getNumPlayers(){return players.size();}
|
inline int getNumPlayers(){return players.size();}
|
||||||
inline Technology getTechnology(int id){return technologies[id];}
|
inline Technology getTechnology(int id){return technologies[id];}
|
||||||
|
inline Ability getAbility(int id){return abilities[id];}
|
||||||
private:
|
private:
|
||||||
Game(){}
|
Game(){}
|
||||||
void resetLuaGameObjects();
|
void resetLuaGameObjects();
|
||||||
|
|||||||
@@ -183,4 +183,8 @@ namespace battleship{
|
|||||||
|
|
||||||
return ucUnits;
|
return ucUnits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::addTechnology(int techId){
|
||||||
|
technologies.push_back(techId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ namespace battleship{
|
|||||||
void selectUnits(std::vector<Unit*>);
|
void selectUnits(std::vector<Unit*>);
|
||||||
std::vector<Unit*> getUnitsById(int, int = -1);
|
std::vector<Unit*> getUnitsById(int, int = -1);
|
||||||
std::vector<Unit*> getUnitsByClass(UnitClass, int = -1);
|
std::vector<Unit*> getUnitsByClass(UnitClass, int = -1);
|
||||||
|
void addTechnology(int);
|
||||||
inline void deselectUnits(){selectedUnits.clear();}
|
inline void deselectUnits(){selectedUnits.clear();}
|
||||||
inline Unit* getSelectedUnit(int id){return selectedUnits[id];}
|
inline Unit* getSelectedUnit(int id){return selectedUnits[id];}
|
||||||
inline std::vector<Unit*> getSelectedUnits(){return selectedUnits;}
|
inline std::vector<Unit*> getSelectedUnits(){return selectedUnits;}
|
||||||
@@ -74,7 +75,6 @@ namespace battleship{
|
|||||||
inline vb01::Vector3 getColor(){return color;}
|
inline vb01::Vector3 getColor(){return color;}
|
||||||
inline std::string getName(){return name;}
|
inline std::string getName(){return name;}
|
||||||
inline std::vector<int> getTechnologies(){return technologies;}
|
inline std::vector<int> getTechnologies(){return technologies;}
|
||||||
inline void addTechnology(int tid){technologies.push_back(tid);}
|
|
||||||
private:
|
private:
|
||||||
bool cpuPlayer = false;
|
bool cpuPlayer = false;
|
||||||
std::vector<int> technologies;
|
std::vector<int> technologies;
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ namespace battleship{
|
|||||||
|
|
||||||
for(int i = 0; i < numBuildableUnits; i++){
|
for(int i = 0; i < numBuildableUnits; i++){
|
||||||
sol::table buTable = unitTable[tblName][i + 1];
|
sol::table buTable = unitTable[tblName][i + 1];
|
||||||
buildableUnits.push_back(BuildableUnit(buTable["id"], buTable["buildable"]));
|
buildableUnits.push_back(BuildableUnit(buTable["id"], game->isUnitUnlocked(currTechs, id) | (bool)buTable["buildable"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user