mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-27 03:53:33 +00:00
technology research button
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
#include "researchButton.h"
|
||||
#include "activeGameState.h"
|
||||
#include "researchStruct.h"
|
||||
|
||||
#include <stateManager.h>
|
||||
#include <solUtil.h>
|
||||
|
||||
namespace battleship{
|
||||
using namespace vb01;
|
||||
using namespace std;
|
||||
|
||||
ResearchButton::ResearchButton(Vector2 pos, Vector2 size, string name, int trigger, string imagePath, int uid, int tid) :
|
||||
UnitButton(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, imagePath, uid), techId(tid){}
|
||||
|
||||
void ResearchButton::onClick(){
|
||||
ActiveGameState *activeState = (ActiveGameState*)(GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::ACTIVE_STATE));
|
||||
Player *player = activeState->getPlayer();
|
||||
vector<Unit*> selUnits = player->getSelectedUnits(), researchStructs = player->getUnitsById(unitId);
|
||||
|
||||
for(Unit *rs : researchStructs)
|
||||
if(find(selUnits.begin(), selUnits.end(), rs) != selUnits.end())
|
||||
((ResearchStruct*)rs)->appendToQueue(techId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user