Commit 59b1cc9d authored by Kevin Balz's avatar Kevin Balz
Browse files

Merge branch 'feature/37-enemy-types' into feature/36-level-design

parents 21e4bf04 c0f8960d
Pipeline #3396 failed with stage
in 5 minutes and 4 seconds
{
"Transform": {
"scale": {
"x": 0.2,
"y": 0.2,
"z": 0.2
"x": 0.4,
"y": 0.4,
"z": 0.4
}
},
"Model": {
"aid": "model:cube"
"aid": "model:tetr"
},
"Shadowcaster": {
},
......
......@@ -12,7 +12,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
}
}
dummy
################################
###################-----------|#
#|-------|#|-----|| b |#
##---- b|-| b -- b |#
#|p b b G|#
#|---- b|-| b -- b |#
######---|#|-----|| b |#
###################-----------|#
################################
\ No newline at end of file
####################
###|--------|#######
#|-| 7| 5|--|####
#| 3 |####
#|-| 7| 1 || |####
###|--------|| |####
#############| |####
##########|--| |--|#
##########| |#
##########| |#
##########| |#
##########| <p> |#
##########| |#
##########| |#
##########| |#
##########|-------|#
####################
{
"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
},
"p": {
"blueprint": "dummy_floor",
"solid": false,
"spawn": true,
"spawns": "player"
},
"G": {
"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"
}
}
}
......@@ -112,97 +112,101 @@ namespace phase_shifter::gameplay {
for(auto&& [entity, shooting, transform] :
_entity_manager.list<Entity_facet, Shooting_comp, components::Transform_comp>()) {
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) {
glm::vec3 closest_target_pos(0.f);
float closest_dist = 999999999.f;
for(auto&& [target, target_comp, target_transform] :
_entity_manager.list<Entity_facet, Target_comp, components::Transform_comp>()) {
auto target_position = target_transform.position;
auto dist = glm::length(glm::vec2(target_position.x, target_position.z)
- glm::vec2(my_position.x, my_position.z));
if(dist < closest_dist) {
closest_dist = dist;
closest_target_pos = target_position;
}
}
- 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;
for(auto&& [target, target_comp, target_transform] :
_entity_manager.list<Entity_facet, Target_comp, components::Transform_comp>()) {
auto target_position = target_transform.position;
auto dist = glm::length(glm::vec2(target_position.x, target_position.z)
- glm::vec2(my_position.x, my_position.z));
if(dist < closest_dist) {
closest_dist = dist;
closest_target_pos = target_position;
}
}
glm::vec2 t_direction{closest_target_pos.x - my_position.x,
closest_target_pos.z - my_position.z};
shooting.target_direction =
std::acos(-t_direction.y / glm::length(t_direction)) * 180.f / mirrage::util::PI;
if(t_direction.x < 0) {
shooting.target_direction *= -1;
}
glm::vec2 t_direction{closest_target_pos.x - my_position.x, closest_target_pos.z - my_position.z};
shooting.target_direction =
std::acos(-t_direction.y / glm::length(t_direction)) * 180.f / mirrage::util::PI;
if(t_direction.x < 0) {
shooting.target_direction *= -1;
}
if(closest_dist <= shooting.attack_radius) {
shooting.idle = false;
} else {
shooting.idle = true;
}
if(closest_dist <= shooting.attack_radius) {
shooting.idle = false;
} else {
shooting.idle = true;
}
auto orientation = shooting.target_direction;
if(shooting.idle) {
orientation = shooting.default_orientation + shooting.rotation;
}
auto rad_orientation = orientation * mirrage::util::PI / 180.f;
auto orientation = shooting.target_direction;
if(shooting.idle) {
orientation = shooting.default_orientation + shooting.rotation;
}
auto rad_orientation = orientation * mirrage::util::PI / 180.f;
if(beat.beat) {
if(shooting.idle && shooting.rotate) {
shooting.do_rotation();
shooting.rotate = false;
}
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();
}
shooting.wait_beats = shooting.pause_between_shots;
if(shooting.rotation_per_step < 0.0001f) {
shooting.rotate = true;
}
} else {
shooting.wait_beats--;
if(beat.beat) {
if(shooting.idle && shooting.rotate) {
shooting.do_rotation();
shooting.rotate = false;
}
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))
+ glm::vec3{0.f, 1.f, 0.f};
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;
_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();
}
}
transform.orientation = glm::rotation(
{0, 0, 1}, glm::vec3(std::sin(rad_orientation), 0, -std::cos(rad_orientation)));
entity.process([&](Movement_comp& movement) { movement.want_orientation = false; });
shooting.wait_beats = shooting.pause_between_shots;
if(std::abs(shooting.rotation_per_step) > 0.0001f) {
shooting.rotate = true;
}
} else {
shooting.wait_beats--;
}
}
transform.orientation = glm::rotation(
{0, 0, 1}, glm::vec3(std::sin(rad_orientation), 0, -std::cos(rad_orientation)));
entity.process([&](Movement_comp& movement) { movement.want_orientation = false; });
}
}
......
......@@ -84,19 +84,157 @@ namespace phase_shifter::level {
glm::rotate(sun_dir, glm::vec3(0, 0, 1)) * 40.f);
});
_spawners.emplace("0", [&](const Tile& tile, const glm::vec3& position) {
_entities.entity_builder(tile.spawns)
.position(position)
.post_create([=](auto entity) {
entity.process([&](gameplay::Shooting_comp& shooting) {
shooting.default_orientation = 0;
shooting.attack_radius = 20;
shooting.pause_between_shots = 2;
shooting.set_patterns({gameplay::Bulletpattern({{0, 0}})});
});
})
.create();
});
_spawners.emplace("1", [&](const Tile& tile, const glm::vec3& position) {
_entities.entity_builder(tile.spawns)
.position(position)
.post_create([=](auto entity) {
entity.process([&](gameplay::Shooting_comp& shooting) {
shooting.default_orientation = 0;
shooting.set_patterns({gameplay::Bulletpattern({{0, 0}})});
});
})
.create();
});
_spawners.emplace("2", [&](const Tile& tile, const glm::vec3& position) {
_entities.entity_builder(tile.spawns)
.position(position)
.post_create([=](auto entity) {
entity.process([&](gameplay::Shooting_comp& shooting) {
shooting.default_orientation = 45;
shooting.set_patterns({gameplay::Bulletpattern({{0, 0}})});
});
})
.create();
});
_spawners.emplace("3", [&](const Tile& tile, const glm::vec3& position) {
_entities.entity_builder(tile.spawns)
.position(position)
.post_create([=](auto entity) {
entity.process([&](gameplay::Shooting_comp& shooting) {
shooting.default_orientation = 90;
shooting.set_patterns({gameplay::Bulletpattern({{0, 0}})});
});
})
.create();
});
_spawners.emplace("4", [&](const Tile& tile, const glm::vec3& position) {
_entities.entity_builder(tile.spawns)
.position(position)
.post_create([=](auto entity) {
entity.process([&](gameplay::Shooting_comp& shooting) {
shooting.default_orientation = 135;
shooting.set_patterns({gameplay::Bulletpattern({{0, 0}})});
});
})
.create();
});
_spawners.emplace("b", [&](const Tile& tile, const glm::vec3& position) {
mirrage::ecs::Entity_facet enemy =
_entities.entity_builder(tile.spawns).position(position)
.post_create([=](auto entity) {
entity.process(
[&](gameplay::Fixed_path_comp& fixed_path) { fixed_path.update_path({}); });
_spawners.emplace("5", [&](const Tile& tile, const glm::vec3& position) {
_entities.entity_builder(tile.spawns)
.position(position)
.post_create([=](auto entity) {
entity.process([&](gameplay::Shooting_comp& shooting) {
shooting.default_orientation = 180;
shooting.set_patterns({gameplay::Bulletpattern({{0, 0}})});
});
}).create();
})
.create();
});
_spawners.emplace("6", [&](const Tile& tile, const glm::vec3& position) {
_entities.entity_builder(tile.spawns)
.position(position)
.post_create([=](auto entity) {
entity.process([&](gameplay::Shooting_comp& shooting) {
shooting.default_orientation = 225;
shooting.set_patterns({gameplay::Bulletpattern({{0, 0}})});
});
})
.create();
});
_spawners.emplace("7", [&](const Tile& tile, const glm::vec3& position) {
_entities.entity_builder(tile.spawns)
.position(position)
.post_create([=](auto entity) {
entity.process([&](gameplay::Shooting_comp& shooting) {
shooting.default_orientation = 270;
shooting.set_patterns({gameplay::Bulletpattern({{0, 0}})});
});
})
.create();
});
_spawners.emplace("8", [&](const Tile& tile, const glm::vec3& position) {
_entities.entity_builder(tile.spawns)
.position(position)
.post_create([=](auto entity) {
entity.process([&](gameplay::Shooting_comp& shooting) {
shooting.default_orientation = 315;
shooting.set_patterns({gameplay::Bulletpattern({{0, 0}})});
});
})
.create();
});
/*_spawners.emplace("9", [&](const Tile& tile, const glm::vec3& position) {
_entities.entity_builder(tile.spawns)
.position(position)
.post_create([=](auto entity) {
entity.process([&](gameplay::Shooting_comp& shooting) {
shooting.default_orientation = 0;
shooting.rotation_per_step = 360.f / 16.f;
shooting.max_rotation = 999999999.f;
shooting.set_patterns({gameplay::Bulletpattern({{0, 0}})});
});
})
.create();
});*/
_spawners.emplace("<", [&](const Tile& tile, const glm::vec3& position) {
_entities.entity_builder(tile.spawns)
.position(position)
.post_create([=](auto entity) {
entity.process([&](gameplay::Shooting_comp& shooting) {
shooting.default_orientation = 0;
shooting.rotation_per_step = -360.f / 16.f;
shooting.max_rotation = -1;
shooting.set_patterns({gameplay::Bulletpattern({{0, 0}})});
});
})
.create();
});
_spawners.emplace(">", [&](const Tile& tile, const glm::vec3& position) {
_entities.entity_builder(tile.spawns)
.position(position)
.post_create([=](auto entity) {
entity.process([&](gameplay::Shooting_comp& shooting) {
shooting.default_orientation = 0;
shooting.rotation_per_step = 360.f / 16.f;
shooting.max_rotation = -1;
shooting.set_patterns({gameplay::Bulletpattern({{0, 0}})});
});
})
.create();
});
}
auto Level_system::update(const mirrage::util::Time& time) -> void {}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment