summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/game.cpp32
-rw-r--r--src/game/game.hpp7
-rw-r--r--src/game/unit_builder.cpp3
-rw-r--r--src/game/unit_scientist.cpp3
-rw-r--r--src/game/unit_teleporter.cpp3
5 files changed, 48 insertions, 0 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp
index 883df60..246a222 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -503,6 +503,36 @@ void state_t::resume(void)
paused = false;
}
+void state_t::check_game_over(void)
+{
+ if (game_over_displayed)
+ return;
+
+ if (!first_teleporter_placed)
+ return;
+
+ // Can collect crystals and got a teleporter.
+ if (num_scientists && num_teleporters)
+ return;
+
+ // Got a teleporter and enough crystals for a scientist.
+ if (num_teleporters && crystals >= 95)
+ return;
+
+ // Got a scientist, a builder and enough crystals for a teleporter.
+ if (num_scientists && num_builders && crystals >= 265)
+ return;
+
+ // Got a builder and enough crystals for a teleporter and a scientist.
+ if (num_builders && crystals >= 265 + 95)
+ return;
+
+ interface.print("FURTHER PROGRESS IS NOT POSSIBLE.");
+ interface.print("At this point you might want to restart the game.");
+
+ game_over_displayed = true;
+}
+
#define TIME_DELTA ((ntime_t)1000000000 / 100)
#define TIME_LIMIT ((ntime_t)1000000000 / 20)
@@ -536,6 +566,8 @@ void state_t::tick(ntime_t time_)
if (awake_entities.find(ent) != awake_entities.end())
ent->on_think();
+ check_game_over();
+
frames++;
frames_since_t0++;
time += TIME_DELTA;
diff --git a/src/game/game.hpp b/src/game/game.hpp
index 31eb164..b6cb597 100644
--- a/src/game/game.hpp
+++ b/src/game/game.hpp
@@ -142,6 +142,13 @@ namespace game {
bool first_teleporter_placed = false;
size_t crystals = 150;
+ size_t num_scientists = 0;
+ size_t num_builders = 0;
+ size_t num_teleporters = 0;
+ bool game_over_displayed = false;
+ void check_game_over(void);
+
+
void command_first_teleporter(v2f_t where);
void wake_area(v2f_t x);
diff --git a/src/game/unit_builder.cpp b/src/game/unit_builder.cpp
index 801639e..231101a 100644
--- a/src/game/unit_builder.cpp
+++ b/src/game/unit_builder.cpp
@@ -49,6 +49,8 @@ unit_builder_t::unit_builder_t(game::state_t *game) : unit_t(game, UNIT_BUILDER)
controllable = true;
health = max_health = 45;
+
+ game->num_builders++;
}
void unit_builder_t::command_stop(void)
@@ -247,6 +249,7 @@ void unit_builder_t::on_death(void)
place(world, x);
controllable = false;
move_marker.reset();
+ game->num_builders--;
}
void unit_builder_t::render_to(render::state_t *render)
diff --git a/src/game/unit_scientist.cpp b/src/game/unit_scientist.cpp
index 537539e..e1f8ece 100644
--- a/src/game/unit_scientist.cpp
+++ b/src/game/unit_scientist.cpp
@@ -49,6 +49,8 @@ unit_scientist_t::unit_scientist_t(game::state_t *game) : unit_t(game, UNIT_SCIE
controllable = true;
health = max_health = 15;
+
+ game->num_scientists++;
}
static std::string russian_plural(size_t count, const char *nom_sg, const char *gen_sg,
@@ -142,6 +144,7 @@ void unit_scientist_t::on_death(void)
cmodel.ignore = true;
game->deletion_list.insert(this);
game->explosion(x);
+ game->num_scientists--;
}
void unit_scientist_t::render_to(render::state_t *render)
diff --git a/src/game/unit_teleporter.cpp b/src/game/unit_teleporter.cpp
index fd73ab6..56b3b5a 100644
--- a/src/game/unit_teleporter.cpp
+++ b/src/game/unit_teleporter.cpp
@@ -35,6 +35,8 @@ unit_teleporter_t::unit_teleporter_t(game::state_t *game_) : unit_t(game_, UNIT_
friendly = true;
controllable = true;
constructed = false;
+
+ game->num_teleporters++;
}
void unit_teleporter_t::on_damage(unit_t *attacker)
@@ -46,6 +48,7 @@ void unit_teleporter_t::on_death(void)
{
game->explosion(x);
game->deletion_list.insert(this);
+ game->num_teleporters--;
}
void unit_teleporter_t::render_to(render::state_t *render)