diff --git a/activeGameState.cpp b/activeGameState.cpp index 6a8dd7e..ece512d 100755 --- a/activeGameState.cpp +++ b/activeGameState.cpp @@ -43,7 +43,12 @@ namespace battleship{ mainPlayer = Map::getSingleton()->getPlayer(playerId); initDragbox(); - initDepthText(); + + refinedsText = initText(Vector2(0, 100)); + wealthText = initText(Vector2(0, 200)); + researchText = initText(Vector2(0, 300)); + textNode = initText(Vector2(0, 400)); + depth = 1; } ActiveGameState::~ActiveGameState() { @@ -65,33 +70,41 @@ namespace battleship{ root->getGuiNode()->attachChild(dragboxNode); } - void ActiveGameState::initDepthText(){ - Root *root = Root::getSingleton(); - Text *t = new Text(GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", L"depth: "); - - Material *tm = new Material(root->getLibPath() + "text"); + Node* ActiveGameState::initText(Vector2 pos){ + Material *tm = new Material(Root::getSingleton()->getLibPath() + "text"); tm->addBoolUniform("texturingEnabled", false); tm->addVec4Uniform("diffuseColor", Vector4(1, 1, 1, 1)); + + Text *t = new Text(GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", L""); t->setMaterial(tm); - textNode = new Node(Vector3(0, 100, 0)); - textNode->addText(t); + Node *node = new Node(Vector3(pos.x, pos.y, 0)); + node->addText(t); - depth = 1; + return node; } void ActiveGameState::onAttached() { AbstractAppState::onAttached(); Root::getSingleton()->getGuiNode()->attachChild(textNode); + Root::getSingleton()->getGuiNode()->attachChild(refinedsText); + Root::getSingleton()->getGuiNode()->attachChild(wealthText); + Root::getSingleton()->getGuiNode()->attachChild(researchText); } void ActiveGameState::onDettached() { AbstractAppState::onDettached(); - Root::getSingleton()->getGuiNode()->attachChild(textNode); + Root::getSingleton()->getGuiNode()->dettachChild(textNode); + Root::getSingleton()->getGuiNode()->dettachChild(refinedsText); + Root::getSingleton()->getGuiNode()->dettachChild(wealthText); + Root::getSingleton()->getGuiNode()->dettachChild(researchText); } void ActiveGameState::update() { textNode->getText(0)->setText(L"Depth: " + to_wstring(depth)); + refinedsText->getText(0)->setText(L"Refineds: " + to_wstring(mainPlayer->getRefineds())); + wealthText->getText(0)->setText(L"Wealth: " + to_wstring(mainPlayer->getWealth())); + researchText->getText(0)->setText(L"Research: " + to_wstring(mainPlayer->getResearch())); if (isSelectionBox) updateSelectionBox(); diff --git a/activeGameState.h b/activeGameState.h index 2db8e28..447dc69 100755 --- a/activeGameState.h +++ b/activeGameState.h @@ -30,7 +30,7 @@ namespace battleship{ inline std::vector& getUnitGroup(int i){return unitGroups[i];} private: void initDragbox(); - void initDepthText(); + vb01::Node* initText(vb01::Vector2); void deselectUnits(); void renderUnits(); void updateSelectionBox(); @@ -43,7 +43,7 @@ namespace battleship{ GuiAppState *guiState; Player *mainPlayer; vb01::Quad *dragbox = nullptr; - vb01::Node *dragboxNode = nullptr, *textNode = nullptr; + vb01::Node *dragboxNode = nullptr, *textNode = nullptr, *refinedsText = nullptr, *wealthText = nullptr, *researchText = nullptr; vb01::Vector2 clickPoint; std::vector unitScreenPosVec; std::vector unitLightNodes; diff --git a/player.h b/player.h index 215e613..932372d 100755 --- a/player.h +++ b/player.h @@ -31,8 +31,17 @@ namespace battleship{ inline int getFaction(){return faction;} inline int getSide(){return side;} inline vb01::Vector3 getSpawnPoint(){return spawnPoint;} + inline int getRefineds(){return refineds;} + inline void setRefineds(int ref){this->refineds = ref;} + inline void addRefineds(int ref){this->refineds += ref;} + inline int getWealth(){return wealth;} + inline void setWealth(int w){this->wealth = w;} + inline void addWealth(int w){this->wealth += w;} + inline int getResearch(){return research;} + inline void setResearch(int r){this->research = r;} + inline void addResearch(int r){this->research += r;} private: - int credits, faction, difficulty,side,id; + int refineds = 0, wealth = 0, research = 0, faction, difficulty,side,id; std::vector units, selectedUnits; vb01::Vector3 spawnPoint; };