diff --git a/resources/config/game_over.json b/resources/config/game_over.json index fe448c6..4fcac9d 100644 --- a/resources/config/game_over.json +++ b/resources/config/game_over.json @@ -14,40 +14,78 @@ { "type": "Button", "name": "gameOverText", - "x": 350, - "y": 400, - "width": 600, - "height": 150, + "x": 476.5, + "y": 500, + "width": 327, + "height": 26, "textures": { - "normal": "resources/gameover.png", - "hover": "resources/gameover.png", - "pressed": "resources/gameover.png" + "normal": "resources/game_over/MissionFailed.png", + "hover": "resources/game_over/MissionFailed.png", + "pressed": "resources/game_over/MissionFailed.png" } }, { "type": "Button", - "name": "restartButton", - "x": 350, - "y": 300, - "width": 300, - "height": 80, + "name": "underlineBtn", + "x": 556, + "y": 465, + "width": 168, + "height": 44, "textures": { - "normal": "resources/shoot_normal.png", - "hover": "resources/shoot_normal.png", - "pressed": "resources/shoot_normal.png" + "normal": "resources/game_over/Container.png", + "hover": "resources/game_over/Container.png", + "pressed": "resources/game_over/Container.png" + } + }, + { + "type": "Button", + "name": "finalscore", + "x": 596.5, + "y": 436, + "width": 87, + "height": 9, + "textures": { + "normal": "resources/game_over/FinalScore.png", + "hover": "resources/game_over/FinalScore.png", + "pressed": "resources/game_over/FinalScore.png" + } + }, + { + "type": "TextView", + "name": "scoreText", + "x": 350, + "y": 356, + "width": 600, + "height": 80, + "text": "0", + "fontSize": 36, + "color": [0, 217, 255, 1], + "align": "center" + }, + { + "type": "Button", + "name": "restartButton", + "x": 449, + "y": 308, + "width": 382, + "height": 56, + "textures": { + "normal": "resources/game_over/Filledbuttons.png", + "hover": "resources/game_over/Filledbuttons.png", + "pressed": "resources/game_over/Filledbuttons.png" } }, { "type": "Button", "name": "gameOverExitButton", - "x": 650, - "y": 300, - "width": 300, - "height": 80, + "x": 449, + "y": 240, + "width": 382, + "height": 56, "textures": { - "normal": "resources/sand2.png", - "hover": "resources/sand2.png", - "pressed": "resources/sand2.png" + "normal": "resources/game_over/Secondarybutton.png", + "hover": "resources/game_over/Secondarybutton.png", + "pressed": "resources/game_over/Secondarybutton.png" } } ] diff --git a/resources/game_over/Container.png b/resources/game_over/Container.png new file mode 100644 index 0000000..226e276 --- /dev/null +++ b/resources/game_over/Container.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d495f21543ab72e6a2cb5082507212616c666bef11bc99bd0447e6906a957836 +size 6709 diff --git a/resources/game_over/Filledbuttons.png b/resources/game_over/Filledbuttons.png new file mode 100644 index 0000000..808344f --- /dev/null +++ b/resources/game_over/Filledbuttons.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f6283a169f71822d3c3f8b3c80369cd3ac25b70ef51d3f34685687b1d2819a1b +size 2406 diff --git a/resources/game_over/FinalScore.png b/resources/game_over/FinalScore.png new file mode 100644 index 0000000..7ac0bbc --- /dev/null +++ b/resources/game_over/FinalScore.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6bb6e8e59482729d6da84188c830842cf07e4e379076ba64d7916b8b0d45cf09 +size 1244 diff --git a/resources/game_over/MissionFailed.png b/resources/game_over/MissionFailed.png new file mode 100644 index 0000000..1a8731d --- /dev/null +++ b/resources/game_over/MissionFailed.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:930565f3911bcb11904808fe67ca278c1460f42f7c7c7dcfffc2301f5c0d408c +size 2678 diff --git a/resources/game_over/Secondarybutton.png b/resources/game_over/Secondarybutton.png new file mode 100644 index 0000000..5bb684a --- /dev/null +++ b/resources/game_over/Secondarybutton.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:00a1c3c32da992686febd87918801868d4af2ec99904ed3f80b0c8f58009c5b2 +size 1840 diff --git a/src/MenuManager.cpp b/src/MenuManager.cpp index 459f33c..b87a72e 100644 --- a/src/MenuManager.cpp +++ b/src/MenuManager.cpp @@ -38,7 +38,7 @@ namespace ZL { uiManager.startAnimationOnNode("backgroundNode", "bgScroll"); static bool isExitButtonAnimating = false; uiManager.setAnimationCallback("settingsButton", "buttonsExit", [this]() { - std::cerr << "Settings button animation finished -> переход в настройки" << std::endl; + std::cerr << "Settings button animation finished -> ??????? ? ?????????" << std::endl; if (uiManager.pushMenuFromSavedRoot(settingsSavedRoot)) { uiManager.setButtonCallback("Opt1", [this](const std::string& n) { std::cerr << "Opt1 pressed: " << n << std::endl; @@ -258,14 +258,17 @@ namespace ZL { }); } - void MenuManager::showGameOver() + void MenuManager::showGameOver(int score) { if (!uiGameOverShown) { if (uiManager.pushMenuFromSavedRoot(gameOverSavedRoot)) { + uiManager.setText("scoreText", std::string("Score: ") + std::to_string(score)); + uiManager.setButtonCallback("restartButton", [this](const std::string& name) { + uiManager.setText("scoreText", ""); uiGameOverShown = false; uiManager.popMenu(); - onRestartPressed(); + if (onRestartPressed) onRestartPressed(); }); uiManager.setButtonCallback("gameOverExitButton", [this](const std::string& name) { diff --git a/src/MenuManager.h b/src/MenuManager.h index 2bb4819..0b33f2b 100644 --- a/src/MenuManager.h +++ b/src/MenuManager.h @@ -28,7 +28,8 @@ namespace ZL { void setupMenu(); - void showGameOver(); + //void showGameOver(); + void showGameOver(int score); std::function onRestartPressed; std::function onVelocityChanged; diff --git a/src/Space.cpp b/src/Space.cpp index fef7a82..146d7bc 100644 --- a/src/Space.cpp +++ b/src/Space.cpp @@ -276,7 +276,7 @@ namespace ZL std::cerr << "Client: Failed to send RESPAWN\n"; } } - + this->playerScore = 0; std::cerr << "Game restarted\n"; }; @@ -1598,7 +1598,7 @@ namespace ZL std::cerr << "GAME OVER: collision with planet (moved back and exploded)\n"; - menuManager.showGameOver(); + menuManager.showGameOver(this->playerScore); } else { bool stoneCollided = false; @@ -1673,7 +1673,7 @@ namespace ZL planetObject.planetStones.statuses[collidedTriIdx] = ChunkStatus::Empty; } - menuManager.showGameOver(); + menuManager.showGameOver(this->playerScore); } } } @@ -1777,12 +1777,17 @@ namespace ZL shipAlive = false; gameOver = true; Environment::shipState.velocity = 0.0f; - menuManager.showGameOver(); + menuManager.showGameOver(this->playerScore); } else { deadRemotePlayers.insert(d.targetId); std::cout << "Marked remote player " << d.targetId << " as dead" << std::endl; } + if (d.killerId == localId) { + this->playerScore += 1; + std::cout << "Client: Increased local score to " << this->playerScore << std::endl; + + } } } diff --git a/src/Space.h b/src/Space.h index dde0f69..894fa39 100644 --- a/src/Space.h +++ b/src/Space.h @@ -122,6 +122,7 @@ namespace ZL { static constexpr float CLOSE_DIST = 600.0f; std::unordered_set deadRemotePlayers; + int playerScore = 0; static constexpr float TARGET_MAX_DIST = 50000.0f; static constexpr float TARGET_MAX_DIST_SQ = TARGET_MAX_DIST * TARGET_MAX_DIST;