mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-28 00:31:50 +00:00
95 lines
4.0 KiB
C++
95 lines
4.0 KiB
C++
//
|
|
// Created by hbenjamin on 15/06/2021.
|
|
//
|
|
|
|
#include <Wal.hpp>
|
|
#include "System/Movable/MovableSystem.hpp"
|
|
#include <Model/Model.hpp>
|
|
#include <Drawables/2D/Rectangle.hpp>
|
|
#include <Drawables/2D/Text.hpp>
|
|
#include <TraceLog.hpp>
|
|
#include "Component/Button/ButtonComponent.hpp"
|
|
#include "Component/Renderer/CameraComponent.hpp"
|
|
#include "Component/Renderer/Drawable2DComponent.hpp"
|
|
#include "Runner.hpp"
|
|
#include "Models/GameState.hpp"
|
|
#include <Component/Animator/AnimatorComponent.hpp>
|
|
#include <Component/Tag/TagComponent.hpp>
|
|
#include <Drawables/Texture.hpp>
|
|
#include <System/Lobby/ResumeLobbySystem.hpp>
|
|
#include "System/Music/MusicSystem.hpp"
|
|
#include "Component/Lobby/LobbyComponent.hpp"
|
|
|
|
namespace RAY3D = RAY::Drawables::Drawables3D;
|
|
namespace RAY2D = RAY::Drawables::Drawables2D;
|
|
|
|
namespace BBM
|
|
{
|
|
std::shared_ptr<WAL::Scene> Runner::loadResumeLobbyScene()
|
|
{
|
|
static const std::map<SoundComponent::SoundIndex, std::string> sounds = {
|
|
{SoundComponent::BOMB, "assets/sounds/click.ogg"}
|
|
};
|
|
auto scene = std::make_shared<WAL::Scene>();
|
|
|
|
addMenuControl(*scene);
|
|
scene->addEntity("Control entity")
|
|
.addComponent<MusicComponent>("assets/musics/music_player_select.ogg")
|
|
.addComponent<SoundComponent>(sounds);
|
|
scene->addEntity("background")
|
|
.addComponent<PositionComponent>()
|
|
.addComponent<Drawable2DComponent, RAY::Texture>("assets/backgrounds/menu.png");
|
|
scene->addEntity("white background")
|
|
.addComponent<PositionComponent>(200, 300, 0)
|
|
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(Vector2f(), Vector2f(1525, 325), RAY::Color(WHITE).setA(150));
|
|
scene->addEntity("lobby text")
|
|
.addComponent<PositionComponent>(1920 / 2.75, 100, 0)
|
|
.addComponent<Drawable2DComponent, RAY2D::Text>("Get Ready", 120, RAY::Vector2(), ORANGE);
|
|
auto &play = scene->addEntity("play button")
|
|
.addComponent<PositionComponent>(1920 / 2.5, 1080 - 180, 0)
|
|
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_new_game.png")
|
|
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &wal)
|
|
{
|
|
auto *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
|
texture->use("assets/buttons/button_new_game.png");
|
|
})
|
|
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &wal)
|
|
{
|
|
auto *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
|
texture->use("assets/buttons/button_new_game_hovered.png");
|
|
})
|
|
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &wal)
|
|
{
|
|
if (Runner::gameState.currentScene != GameState::ResumeLobbyScene
|
|
|| !ResumeLobbySystem::playersAreReady(*wal.getScene()))
|
|
return;
|
|
ResumeLobbySystem::resumeToGame(wal);
|
|
})
|
|
.addComponent<TagComponent<ResumeButton>>();
|
|
auto &back = scene->addEntity("back to menu")
|
|
.addComponent<PositionComponent>(10, 1080 - 85, 0)
|
|
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_back.png")
|
|
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &wal)
|
|
{
|
|
wal.getSystem<ResumeLobbySystem>().unloadLobbyFromResume();
|
|
gameState.nextScene = BBM::GameState::SceneID::MainMenuScene;
|
|
})
|
|
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
|
|
{
|
|
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
|
texture->use("assets/buttons/button_back.png");
|
|
})
|
|
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &)
|
|
{
|
|
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
|
|
|
texture->use("assets/buttons/button_back_hovered.png");
|
|
});
|
|
scene->addEntity("camera")
|
|
.addComponent<PositionComponent>(8, 20, 7)
|
|
.addComponent<CameraComponent>(Vector3f(8, 0, 8));
|
|
play.getComponent<OnClickComponent>().setButtonLinks(nullptr, &back, &back);
|
|
back.getComponent<OnClickComponent>().setButtonLinks(&play, nullptr, nullptr, &play);
|
|
return scene;
|
|
}
|
|
} |