Getting more UI elements sorted out in the boss fight.
This commit is contained in:
parent
d4d8d8ca99
commit
a8863cf687
4 changed files with 28 additions and 44 deletions
|
|
@ -30,7 +30,6 @@ namespace boss {
|
|||
switch($state) {
|
||||
FSM_STATE(State, START, ev, data);
|
||||
FSM_STATE(State, PLAYER_REQUESTS, ev, data);
|
||||
FSM_STATE(State, PLAN_BATTLE, ev, data);
|
||||
FSM_STATE(State, EXEC_PLAN, ev, data);
|
||||
FSM_STATE(State, END, ev, data);
|
||||
}
|
||||
|
|
@ -43,7 +42,7 @@ namespace boss {
|
|||
// this is only if using the debug X key to skip it
|
||||
case TICK:
|
||||
case BOSS_START:
|
||||
$ui.status(L"PLAYER REQUESTS");
|
||||
$ui.status(L"PLAYER REQUESTS", L"COMMIT");
|
||||
$battle.ap_refresh();
|
||||
state(State::PLAYER_REQUESTS);
|
||||
break;
|
||||
|
|
@ -62,8 +61,8 @@ namespace boss {
|
|||
break;
|
||||
case COMBAT_START:
|
||||
System::plan_battle($battle, $world, $boss_id);
|
||||
$ui.status(L"PLANNING BATTLE");
|
||||
state(State::PLAN_BATTLE);
|
||||
$ui.status(L"EXEC PLAN", L"START");
|
||||
state(State::EXEC_PLAN);
|
||||
break;
|
||||
case ATTACK:
|
||||
if($battle.player_request("kill_enemy")) {
|
||||
|
|
@ -80,7 +79,7 @@ namespace boss {
|
|||
}
|
||||
}
|
||||
|
||||
void Fight::PLAN_BATTLE(game::Event ev, std::any data) {
|
||||
void Fight::EXEC_PLAN(game::Event ev, std::any data) {
|
||||
using enum game::Event;
|
||||
|
||||
switch(ev) {
|
||||
|
|
@ -89,23 +88,27 @@ namespace boss {
|
|||
state(State::END);
|
||||
break;
|
||||
case COMBAT_START:
|
||||
$ui.status(L"EXEC PLAN");
|
||||
state(State::EXEC_PLAN);
|
||||
$ui.status(L"X TURN", L"STEP");
|
||||
next_combat_dumb_name();
|
||||
break;
|
||||
case COMBAT:
|
||||
do_combat(data);
|
||||
break;
|
||||
case TICK:
|
||||
break; // ignore tick
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Fight::next_combat_dumb_name() {
|
||||
if(auto action = $battle.next()) {
|
||||
System::combat(*action, $world, $boss_id, 0);
|
||||
} else if(player_dead()) {
|
||||
$ui.status(L"YOU DIED", L"DEAD");
|
||||
state(State::END);
|
||||
} else {
|
||||
$ui.status(L"PLAYER REQUESTS");
|
||||
$ui.zoom("", 1.0);
|
||||
$ui.status(L"PLAYER REQUESTS", L"COMMIT");
|
||||
$battle.ap_refresh();
|
||||
$battle.clear_requests();
|
||||
state(State::PLAYER_REQUESTS);
|
||||
|
|
@ -124,35 +127,8 @@ namespace boss {
|
|||
$ui.move_actor("player", player_move);
|
||||
$ui.move_actor("boss", boss_move);
|
||||
|
||||
if(result.enemy_did > 0) {
|
||||
// make boss move
|
||||
$ui.animate_actor("boss");
|
||||
}
|
||||
|
||||
if(result.player_did > 0) {
|
||||
// make player move
|
||||
$ui.animate_actor("player");
|
||||
$ui.zoom(player_move, 2.0);
|
||||
}
|
||||
}
|
||||
|
||||
void Fight::EXEC_PLAN(game::Event ev, std::any data) {
|
||||
using enum game::Event;
|
||||
|
||||
switch(ev) {
|
||||
// this is only if using the debug X key to skip it
|
||||
case BOSS_START:
|
||||
state(State::END);
|
||||
break;
|
||||
case COMBAT_START:
|
||||
next_combat_dumb_name();
|
||||
break;
|
||||
case COMBAT:
|
||||
do_combat(data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$ui.damage("player", result.enemy_did);
|
||||
$ui.damage("boss", result.player_did);
|
||||
}
|
||||
|
||||
void Fight::END(game::Event ev, std::any) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ namespace boss {
|
|||
enum class State {
|
||||
START=__LINE__,
|
||||
PLAYER_REQUESTS=__LINE__,
|
||||
PLAN_BATTLE=__LINE__,
|
||||
EXEC_PLAN=__LINE__,
|
||||
END=__LINE__
|
||||
};
|
||||
|
|
@ -42,7 +41,6 @@ namespace boss {
|
|||
|
||||
void START(game::Event ev, std::any data);
|
||||
void PLAYER_REQUESTS(game::Event ev, std::any data);
|
||||
void PLAN_BATTLE(game::Event ev, std::any data);
|
||||
void EXEC_PLAN(game::Event ev, std::any data);
|
||||
void END(game::Event ev, std::any data);
|
||||
void render(sf::RenderWindow& window);
|
||||
|
|
|
|||
11
boss/ui.cpp
11
boss/ui.cpp
|
|
@ -87,8 +87,9 @@ namespace boss {
|
|||
|| $actions.mouse(x, y, mods) || $arena.mouse(x, y, mods);
|
||||
}
|
||||
|
||||
void UI::status(const std::wstring& msg) {
|
||||
void UI::status(const std::wstring& msg, const std::wstring &button_msg) {
|
||||
$arena.$ui.show_text("status", msg);
|
||||
$actions.show_text("commit", button_msg);
|
||||
}
|
||||
|
||||
void UI::move_actor(const std::string& actor, const std::string& cell_name) {
|
||||
|
|
@ -103,6 +104,14 @@ namespace boss {
|
|||
$arena.play_animations();
|
||||
}
|
||||
|
||||
void UI::damage(const std::string& actor, int amount) {
|
||||
if(amount == 0) {
|
||||
$arena.$ui.show_text("boss7", fmt::format(L"{} MISSED!", guecs::to_wstring(actor)));
|
||||
} else {
|
||||
$arena.$ui.show_text("boss7", fmt::format(L"{} HIT {}!", guecs::to_wstring(actor), amount));
|
||||
}
|
||||
}
|
||||
|
||||
void UI::zoom(const std::string &cell_name, double ratio) {
|
||||
if(cell_name == "") {
|
||||
dbc::log("!!!!!!!!! you should add this to guecs");
|
||||
|
|
|
|||
|
|
@ -33,11 +33,12 @@ namespace boss {
|
|||
void init();
|
||||
void render(sf::RenderWindow& window);
|
||||
bool mouse(float x, float y, guecs::Modifiers mods);
|
||||
void status(const std::wstring& msg);
|
||||
void status(const std::wstring& msg, const std::wstring &button_msg);
|
||||
void move_actor(const std::string& actor, const std::string& cell_name);
|
||||
void animate_actor(const std::string& actor);
|
||||
void update_stats();
|
||||
void play_animations();
|
||||
void zoom(const std::string& cell, double ratio);
|
||||
void damage(const std::string& actor, int amount);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue