diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2025-01-09 21:14:35 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2025-01-09 21:14:35 +0100 |
commit | f6683fa71fa670cfbe6aa6233fafb869295da11a (patch) | |
tree | a46ee1d8856b5f0e0298abbab9c92ba21509d830 /game/menus/shop/ShopLoadScript.cpp | |
parent | 296c7b8becc04fa0eeef7c732e5c62a26de45570 (diff) |
added shop functionality
Diffstat (limited to 'game/menus/shop/ShopLoadScript.cpp')
-rw-r--r-- | game/menus/shop/ShopLoadScript.cpp | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/game/menus/shop/ShopLoadScript.cpp b/game/menus/shop/ShopLoadScript.cpp new file mode 100644 index 0000000..a9f9bfe --- /dev/null +++ b/game/menus/shop/ShopLoadScript.cpp @@ -0,0 +1,131 @@ +#include "ShopLoadScript.h" +#include <crepe/ValueBroker.h> +#include "api/Button.h" +#include "api/Sprite.h" +#include "Shopconfig.h" +#include "api/Text.h" +#include "manager/SaveManager.h" + +using namespace crepe; +using namespace std; + +void ShopLoadScript::init() { + this->update(); + this->subscribe<ShopUpdate>([this](const ShopUpdate e) { + return this->update(); + }); +} + +bool ShopLoadScript::update(){ + SaveManager & save = this->get_save_manager(); + ValueBroker<int> buy_bullet = save.get<int>(BUY_BULLET_SAVE,0); + ValueBroker<int> buy_bubble = save.get<int>(BUY_BUBBLE_SAVE,0); + + + if(buy_bullet.get()){ + auto sprites = this->get_components_by_tag<Sprite>(BUY_BULLET); + for(auto sprite : sprites){ + sprite.get().active = false; + } + auto buttons = this->get_components_by_tag<Button>(BUY_BULLET); + for(auto btn : buttons){ + btn.get().active = false; + } + auto texts = this->get_components_by_tag<Text>(BUY_BULLET); + for(auto txt : texts){ + txt.get().active = false; + } + auto sprites1 = this->get_components_by_tag<Sprite>(SELECT_BULLET); + for(auto sprite : sprites1){ + sprite.get().active = true; + } + auto buttons1 = this->get_components_by_tag<Button>(SELECT_BULLET); + for(auto btn : buttons1){ + btn.get().active = true; + } + auto texts1 = this->get_components_by_tag<Text>(SELECT_BULLET); + for(auto txt : texts1){ + txt.get().active = true; + } + } + else { + auto sprites = this->get_components_by_tag<Sprite>(SELECT_BULLET); + for(auto sprite : sprites){ + sprite.get().active = false; + } + auto buttons = this->get_components_by_tag<Button>(SELECT_BULLET); + for(auto btn : buttons){ + btn.get().active = false; + } + auto texts = this->get_components_by_tag<Text>(SELECT_BULLET); + for(auto txt : texts){ + txt.get().active = false; + } + auto sprites1 = this->get_components_by_tag<Sprite>(BUY_BULLET); + for(auto sprite : sprites1){ + sprite.get().active = true; + } + auto buttons1 = this->get_components_by_tag<Button>(BUY_BULLET); + for(auto btn : buttons1){ + btn.get().active = true; + } + auto texts1 = this->get_components_by_tag<Text>(BUY_BULLET); + for(auto txt : texts1){ + txt.get().active = true; + } + } + + if(buy_bubble.get()){ + auto sprites = this->get_components_by_tag<Sprite>(BUY_BUBBLE); + for(auto sprite : sprites){ + sprite.get().active = false; + } + auto buttons = this->get_components_by_tag<Button>(BUY_BUBBLE); + for(auto btn : buttons){ + btn.get().active = false; + } + auto texts = this->get_components_by_tag<Text>(BUY_BUBBLE); + for(auto txt : texts){ + txt.get().active = false; + } + auto sprites1 = this->get_components_by_tag<Sprite>(SELECT_BUBBLE); + for(auto sprite : sprites1){ + sprite.get().active = true; + } + auto buttons1 = this->get_components_by_tag<Button>(SELECT_BUBBLE); + for(auto btn : buttons1){ + btn.get().active = true; + } + auto texts1 = this->get_components_by_tag<Text>(SELECT_BUBBLE); + for(auto txt : texts1){ + txt.get().active = true; + } + } + else { + auto sprites = this->get_components_by_tag<Sprite>(SELECT_BUBBLE); + for(auto sprite : sprites){ + sprite.get().active = false; + } + auto buttons = this->get_components_by_tag<Button>(SELECT_BUBBLE); + for(auto btn : buttons){ + btn.get().active = false; + } + auto texts = this->get_components_by_tag<Text>(SELECT_BUBBLE); + for(auto txt : texts){ + txt.get().active = false; + } + auto sprites1 = this->get_components_by_tag<Sprite>(BUY_BUBBLE); + for(auto sprite : sprites1){ + sprite.get().active = true; + } + auto buttons1 = this->get_components_by_tag<Button>(BUY_BUBBLE); + for(auto btn : buttons1){ + btn.get().active = true; + } + auto texts1 = this->get_components_by_tag<Text>(BUY_BUBBLE); + for(auto txt : texts1){ + txt.get().active = true; + } + } + return false; +} |