BossFightUI now gets everything from a world and will be implemented like the rest of the game, but as a mini game.
This commit is contained in:
parent
ca18422930
commit
6e8aa48332
4 changed files with 34 additions and 25 deletions
|
@ -5,9 +5,10 @@
|
||||||
namespace gui {
|
namespace gui {
|
||||||
using namespace guecs;
|
using namespace guecs;
|
||||||
|
|
||||||
BossFightUI::BossFightUI(DinkyECS::World& world, std::string boss_name)
|
BossFightUI::BossFightUI(shared_ptr<DinkyECS::World> world, DinkyECS::Entity boss_id)
|
||||||
: $config(world.get_the<components::GameConfig>()),
|
: $world(world),
|
||||||
$boss_name(boss_name)
|
$boss_id(boss_id),
|
||||||
|
$config(world->get_the<components::GameConfig>())
|
||||||
{
|
{
|
||||||
$status.position(0, 0, BOSS_VIEW_X, SCREEN_HEIGHT);
|
$status.position(0, 0, BOSS_VIEW_X, SCREEN_HEIGHT);
|
||||||
$status.layout(
|
$status.layout(
|
||||||
|
@ -24,15 +25,13 @@ namespace gui {
|
||||||
"[overlay_9|overlay_10|overlay_12]"
|
"[overlay_9|overlay_10|overlay_12]"
|
||||||
"[overlay_13|overlay_14|overlay_16]");
|
"[overlay_13|overlay_14|overlay_16]");
|
||||||
|
|
||||||
$sounds = components::get<components::Sound>($config.bosses[boss_name]);
|
$sounds = $world->get<components::Sound>($boss_id);
|
||||||
$combat = components::get<components::Combat>($config.bosses[boss_name]);
|
$combat = $world->get<components::Combat>($boss_id);
|
||||||
$weapon_hit_sound = $config.bosses[$boss_name]["weapon_sound"];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BossFightUI::configure_sprite() {
|
void BossFightUI::configure_sprite() {
|
||||||
auto& boss = $config.bosses[$boss_name];
|
$sprite_config = $world->get<components::Sprite>($boss_id);
|
||||||
$sprite_config = components::get<components::Sprite>(boss);
|
$animation = $world->get<components::Animation>($boss_id);
|
||||||
$animation = components::get<components::Animation>(boss);
|
|
||||||
$animation.texture_width = $sprite_config.width;
|
$animation.texture_width = $sprite_config.width;
|
||||||
|
|
||||||
$boss_image = textures::get($sprite_config.name);
|
$boss_image = textures::get($sprite_config.name);
|
||||||
|
@ -48,8 +47,10 @@ namespace gui {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BossFightUI::configure_background() {
|
void BossFightUI::configure_background() {
|
||||||
auto& boss = $config.bosses[$boss_name];
|
// FIX ME
|
||||||
$boss_background = textures::get(boss["background"]);
|
// auto& config = $world->get_the<components::GameConfig>();
|
||||||
|
std::string boss_bg = "boss_fight_background";
|
||||||
|
$boss_background = textures::get(boss_bg);
|
||||||
$boss_background.sprite->setPosition({BOSS_VIEW_X, BOSS_VIEW_Y});
|
$boss_background.sprite->setPosition({BOSS_VIEW_X, BOSS_VIEW_Y});
|
||||||
$status.world().set_the<Background>({$status.$parser});
|
$status.world().set_the<Background>({$status.$parser});
|
||||||
}
|
}
|
||||||
|
@ -96,10 +97,6 @@ namespace gui {
|
||||||
sound::play($sounds.attack);
|
sound::play($sounds.attack);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!sound::playing($weapon_hit_sound) && $animation.subframe > 1.2 && $animation.subframe < 1.5) {
|
|
||||||
sound::play($weapon_hit_sound);
|
|
||||||
}
|
|
||||||
|
|
||||||
$boss_image.sprite->setTextureRect(frame_rect);
|
$boss_image.sprite->setTextureRect(frame_rect);
|
||||||
window.draw(*$boss_image.sprite);
|
window.draw(*$boss_image.sprite);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,19 +19,19 @@ namespace gui {
|
||||||
public:
|
public:
|
||||||
sf::Clock $clock;
|
sf::Clock $clock;
|
||||||
bool $boss_hit = false;
|
bool $boss_hit = false;
|
||||||
std::string $weapon_hit_sound;
|
|
||||||
components::Combat $combat;
|
components::Combat $combat;
|
||||||
components::Sprite $sprite_config;
|
components::Sprite $sprite_config;
|
||||||
components::Sound $sounds;
|
components::Sound $sounds;
|
||||||
components::Animation $animation;
|
components::Animation $animation;
|
||||||
components::GameConfig& $config;
|
|
||||||
std::string $boss_name;
|
|
||||||
guecs::UI $status;
|
guecs::UI $status;
|
||||||
guecs::UI $overlay;
|
guecs::UI $overlay;
|
||||||
textures::SpriteTexture $boss_image;
|
textures::SpriteTexture $boss_image;
|
||||||
textures::SpriteTexture $boss_background;
|
textures::SpriteTexture $boss_background;
|
||||||
|
std::shared_ptr<DinkyECS::World> $world = nullptr;
|
||||||
|
DinkyECS::Entity $boss_id;
|
||||||
|
components::GameConfig& $config;
|
||||||
|
|
||||||
BossFightUI(DinkyECS::World& world, std::string boss_name);
|
BossFightUI(std::shared_ptr<DinkyECS::World> world, DinkyECS::Entity boss_id);
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void render(sf::RenderWindow& window);
|
void render(sf::RenderWindow& window);
|
||||||
|
|
|
@ -21,12 +21,9 @@ LevelScaling LevelManager::scale_level() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<gui::BossFightUI> LevelManager::create_bossfight(shared_ptr<DinkyECS::World> prev_world) {
|
|
||||||
dbc::check(prev_world != nullptr, "Starter world for boss fights can't be null.");
|
|
||||||
return make_shared<gui::BossFightUI>(*prev_world, "RAT_KING");
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t LevelManager::create_level(shared_ptr<DinkyECS::World> prev_world) {
|
inline shared_ptr<DinkyECS::World> clone_load_world(shared_ptr<DinkyECS::World> prev_world)
|
||||||
|
{
|
||||||
auto world = make_shared<DinkyECS::World>();
|
auto world = make_shared<DinkyECS::World>();
|
||||||
|
|
||||||
if(prev_world != nullptr) {
|
if(prev_world != nullptr) {
|
||||||
|
@ -35,6 +32,22 @@ size_t LevelManager::create_level(shared_ptr<DinkyECS::World> prev_world) {
|
||||||
save::load_configs(*world);
|
save::load_configs(*world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
|
||||||
|
shared_ptr<gui::BossFightUI> LevelManager::create_bossfight(shared_ptr<DinkyECS::World> prev_world) {
|
||||||
|
dbc::check(prev_world != nullptr, "Starter world for boss fights can't be null.");
|
||||||
|
auto world = clone_load_world(prev_world);
|
||||||
|
auto& config = prev_world->get_the<GameConfig>();
|
||||||
|
auto& boss_data = config.bosses["RAT_KING"];
|
||||||
|
auto boss_id = world->entity();
|
||||||
|
components::configure_entity($components, *world, boss_id, boss_data["components"]);
|
||||||
|
|
||||||
|
return make_shared<gui::BossFightUI>(world, boss_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t LevelManager::create_level(shared_ptr<DinkyECS::World> prev_world) {
|
||||||
|
auto world = clone_load_world(prev_world);
|
||||||
auto scaling = scale_level();
|
auto scaling = scale_level();
|
||||||
|
|
||||||
auto map = make_shared<Map>(scaling.map_width, scaling.map_height);
|
auto map = make_shared<Map>(scaling.map_width, scaling.map_height);
|
||||||
|
|
|
@ -11,7 +11,6 @@ struct Stats {
|
||||||
double min = 0.0;
|
double min = 0.0;
|
||||||
double max = 0.0;
|
double max = 0.0;
|
||||||
|
|
||||||
|
|
||||||
inline void reset() {
|
inline void reset() {
|
||||||
sum = 0;
|
sum = 0;
|
||||||
sumsq = 0;
|
sumsq = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue