diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/assets.cpp | 2 | ||||
-rw-r--r-- | src/game/effects.cpp | 31 | ||||
-rw-r--r-- | src/game/game.cpp | 23 | ||||
-rw-r--r-- | src/game/game.hpp | 20 | ||||
-rw-r--r-- | src/game/text.cpp | 6 | ||||
-rw-r--r-- | src/game/units.cpp | 6 |
6 files changed, 71 insertions, 17 deletions
diff --git a/src/game/assets.cpp b/src/game/assets.cpp index 03ca7d8..1aed662 100644 --- a/src/game/assets.cpp +++ b/src/game/assets.cpp @@ -27,6 +27,7 @@ deco_assets_t deco; render::animated_texture_t unit_selected; render::animated_texture_t unit_selected_halo; +render::animated_texture_t move_marker; void load(void) { @@ -56,6 +57,7 @@ void load(void) unit_selected.load("assets/units/selected_", 1); unit_selected_halo.load("assets/units/selected_halo_", 1); + move_marker.load("assets/units/move_marker_", 8); world::register_tile(TILE_DIRT, 0); render::register_tile(TILE_DIRT, "assets/tiles/dirt.png", NULL, 0.0f); diff --git a/src/game/effects.cpp b/src/game/effects.cpp index 932b562..39a1f1e 100644 --- a/src/game/effects.cpp +++ b/src/game/effects.cpp @@ -21,8 +21,6 @@ namespace game { effect_t::effect_t(state_t *game_) : game::entity_t(game_, ET_EFFECT) { - ignore_waking = true; - wake(); } void effect_t::on_think(void) @@ -43,6 +41,9 @@ fx_tracer_t::fx_tracer_t(state_t *game_, v2f_t x0_, v2f_t x1_) : effect_t(game_) render_bounds = render_bounds.norm(); cmodel.bounds = render_bounds; cmodel.cflags = 0; + + ignore_waking = true; + wake(); } void fx_tracer_t::render_to(render::state_t *render) @@ -71,6 +72,9 @@ fx_blood_t::fx_blood_t(state_t *game_, v2f_t x_, bool alien_) : effect_t(game_) render_bounds[1] = x + v2f_t(0.2, 0.2); cmodel.bounds = render_bounds; cmodel.cflags = 0; + + ignore_waking = true; + wake(); } void fx_blood_t::render_to(render::state_t *render) @@ -88,4 +92,27 @@ void fx_blood_t::render_to(render::state_t *render) render->render(phase, &assets::fx.blood, render_bounds, color); } +fx_move_marker_t::fx_move_marker_t(state_t *game_, v2f_t x_) : effect_t(game_) +{ + x = x_; + render_bounds[0] = x + v2f_t(-0.15, -0.4); + render_bounds[1] = x + v2f_t(0.15, 0.2); + cmodel.bounds = render_bounds; + cmodel.cflags = 0; + + ignore_waking = true; + link(&game->world); +} + +fx_move_marker_t::~fx_move_marker_t(void) +{ + unlink(); + sleep(); +} + +void fx_move_marker_t::render_to(render::state_t *render) +{ + render->render(game->now * 2, &assets::move_marker, render_bounds, sf::Color::White); +} + } // namespace game diff --git a/src/game/game.cpp b/src/game/game.cpp index ddf9a75..f76b478 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -140,16 +140,27 @@ void state_t::command(v2f_t x) group_say(text::get(text::SAY_MOVING_GROUP)); for (unit_t *unit : selected_units) { - if (unit->dead) + unit_soldier_t *soldier; + + if (unit->type != unit_t::UNIT_SOLDIER) continue; - if (!unit->controllable) + soldier = dynamic_cast<unit_soldier_t*>(unit); + + if (soldier->dead) continue; - if (!unit->start_moving(snap)) - unit->say(text::get(text::SAY_NO_PATH)); - else if (selected_units.size() == 1) - unit->say(text::get(text::SAY_MOVING)); + if (!soldier->controllable) + continue; + + if (!soldier->start_moving(snap)) + soldier->say(text::get(text::SAY_NO_PATH)); + else { + soldier->move_marker = std::make_unique<fx_move_marker_t>(this, soldier->move.path.back()); + + if (selected_units.size() == 1) + soldier->say(text::get(text::SAY_MOVING)); + } } } diff --git a/src/game/game.hpp b/src/game/game.hpp index 213e8b1..0143edb 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -82,6 +82,7 @@ namespace game { extern deco_assets_t deco; extern render::animated_texture_t unit_selected; extern render::animated_texture_t unit_selected_halo; + extern render::animated_texture_t move_marker; void load(void); } @@ -101,7 +102,6 @@ namespace game { FOLLOWING_OFF, SAY_GROUP, SAY_NO_PATH, - SAY_BLOCKED, SAY_READY, SAY_READY_GROUP, SAY_MOVING, @@ -148,6 +148,8 @@ namespace game { virtual void on_wake(void) = 0; }; + class fx_move_marker_t; + class unit_t : public entity_t { protected: double next_targetting = -INFINITY; @@ -208,9 +210,14 @@ namespace game { }; class unit_soldier_t : public unit_t { + friend state_t; + + protected: double last_target_time = -INFINITY; v2f_t last_target_x; + std::unique_ptr<fx_move_marker_t> move_marker; + sf::Color selection_color; double next_fear_test = -INFINITY; @@ -301,6 +308,17 @@ namespace game { void render_to(render::state_t *render); }; + class fx_move_marker_t : public effect_t { + v2f_t x; + + public: + fx_move_marker_t(game::state_t *game_, v2f_t x_); + ~fx_move_marker_t(void); + + void render_to(render::state_t *render); + }; + + typedef enum { DECO_STONE, DECO_STONE_SMALL, diff --git a/src/game/text.cpp b/src/game/text.cpp index b9cdd32..7e90edf 100644 --- a/src/game/text.cpp +++ b/src/game/text.cpp @@ -43,9 +43,6 @@ static std::string get_english(index_t index) case SAY_GROUP: return "Group"; - case SAY_BLOCKED: - return "Something is in my way."; - case SAY_NO_PATH: return "I can't get there."; @@ -121,9 +118,6 @@ static std::string get_polish(index_t index) case SAY_GROUP: return "Oddział"; - case SAY_BLOCKED: - return "Coś jest na mojej drodze."; - case SAY_NO_PATH: return "Nie mogę się tam dostać."; diff --git a/src/game/units.cpp b/src/game/units.cpp index c8ba2d8..d072f20 100644 --- a/src/game/units.cpp +++ b/src/game/units.cpp @@ -431,8 +431,9 @@ void unit_soldier_t::on_think(void) if (!panic) { target_and_attack(); - if (!keep_moving(4.0)) - say(text::get(text::SAY_BLOCKED)); + keep_moving(4.0); + if (!move.moving) + move_marker.reset(); } else { move.moving = true; keep_moving(6.0); @@ -458,6 +459,7 @@ void unit_soldier_t::on_death(void) place(world, x); controllable = false; game->selected_units.erase(this); + move_marker.reset(); } void unit_soldier_t::render_to(render::state_t *render) |