Commit 3d332b78 authored by Tim Scheiber's avatar Tim Scheiber

Merge branch 'feature/36-level-design' into 'develop'

Resolve "Level Design"

Closes #36

See merge request !26
parents 3fb64e03 b801adb2
Pipeline #3442 passed with stage
in 5 minutes and 2 seconds
{
"Transform": {
"scale": {
"x": 0.2,
"y": 0.2,
"z": 0.2
"x": 1,
"y": 1,
"z": 1
}
},
"Model": {
......@@ -22,6 +22,10 @@
"radius": 0.3
},
"Bullet": {},
"Killable": {
"radius": 1,
"only_stationary": true
},
"Material_property": {
"emissive_color": {
"r": 0.5,
......
{
"Transform": {
"scale": {
"x": 0.3,
"y": 0.3,
"z": 0.3
}
},
"Model": {
"aid": "model:drone"
},
"Shadowcaster": {
},
"Movement": {
"beats_per_step": 1,
"distance_per_step": 1,
"step_time_percentage": 0.2,
"off_beat_threshold": 0.0
},
"FixedPath": {
"pause_between_steps": 1,
"wait_beats": 1
},
"Shooting": {
"spawn_offset": 1,
"pause_between_shots": 1
},
"Killable": {
"radius": 1
}
}
......@@ -33,7 +33,7 @@
"Shadowcaster": {},
"Movement": {
"beats_per_step": 1,
"distance_per_step": 5,
"distance_per_step": 4,
"step_time_percentage": 0.5,
"off_beat_threshold": 0.2,
"overshoot": 3
......
{
"Transform": {
"scale": {
"x": 0.3,
"y": 0.3,
"z": 0.3
}
},
"Model": {
"aid": "model:drone"
},
"Shadowcaster": {
},
"Movement": {
"beats_per_step": 1,
"distance_per_step": 1,
"step_time_percentage": 0.2,
"off_beat_threshold": 0.0
},
"Shooting": {
"spawn_offset": 1,
"pause_between_shots": 1
},
"Killable": {
"radius": 1
}
}
tileset
##############################################################################
####################-----##########-##########################################
######---####-----#|> >|########|!|#########################################
##---} 7{--} 5 {} |######--} {--#######################################
#|@ 5 |#####| |######################################
##---] 7[--] 1 [] |#####| |######################################
######---####-----#|> >|#####| |######################################
####################-] [-######| |######################################
#####################| |#######| |######################################
#####################| |########--] [--#######################################
####################-} {-#########| |#########################################
###################|4 6|###-----} {#########################################
###############----} |##|5 5 7|########################################
##############| |##| |########################################
##############| |--] |##| 7|########################################
##############} {##|2 8|##| [----######---################################
#############|0 |##-----###}~ ~{########-}0 0{-##############################
#############| |#########| 5 5 |######| |#############################
#############| 0|#########| |###--#] [---] |#############################
#############| |#########| > |##|55{} |##-} {-############################
#############|0 |#########| < {--} |#|e f|###########################
#############| |#########| |#| |###########################
#############| 0|##########----------]11[##| |###########################
#############| |#####################--###| |###########################
##############] [############################-] [-############################
##############| |--------#####################| {------#######################
##############| d|####################| |######################
##############| |####--##--##--##--###--] |######################
##############| d|##-}<>{}<>{}<>{}<>{-###| j |######################
##############| {-} {--} |######################
##############| d |######################
##############| [-] [--------#######################
###############----------###-]><[]><[]><[]><[-################################
##############################--##--##--##--##################################
##############################################################################
\ No newline at end of file
{
"tile_size": 4,
"tiles": {
"|": {
"blueprint": "dummy_wall",
"solid": true
},
"-": {
"blueprint": "dummy_wall",
"solid": true
},
" ": {
"blueprint": "dummy_floor",
"solid": false
},
"#": {
"blueprint": "dummy_ceiling",
"solid": true
},
"p": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "player"
},
"h": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "hunting_enemy"
},
"b": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "basic_enemy"
},
"G": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "goal"
}
}
"tiles": {
"|": {
"blueprint": "dummy_wall",
"solid": true
},
"-": {
"blueprint": "dummy_wall",
"solid": true
},
" ": {
"blueprint": "dummy_floor",
"solid": false
},
"#": {
"blueprint": "dummy_ceiling",
"solid": true
},
"@": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "player"
},
"!": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "goal"
},
"0": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"1": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"2": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"3": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"4": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"5": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"6": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"7": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"8": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"<": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
">": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"a": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"b": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"c": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"d": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "moving_turret"
},
"e": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"f": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"g": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"h": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"i": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"j": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
}
}
}
{
"tile_size": 4,
"tiles": {
"#": {
"blueprint": "ceiling",
"solid": true
},
" ": {
"blueprint": "floor",
"solid": false
},
"-": {
"blueprint": "wall_horizontal",
"solid": true
},
"|": {
"blueprint": "wall_vertical",
"solid": true
},
"p": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "player"
},
"h": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "hunting_enemy"
},
"b": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "basic_enemy"
},
"G": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "goal"
},
"[": {
"blueprint": "wall_top_left",
"solid": true
},
"]": {
"blueprint": "wall_top_right",
"solid": true
},
"{": {
"blueprint": "wall_bottom_left",
"solid": true
},
"}": {
"blueprint": "wall_bottom_right",
"solid": true
}
}
"tiles": {
"#": {
"blueprint": "ceiling",
"solid": true
},
" ": {
"blueprint": "floor",
"solid": false
},
"-": {
"blueprint": "wall_horizontal",
"solid": true
},
"|": {
"blueprint": "wall_vertical",
"solid": true
},
"[": {
"blueprint": "wall_vertical",
"solid": true
},
"]": {
"blueprint": "wall_vertical",
"solid": true
},
"{": {
"blueprint": "wall_vertical",
"solid": true
},
"}": {
"blueprint": "wall_vertical",
"solid": true
},
"~": {
"blueprint": "wall_vertical",
"solid": true
},
"@": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "player"
},
"!": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "goal"
},
"0": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"1": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"2": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"3": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"4": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"5": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"6": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"7": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"8": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"<": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
">": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"a": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"b": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"c": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"d": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "moving_turret"
},
"e": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"f": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"g": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"h": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"i": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
},
"j": {
"blueprint": "floor",
"solid": false,
"spawn": true,
"spawns": "static_turret"
}
}
}
Subproject commit 57bcafb5c858c315b9b8cfc00624505d46ea91a0
Subproject commit d997d0e29bbbbe10a5eb9c211f8131a8e46135b0
......@@ -16,7 +16,7 @@ namespace phase_shifter::gameplay {
} // namespace
Beat_system::Beat_system(mirrage::util::Message_bus& bus, mirrage::asset::Asset_manager& assets)
: _bus(bus), _assets(assets)
: _bus(bus), _mailbox(bus), _assets(assets)
{
auto input = _assets.open(mirrage::asset::AID("beat:pulse")).get_or_throw();
std::string line;
......@@ -29,6 +29,8 @@ namespace phase_shifter::gameplay {
_state.beats_left = static_cast<int>(_time_stamps.size());
_state.avg_beat_time =
static_cast<float>(_time_stamps[_time_stamps.size() - 1]) / _time_stamps.size();
_mailbox.subscribe_to([&](Beat_missed_msg& e) { decrease_beats_left(1); });
}
void Beat_system::update(mirrage::util::Time dt)
......
......@@ -7,6 +7,9 @@
namespace phase_shifter::gameplay {
struct Beat_missed_msg {
};
struct Beat_state {
bool beat = false;
float time_since_beat = 0.f;
......@@ -36,6 +39,7 @@ namespace phase_shifter::gameplay {
private:
mirrage::util::Message_bus& _bus;
mirrage::util::Mailbox_collection _mailbox;
mirrage::asset::Asset_manager& _assets;
Beat_state _state;
float _acc = 0.f;
......
......@@ -15,8 +15,8 @@ namespace phase_shifter::gameplay {
using mirrage::ecs::components::Transform_comp;
namespace {
constexpr auto damage_beat_penalty = 10;
constexpr auto kill_beat_gain = 5;
constexpr auto damage_beat_penalty = 5;
constexpr auto kill_beat_gain = 10;
}
Combat_system::Combat_system(mirrage::util::Message_bus& bus,
......
......@@ -30,6 +30,7 @@ namespace phase_shifter::gameplay {
{
auto beat = _beat_system.beat_state();
despawn_distant_bullets();
do_movement(beat);
do_shooting(beat);
do_bullet_hit_detection();
......@@ -110,7 +111,16 @@ namespace phase_shifter::gameplay {
{
for(auto&& [entity, shooting, transform] :
_entity_manager.list<Entity_facet, Shooting_comp, components::Transform_comp>()) {
auto my_position = transform.position;
auto my_position = transform.position;
bool shoot = false;
for(auto&& [player, player_transform] :
_entity_manager.list<Player_comp, components::Transform_comp>()) {
if(glm::length(glm::vec2{player_transform.position.x, player_transform.position.z}
- glm::vec2{my_position.x, my_position.z})
<= trigger_distance_shooting) {
shoot = true;
}
}
glm::vec3 closest_target_pos(0.f);
float closest_dist = 999999999.f;
......@@ -133,7 +143,7 @@ namespace phase_shifter::gameplay {
shooting.target_direction *= -1;
}
if(closest_dist <= shooting.attack_radius) {
if(shooting.attack_radius >= 0 && closest_dist <= shooting.attack_radius) {
shooting.idle = false;
} else {
shooting.idle = true;
......@@ -152,36 +162,44 @@ namespace phase_shifter::gameplay {
}
if(shooting.wait_beats == 0) {
auto bullet_pattern = shooting.next_pattern();
auto spawn_position =
transform.position
+ shooting.spawn_offset
* glm::vec3(std::sin(rad_orientation), 0, -std::cos(rad_orientation));
for(auto bullet : bullet_pattern.bullets) {
auto bullet_direction = orientation + bullet.direction;
auto rad_bullet_direction = bullet_direction * mirrage::util::PI / 180.f;
_entity_manager.entity_builder("bullet")
.position(spawn_position)
.rotation(glm::rotation({0, 0, 1},
glm::vec3(std::sin(rad_bullet_direction),
0,
-std::cos(rad_bullet_direction))))
.post_create([=](auto entity) {
entity.process([=](Continuous_path_comp& cont_path) {
cont_path.direction = bullet_direction;
cont_path.curvature = bullet.curvature;
});
entity.process([=](Movement_comp& move, Continuous_path_comp& cont_path) {
float rad_direction = cont_path.direction * mirrage::util::PI / 180.f;
move.aim.x = std::sin(rad_direction);
move.aim.y = -std::cos(rad_direction);
});
})
.create();
if(shoot) {
for(auto bullet : bullet_pattern.bullets) {
auto bullet_direction = orientation + bullet.direction;
auto rad_bullet_direction = bullet_direction * mirrage::util::PI / 180.f;
auto spawn_position = transform.position
+ shooting.spawn_offset
* glm::vec3(std::sin(rad_bullet_direction),
0,
-std::cos(rad_bullet_direction))
+ glm::vec3{0.f, 1.f, 0.f};
_entity_manager.entity_builder("bullet")
.position(spawn_position)
.rotation(glm::rotation({0, 0, 1},
glm::vec3(std::sin(rad_bullet_direction),
0,
-std::cos(rad_bullet_direction))))
.post_create([=](auto entity) {
entity.process([=](Continuous_path_comp& cont_path) {
cont_path.direction = bullet_direction;