When there's actions in the arena the camera moves.
This commit is contained in:
parent
63a17d7efa
commit
d244106981
4 changed files with 52 additions and 14 deletions
|
|
@ -14,11 +14,8 @@ namespace boss {
|
|||
|
||||
void System::initialize_boss_ai(DinkyECS::World& world, DinkyECS::Entity boss_id) {
|
||||
dbc::check(world.has<EnemyConfig>(boss_id), "boss doesn't have an AI EnemyConfig");
|
||||
|
||||
auto& config = world.get<EnemyConfig>(boss_id);
|
||||
|
||||
auto ai_start = ai::load_state(config.ai_start_name);
|
||||
|
||||
auto ai_goal = ai::load_state(config.ai_goal_name);
|
||||
|
||||
ai::EntityAI boss_ai(config.ai_script, ai_start, ai_goal);
|
||||
|
|
@ -65,8 +62,6 @@ namespace boss {
|
|||
battle.set_all("in_combat", true);
|
||||
battle.plan();
|
||||
|
||||
battle.dump();
|
||||
|
||||
while(auto act = battle.next()) {
|
||||
auto [enemy, enemy_action] = *act;
|
||||
|
||||
|
|
@ -78,12 +73,10 @@ namespace boss {
|
|||
auto& the_belt = world->get_the<ritual::Belt>();
|
||||
|
||||
dbc::check(the_belt.has(attack_id), "STOP passing invalid attack IDs to the system.");
|
||||
fmt::println("player did damage");
|
||||
}
|
||||
|
||||
if(enemy_action == combat::BattleAction::ATTACK) {
|
||||
result.enemy_did = enemy.combat.attack(player_combat);
|
||||
fmt::println("enemy did damage");
|
||||
}
|
||||
|
||||
// need to replicate this in the boss UI
|
||||
|
|
|
|||
48
boss/ui.cpp
48
boss/ui.cpp
|
|
@ -20,7 +20,7 @@ namespace boss {
|
|||
$view_sprite($view_texture.getTexture())
|
||||
{
|
||||
$view_sprite.setPosition({BOSS_VIEW_X, BOSS_VIEW_Y});
|
||||
$camera.style("bounce");
|
||||
$camera.style("shake");
|
||||
}
|
||||
|
||||
void UI::init() {
|
||||
|
|
@ -50,8 +50,37 @@ namespace boss {
|
|||
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));
|
||||
std::wstring status = fmt::format(
|
||||
L"PLAYER: {}\nBOSS: {}", player_combat.hp, boss_combat.hp);
|
||||
|
||||
if($world->has_event<Events::GUI>()) {
|
||||
auto [evt, entity, data] = $world->recv<Events::GUI>();
|
||||
auto result = std::any_cast<Events::Combat>(data);
|
||||
auto& player_is = $arena.$actors.at($arena.$actor_name_ids.at("player"));
|
||||
auto& boss_is = $arena.$actors.at($arena.$actor_name_ids.at("boss"));
|
||||
|
||||
if(result.player_did > 0) {
|
||||
status += L"\nYOU HIT!";
|
||||
} else {
|
||||
status += L"\nYOU MISSED!";
|
||||
}
|
||||
|
||||
if(result.enemy_did > 0) {
|
||||
status += L"\nBOSS HIT!";
|
||||
} else {
|
||||
status += L"\nBOSS MISSED!";
|
||||
}
|
||||
|
||||
if(result.player_did > 0) {
|
||||
zoom(boss_is.cell);
|
||||
} else if(result.enemy_did > 0) {
|
||||
zoom(player_is.cell);
|
||||
} else {
|
||||
zoom("");
|
||||
}
|
||||
}
|
||||
|
||||
$actions.show_text("stats", status);
|
||||
}
|
||||
|
||||
void UI::render(sf::RenderWindow& window) {
|
||||
|
|
@ -59,6 +88,7 @@ namespace boss {
|
|||
$combat_ui.render(window);
|
||||
|
||||
$arena.render($view_texture);
|
||||
$camera.render($view_texture);
|
||||
$view_texture.display();
|
||||
window.draw($view_sprite);
|
||||
}
|
||||
|
|
@ -86,9 +116,15 @@ namespace boss {
|
|||
}
|
||||
|
||||
void UI::zoom(const std::string &cell_name) {
|
||||
auto& cell = $arena.$ui.cell_for(cell_name);
|
||||
if(cell_name == "") {
|
||||
dbc::log("!!!!!!!!! you should add this to guecs");
|
||||
$camera.reset($view_texture, BOSS_VIEW_WIDTH, BOSS_VIEW_HEIGHT);
|
||||
} else {
|
||||
auto& cell = $arena.$ui.cell_for(cell_name);
|
||||
|
||||
$camera.resize(BOSS_VIEW_WIDTH/2, BOSS_VIEW_HEIGHT/2);
|
||||
$camera.move(float(cell.mid_x), float(cell.mid_y));
|
||||
$camera.resize(BOSS_VIEW_WIDTH/2, BOSS_VIEW_HEIGHT/2);
|
||||
$camera.move(float(cell.mid_x), float(cell.mid_y));
|
||||
$camera.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,14 @@ namespace cinematic {
|
|||
}
|
||||
}
|
||||
|
||||
void Camera::reset(sf::RenderTexture& target, float width, float height) {
|
||||
size = {width, height};
|
||||
aimed_at = {width/2, height/2};
|
||||
going_to = {width/2, height/2};
|
||||
view = {aimed_at, size};
|
||||
target.setView(target.getDefaultView());
|
||||
}
|
||||
|
||||
void Camera::render(sf::RenderTexture& target) {
|
||||
if(anim.playing) {
|
||||
anim.apply(view, going_to, size);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace cinematic {
|
|||
struct Camera {
|
||||
components::Animation anim;
|
||||
sf::View view;
|
||||
sf::Vector2f size{SCREEN_WIDTH, SCREEN_WIDTH};
|
||||
sf::Vector2f size{SCREEN_WIDTH, SCREEN_HEIGHT};
|
||||
sf::Vector2f aimed_at{0,0};
|
||||
sf::Vector2f going_to{0,0};
|
||||
|
||||
|
|
@ -19,6 +19,7 @@ namespace cinematic {
|
|||
void render(sf::RenderTexture& target);
|
||||
void play();
|
||||
void style(const std::string &name);
|
||||
void reset(sf::RenderTexture& target, float width, float height);
|
||||
};
|
||||
|
||||
void init();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue