Boss fight now has combat stats and damage so I can now have a boss fight.
This commit is contained in:
parent
8ee3e8736f
commit
63a17d7efa
7 changed files with 58 additions and 9 deletions
27
assets/stories.json
Normal file
27
assets/stories.json
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"rat_king":
|
||||||
|
{"_type": "Storyboard",
|
||||||
|
"image": "test_story",
|
||||||
|
"audio": "rat_king_fight",
|
||||||
|
"layout": [
|
||||||
|
"[a|b|c1]",
|
||||||
|
"[d|e|c2]",
|
||||||
|
"[g|h|i]"
|
||||||
|
],
|
||||||
|
"beats": [
|
||||||
|
["00:00", "a","pan"],
|
||||||
|
["00:06", "a","pan"],
|
||||||
|
["00:13", "b","pan"],
|
||||||
|
["00:19", "g","pan"],
|
||||||
|
["00:25", "h","pan"],
|
||||||
|
["00:29", "h","bounce"],
|
||||||
|
["00:31", "c1","pan"],
|
||||||
|
["00:34", "c2","pan"],
|
||||||
|
["00:39", "d","bounce"],
|
||||||
|
["00:44", "e","shake"],
|
||||||
|
["00:48", "i","pan"],
|
||||||
|
["00:53", "i","shake"],
|
||||||
|
["00:55", "i","bounce"]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
assets/story/rat_king_fight.jpg
Normal file
BIN
assets/story/rat_king_fight.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 MiB |
|
|
@ -3,10 +3,10 @@
|
||||||
#include "animation.hpp"
|
#include "animation.hpp"
|
||||||
|
|
||||||
namespace boss {
|
namespace boss {
|
||||||
Fight::Fight(shared_ptr<World> world, Entity boss_id) :
|
Fight::Fight(shared_ptr<World> world, Entity boss_id, Entity player_id) :
|
||||||
$world(world),
|
$world(world),
|
||||||
$boss_id(boss_id),
|
$boss_id(boss_id),
|
||||||
$ui(world->get<components::AnimatedScene>($boss_id), boss_id)
|
$ui(world, boss_id, player_id)
|
||||||
{
|
{
|
||||||
$ui.init();
|
$ui.init();
|
||||||
}
|
}
|
||||||
|
|
@ -88,6 +88,7 @@ namespace boss {
|
||||||
$ui.move_actor("player", player_pos);
|
$ui.move_actor("player", player_pos);
|
||||||
int attack_id = std::any_cast<int>(data);
|
int attack_id = std::any_cast<int>(data);
|
||||||
boss::System::combat($world, $boss_id, attack_id);
|
boss::System::combat($world, $boss_id, attack_id);
|
||||||
|
$ui.update_stats();
|
||||||
state(State::PLAYER_TURN);
|
state(State::PLAYER_TURN);
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace boss {
|
||||||
sf::Vector2f mouse_pos{0,0};
|
sf::Vector2f mouse_pos{0,0};
|
||||||
int run = 0;
|
int run = 0;
|
||||||
|
|
||||||
Fight(shared_ptr<World> world, DinkyECS::Entity boss_id);
|
Fight(shared_ptr<World> world, Entity boss_id, Entity player_id);
|
||||||
|
|
||||||
bool handle_mouse(gui::Event ev);
|
bool handle_mouse(gui::Event ev);
|
||||||
bool event(gui::Event ev, std::any data);
|
bool event(gui::Event ev, std::any data);
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ namespace boss {
|
||||||
|
|
||||||
dbc::check(world->has<ai::EntityAI>(boss_id), "boss doesn't have an AI");
|
dbc::check(world->has<ai::EntityAI>(boss_id), "boss doesn't have an AI");
|
||||||
|
|
||||||
return make_shared<boss::Fight>(world, boss_id);
|
return make_shared<boss::Fight>(world, boss_id, level.player);
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::combat(std::shared_ptr<DinkyECS::World> world, DinkyECS::Entity boss_id, int attack_id) {
|
void System::combat(std::shared_ptr<DinkyECS::World> world, DinkyECS::Entity boss_id, int attack_id) {
|
||||||
|
|
@ -55,8 +55,8 @@ namespace boss {
|
||||||
dbc::check(world->has<ai::EntityAI>(boss_id), "boss doesn't have an AI");
|
dbc::check(world->has<ai::EntityAI>(boss_id), "boss doesn't have an AI");
|
||||||
|
|
||||||
auto& player_combat = world->get<Combat>(level.player);
|
auto& player_combat = world->get<Combat>(level.player);
|
||||||
auto& boss_ai = world->get<ai::EntityAI>(boss_id);
|
|
||||||
auto& boss_combat = world->get<Combat>(boss_id);
|
auto& boss_combat = world->get<Combat>(boss_id);
|
||||||
|
auto& boss_ai = world->get<ai::EntityAI>(boss_id);
|
||||||
|
|
||||||
combat::BattleEngine battle;
|
combat::BattleEngine battle;
|
||||||
battle.add_enemy({boss_id, boss_ai, boss_combat});
|
battle.add_enemy({boss_id, boss_ai, boss_combat});
|
||||||
|
|
|
||||||
19
boss/ui.cpp
19
boss/ui.cpp
|
|
@ -3,14 +3,19 @@
|
||||||
#include "constants.hpp"
|
#include "constants.hpp"
|
||||||
#include "components.hpp"
|
#include "components.hpp"
|
||||||
#include "animation.hpp"
|
#include "animation.hpp"
|
||||||
|
#include <fmt/xchar.h>
|
||||||
|
#include "game_level.hpp"
|
||||||
|
|
||||||
namespace boss {
|
namespace boss {
|
||||||
using namespace guecs;
|
using namespace guecs;
|
||||||
|
using namespace DinkyECS;
|
||||||
|
|
||||||
UI::UI(components::AnimatedScene& scene, Entity boss_id) :
|
UI::UI(shared_ptr<World> world, Entity boss_id, Entity player_id) :
|
||||||
|
$world(world),
|
||||||
$boss_id(boss_id),
|
$boss_id(boss_id),
|
||||||
|
$player_id(player_id),
|
||||||
$combat_ui(true),
|
$combat_ui(true),
|
||||||
$arena(scene),
|
$arena(world->get<components::AnimatedScene>($boss_id)),
|
||||||
$view_texture({BOSS_VIEW_WIDTH, BOSS_VIEW_HEIGHT}),
|
$view_texture({BOSS_VIEW_WIDTH, BOSS_VIEW_HEIGHT}),
|
||||||
$view_sprite($view_texture.getTexture())
|
$view_sprite($view_texture.getTexture())
|
||||||
{
|
{
|
||||||
|
|
@ -33,7 +38,7 @@ namespace boss {
|
||||||
|
|
||||||
auto stats = $actions.entity("stats");
|
auto stats = $actions.entity("stats");
|
||||||
$actions.set<Rectangle>(stats, {});
|
$actions.set<Rectangle>(stats, {});
|
||||||
$actions.set<Text>(stats, {L"stats"});
|
update_stats();
|
||||||
|
|
||||||
$actions.init();
|
$actions.init();
|
||||||
|
|
||||||
|
|
@ -41,6 +46,14 @@ namespace boss {
|
||||||
$combat_ui.init(cell.x, cell.y, cell.w, cell.h);
|
$combat_ui.init(cell.x, cell.y, cell.w, cell.h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UI::update_stats() {
|
||||||
|
auto& player_combat = $world->get<components::Combat>($player_id);
|
||||||
|
auto& boss_combat = $world->get<components::Combat>($boss_id);
|
||||||
|
|
||||||
|
$actions.show_text("stats", fmt::format(
|
||||||
|
L"PLAYER: {}\nBOSS: {}", player_combat.hp, boss_combat.hp));
|
||||||
|
}
|
||||||
|
|
||||||
void UI::render(sf::RenderWindow& window) {
|
void UI::render(sf::RenderWindow& window) {
|
||||||
$actions.render(window);
|
$actions.render(window);
|
||||||
$combat_ui.render(window);
|
$combat_ui.render(window);
|
||||||
|
|
|
||||||
10
boss/ui.hpp
10
boss/ui.hpp
|
|
@ -9,11 +9,18 @@ namespace components {
|
||||||
struct Animation;
|
struct Animation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// needed to break an include cycle
|
||||||
|
namespace GameDB {
|
||||||
|
struct Level;
|
||||||
|
}
|
||||||
|
|
||||||
namespace boss {
|
namespace boss {
|
||||||
using std::shared_ptr;
|
using std::shared_ptr;
|
||||||
|
|
||||||
struct UI {
|
struct UI {
|
||||||
|
shared_ptr<DinkyECS::World> $world = nullptr;
|
||||||
DinkyECS::Entity $boss_id = DinkyECS::NONE;
|
DinkyECS::Entity $boss_id = DinkyECS::NONE;
|
||||||
|
DinkyECS::Entity $player_id = DinkyECS::NONE;
|
||||||
gui::CombatUI $combat_ui;
|
gui::CombatUI $combat_ui;
|
||||||
scene::Engine $arena;
|
scene::Engine $arena;
|
||||||
guecs::UI $actions;
|
guecs::UI $actions;
|
||||||
|
|
@ -21,7 +28,7 @@ namespace boss {
|
||||||
sf::Sprite $view_sprite;
|
sf::Sprite $view_sprite;
|
||||||
cinematic::Camera $camera;
|
cinematic::Camera $camera;
|
||||||
|
|
||||||
UI(components::AnimatedScene &scene, DinkyECS::Entity boss_id);
|
UI(shared_ptr<DinkyECS::World> world, DinkyECS::Entity boss_id, DinkyECS::Entity player_id);
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void render(sf::RenderWindow& window);
|
void render(sf::RenderWindow& window);
|
||||||
|
|
@ -29,6 +36,7 @@ namespace boss {
|
||||||
void status(const std::wstring& msg);
|
void status(const std::wstring& msg);
|
||||||
void move_actor(const std::string& actor, const std::string& cell_name);
|
void move_actor(const std::string& actor, const std::string& cell_name);
|
||||||
void animate_actor(const std::string& actor);
|
void animate_actor(const std::string& actor);
|
||||||
|
void update_stats();
|
||||||
void play_animations();
|
void play_animations();
|
||||||
void zoom(const std::string &cell);
|
void zoom(const std::string &cell);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue