added new resources

This commit is contained in:
devZoGok
2023-09-30 14:36:17 +03:00
parent 267c1f60f2
commit 056ccdd08a
3 changed files with 35 additions and 13 deletions
+23 -10
View File
@@ -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();
+2 -2
View File
@@ -30,7 +30,7 @@ namespace battleship{
inline std::vector<Unit*>& 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<vb01::Vector2> unitScreenPosVec;
std::vector<vb01::Node*> unitLightNodes;
+10 -1
View File
@@ -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<Unit*> units, selectedUnits;
vb01::Vector3 spawnPoint;
};