mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
incrementing player stats
This commit is contained in:
+3
-1
@@ -21,8 +21,10 @@ namespace battleship{
|
||||
structure->incrementBuildStatus();
|
||||
lastIncrementTime = getTime();
|
||||
}
|
||||
else if(structure->getBuildStatus() >= 100)
|
||||
else if(structure->getBuildStatus() >= 100){
|
||||
removeOrder(0);
|
||||
player->incStructuresBuilt();
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -55,6 +55,8 @@ namespace battleship{
|
||||
|
||||
unitQueue.erase(unitQueue.begin());
|
||||
trainingStatus = 0;
|
||||
|
||||
player->incVehiclesBuilt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,12 +55,12 @@ namespace battleship{
|
||||
inline int getNumStructuresBuilt(){return structuresBuilt;}
|
||||
inline int getNumStructuresDestroyed(){return structuresDestroyed;}
|
||||
inline int getNumStructuresLost(){return structuresLost;}
|
||||
inline void setNumVehiclesBuilt(int vb){vehiclesBuilt = vb;}
|
||||
inline void setNumVehiclesDestroyed(int vd){vehiclesDestroyed = vd;}
|
||||
inline void setNumVehiclesLost(int vl){vehiclesLost = vl;}
|
||||
inline void setNumStructuresBuilt(int sb){structuresBuilt = sb;}
|
||||
inline void setNumStructuresDestroyed(int sd){structuresDestroyed = sd;}
|
||||
inline void setNumStructuresLost(int sl){structuresLost = sl;}
|
||||
inline void incVehiclesBuilt(){vehiclesBuilt++;}
|
||||
inline void incVehiclesDestroyed(){vehiclesDestroyed++;}
|
||||
inline void incVehiclesLost(){vehiclesLost++;}
|
||||
inline void incStructuresBuilt(){structuresBuilt++;}
|
||||
inline void incStructuresDestroyed(){structuresDestroyed++;}
|
||||
inline void incStructuresLost(){structuresLost++;}
|
||||
inline vb01::Vector3 getColor(){return color;}
|
||||
inline std::string getName(){return name;}
|
||||
private:
|
||||
|
||||
@@ -9,4 +9,8 @@ namespace battleship{
|
||||
placeAt(pos);
|
||||
orientAt(rot);
|
||||
}
|
||||
|
||||
ResourceDeposit::~ResourceDeposit(){
|
||||
destroyModel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace battleship{
|
||||
class ResourceDeposit : public GameObject{
|
||||
public:
|
||||
ResourceDeposit(Player*, int, vb01::Vector3, vb01::Quaternion);
|
||||
~ResourceDeposit();
|
||||
private:
|
||||
};
|
||||
}
|
||||
|
||||
+4
-8
@@ -15,15 +15,8 @@ namespace battleship{
|
||||
StatsButton::StatsButton(Vector2 pos, Vector2 size, string name, int trigger, string imagePath) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, true, imagePath){}
|
||||
|
||||
void StatsButton::addPlayerDataGuiElements(int playerId){
|
||||
string fontPath = GameManager::getSingleton()->getPath() + "Fonts/batang.ttf";
|
||||
Player *player = Game::getSingleton()->getPlayer(playerId);
|
||||
|
||||
Root *root = Root::getSingleton();
|
||||
Material *mat = new Material(root->getLibPath() + "text");
|
||||
mat->addBoolUniform("texturingEnabled", false);
|
||||
mat->addVec4Uniform("diffuseColor", Vector4(1, 1, 1, 1));
|
||||
|
||||
const int numPairs = 7;
|
||||
Player *player = Game::getSingleton()->getPlayer(playerId);
|
||||
pair<string, wstring> unitDataPairs[numPairs]{
|
||||
make_pair("pl", stringToWstring(player->getName())),
|
||||
make_pair("vb", to_wstring(player->getNumVehiclesBuilt())),
|
||||
@@ -33,8 +26,11 @@ namespace battleship{
|
||||
make_pair("sd", to_wstring(player->getNumStructuresDestroyed())),
|
||||
make_pair("sl", to_wstring(player->getNumStructuresLost())),
|
||||
};
|
||||
|
||||
ConcreteGuiManager *guiManager = ConcreteGuiManager::getSingleton();
|
||||
Vector3 plCol = player->getColor();
|
||||
Root *root = Root::getSingleton();
|
||||
string fontPath = GameManager::getSingleton()->getPath() + "Fonts/batang.ttf";
|
||||
|
||||
for(int i = 0; i < numPairs; i++){
|
||||
Text *category = guiManager->getText(unitDataPairs[i].first);
|
||||
|
||||
@@ -145,9 +145,23 @@ namespace battleship{
|
||||
|
||||
Unit *targetUnit = orders[0].targets[0].unit;
|
||||
|
||||
if(targetUnit)
|
||||
if(targetUnit){
|
||||
targetUnit->takeDamage(damage);
|
||||
|
||||
if(targetUnit->getHealth() <= DEATH_HP){
|
||||
Player *targUnitPlayer = targetUnit->getPlayer();
|
||||
|
||||
if(targetUnit->isVehicle()){
|
||||
player->incVehiclesDestroyed();
|
||||
targUnitPlayer->incVehiclesLost();
|
||||
}
|
||||
else{
|
||||
player->incStructuresDestroyed();
|
||||
targUnitPlayer->incStructuresLost();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastFireTime = getTime();
|
||||
}
|
||||
|
||||
@@ -187,7 +201,7 @@ namespace battleship{
|
||||
for(GarrisonSlot &slot : garrisonSlots)
|
||||
displayUnitStats(slot.foreground, slot.background, (int)((bool)slot.vehicle), (int)true, mainPlayerSelecting, slot.offset);
|
||||
|
||||
if (health <= 0)
|
||||
if (health <= DEATH_HP)
|
||||
blowUp();
|
||||
}
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ namespace battleship{
|
||||
inline UnitClass getUnitClass() {return unitClass;}
|
||||
inline void takeDamage(int damage) {health -= damage;}
|
||||
inline int getPlayerId() {return playerId;}
|
||||
inline int getHealth(){return health;}
|
||||
inline bool isVehicle(){return gameBase::generateView()["units"]["isVehicle"][id + 1];}
|
||||
inline bool isTargetToTheRight(vb01::Vector3 dir, vb01::Vector3 lv){return lv.getAngleBetween(dir) > vb01::PI / 2;}
|
||||
private:
|
||||
@@ -99,7 +100,7 @@ namespace battleship{
|
||||
void init();
|
||||
inline bool canDisplayOrderLine(){return vb01::getTime() - orderLineDispTime < orderVecDispLength;}
|
||||
|
||||
const int orderVecDispLength = 2000;
|
||||
const int orderVecDispLength = 2000, DEATH_HP = 0;
|
||||
sf::SoundBuffer *selectionSfxBuffer;
|
||||
sf::Sound *selectionSfx = nullptr;
|
||||
vb01::Node *hpBackgroundNode = nullptr, *hpForegroundNode = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user