// // Created by Zoe Roux on 2021-06-14. // #include #include "System/Movable/MovableSystem.hpp" #include #include #include #include #include "Component/Button/ButtonComponent.hpp" #include "Component/Renderer/CameraComponent.hpp" #include "Component/Renderer/Drawable2DComponent.hpp" #include "Runner.hpp" #include "Models/GameState.hpp" #include #include #include #include "System/Sound/PlayerSoundManagerSystem.hpp" #include "System/Music/MusicSystem.hpp" #include "System/Lobby/LobbySystem.hpp" #include "Component/Lobby/LobbyComponent.hpp" namespace RAY3D = RAY::Drawables::Drawables3D; namespace RAY2D = RAY::Drawables::Drawables2D; namespace BBM { std::shared_ptr Runner::loadLobbyScene() { static const std::map sounds = { {SoundComponent::JUMP, "assets/sounds/click.ogg"} }; auto scene = std::make_shared(); addMenuControl(*scene); scene->addEntity("Control entity") .addComponent("assets/musics/music_player_select.ogg") .addComponent(sounds); scene->addEntity("background") .addComponent() .addComponent("assets/plain_menu_background.png"); scene->addEntity("lobby text") .addComponent(1920 / 2.75, 100, 0) .addComponent("Get Ready", 120, RAY::Vector2(), ORANGE); auto &play = scene->addEntity("play button") .addComponent(1920 / 2.5, 1080 - 180, 0) .addComponent("assets/buttons/button_new_game.png") .addComponent([](WAL::Entity &entity, WAL::Wal &wal) { auto *texture = dynamic_cast(entity.getComponent().drawable.get()); texture->use("assets/buttons/button_new_game.png"); }) .addComponent([](WAL::Entity &entity, WAL::Wal &wal) { auto *texture = dynamic_cast(entity.getComponent().drawable.get()); texture->use("assets/buttons/button_new_game_hovered.png"); }) .addComponent([](WAL::Entity &entity, WAL::Wal &wal) { if (Runner::gameState.currentScene != GameState::LobbyScene || !LobbySystem::playersAreReady(*wal.getScene())) return; LobbySystem::switchToGame(wal); }) .addComponent>(); auto &back = scene->addEntity("back to menu") .addComponent(10, 1080 - 85, 0) .addComponent("assets/buttons/button_back.png") .addComponent([](WAL::Entity &entity, WAL::Wal &) { gameState.nextScene = BBM::GameState::SceneID::MainMenuScene; }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); texture->use("assets/buttons/button_back.png"); }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); texture->use("assets/buttons/button_back_hovered.png"); }); auto &lavaOption = scene->addEntity("lava option text") .addComponent(1920 / 6, 2 * 1080 / 3, 0) .addComponent("Lava: Off", 70, RAY::Vector2(), BLACK) .addComponent([](WAL::Entity &entity, WAL::Wal &wal) { RAY2D::Text *text = dynamic_cast(entity.getComponent().drawable.get()); if (text->getString().find("Off") != std::string::npos) { text->setText("Lava: On"); //do } else { text->setText("Lava: Off"); //do } }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { entity.getComponent().drawable->setColor(BLACK); }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { entity.getComponent().drawable->setColor(ORANGE); }); auto &heightOption = scene->addEntity("Height option text") .addComponent(1920 / 1.75, 2 * 1080 / 3, 0) .addComponent("2nd Level: Off", 70, RAY::Vector2(), BLACK) .addComponent([](WAL::Entity &entity, WAL::Wal &wal) { RAY2D::Text *text = dynamic_cast(entity.getComponent().drawable.get()); if (text->getString().find("Off") != std::string::npos) { text->setText("2nd Level: On"); //do } else { text->setText("2nd Level: Off"); //do } }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { entity.getComponent().drawable->setColor(BLACK); }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { entity.getComponent().drawable->setColor(ORANGE); }); for (int i = 0; i < 4; i++) { auto &playerTile = scene->addEntity("player tile") .addComponent(224 * (i + 1) + 200 * i, 1080 / 3, 0) .addComponent(RAY::Vector2(224 * (i + 1) + 200 * i, 1080 / 3), RAY::Vector2(200, 200), RAY::Color(0, 0, 0, 0)); auto &player = scene->addEntity("player") .addComponent(224 * (i + 1) + 200 * i, 1080 / 3, 0) .addComponent("assets/player/icons/none.png"); auto &ready = scene->addEntity("ready") .addComponent(224 * (i + 1) + 200 * i, 1080 / 3, 0) .addComponent(); player.addComponent(i, ready, playerTile); } scene->addEntity("camera") .addComponent(8, 20, 7) .addComponent(Vector3f(8, 0, 8)); play.getComponent().setButtonLinks(&lavaOption, &back, &back, nullptr); back.getComponent().setButtonLinks(&play, nullptr, nullptr, &play); lavaOption.getComponent().setButtonLinks(nullptr, &play, nullptr, &heightOption); heightOption.getComponent().setButtonLinks(nullptr, &play, &lavaOption, nullptr); return scene; } }