Commit 9c0eaad1 authored by Florian Oetke's avatar Florian Oetke

particle effect for special attack

parent a6572e38
{
"Transform":{
"scale": {"x": 1.0, "y": 1.0, "z": 1.0}
},
"Particle_system": {
"cfg": "particle_sys:special_attack_particle_system"
}
}
{
"emitters": [{
"spawn": [
{"particles_per_second": 2000, "stddev":0, "time": 0.01},
{"particles_per_second": 0, "stddev":0, "time": 1}
],
"spawn_loop": false,
"size": {"x":0.0, "y":0.0},
"direction": {"mean":{"elevation":0.0, "azimuth":0.5}, "stddev":{"elevation":0.02, "azimuth":1}},
"ttl": {"mean": 0.8, "stddev": 0.0},
"velocity": {"mean": 16, "stddev": 0.0},
"emit_script_id": "comp_shader:particle_spawn_sphere",
"type_id": "particle_def:special_attack_particles"
}]
}
{
"keyframes": [
{
"time": 0.0,
"color": {"mean":{"hue":0.472, "saturation":1, "value":0.0, "alpha":0}, "stddev":{"hue":0.01}},
"size": {"mean": {"x": 0.0, "y":0.0, "z":0.0}},
"rotation": {"mean":{"angle":1}, "stddev":{"elevation":1, "azimuth":1, "angle": 1}},
"drag": 0.0
},
{
"time": 0.1,
"color": {"mean":{"hue":0.472, "saturation":1, "alpha":20}, "stddev":{"hue":0.004}},
"size": {"mean": {"x": 0.5, "y":0.5, "z":0.5}, "stddev":{"x": 0.1, "y":0.1, "z":0.1}},
"rotation": {"mean":{"angle":0}, "stddev":{"elevation":1, "azimuth":1, "angle": 1}},
"drag": 0.1
},
{
"time": 0.8,
"color": {"mean":{"hue":0.472, "saturation":1, "value":0.0, "alpha":0}, "stddev":{"hue":0.01}},
"size": {"mean": {"x": 0.0, "y":0.0, "z":0.0}},
"rotation": {"mean":{"angle":1}, "stddev":{"elevation":1, "azimuth":1, "angle": 1}},
"drag": 1.0
}
],
"symmetric_scaling": true,
"rotate_with_velocity": true,
"blend": "solid",
"geometry": "mesh",
"model_id": "model:tetr",
"update_script_id": "comp_shader:particle_update_simple"
}
Subproject commit 3e190ffff0e2a684d4ca3f968f2459f225b93b77
Subproject commit 97d1f27e002409519dae841dd1053de1c7eca2fa
......@@ -70,7 +70,7 @@ namespace phase_shifter::gameplay {
move.attack = true;
if(entity.has<Player_comp>()) {
_bus.send<Play_sound_msg>("attack"_strid);
_bus.send<Special_attack_msg>(transform.position);
}
} else {
// start movement
......
......@@ -21,6 +21,10 @@ namespace phase_shifter {
glm::vec3 attack_direction;
};
struct Special_attack_msg {
glm::vec3 position;
};
struct Play_sound_msg {
mirrage::util::Str_id id;
};
......
......@@ -33,6 +33,7 @@ namespace phase_shifter::ui {
entity.process([=](Particle_system_comp& particle) {
for(auto& e : particle.particle_system.emitters()) {
e.active(true);
e.reset_time();
}
});
entity.process([=](Transform_comp& transform) {
......@@ -48,14 +49,13 @@ namespace phase_shifter::ui {
_tombstones.resize(20);
for(auto& t : _tombstones) {
t.entity = _ecs.entity_builder("enemy_tombstone")
.position(glm::vec3{-999.f, 0.f, -999.f})
.post_create([=](mirrage::ecs::Entity_facet entity) {
// disable_tombstone(entity);
})
.create();
t.entity =
_ecs.entity_builder("enemy_tombstone").position(glm::vec3{-999.f, 0.f, -999.f}).create();
};
_special_attack_marker =
_ecs.entity_builder("special_attack_marker").position(glm::vec3{-999.f, 0.f, -999.f}).create();
_mailbox.subscribe_to([&](Enemy_killed_msg& e) {
_bus.send<Play_sound_msg>("enemy_hit"_strid);
......@@ -78,6 +78,13 @@ namespace phase_shifter::ui {
});
});
_mailbox.subscribe_to([&](Special_attack_msg& e) {
_bus.send<Play_sound_msg>("attack"_strid);
enable_tombstone(_special_attack_marker, e.position + glm::vec3(0, 1, 0), glm::vec3(1, 0, 0));
_time_to_free_special_attack_marker = 0.5f;
// TODO
});
_mailbox.subscribe_to([&](Win_msg& e) {
_bus.send<Play_sound_msg>("win"_strid);
// TODO
......@@ -93,6 +100,13 @@ namespace phase_shifter::ui {
{
_mailbox.update_subscriptions();
_actions.update(dt);
if(_time_to_free_special_attack_marker > 0) {
_time_to_free_special_attack_marker -= dt.value();
if(_time_to_free_special_attack_marker < 0) {
disable_tombstone(_special_attack_marker);
}
}
}
} // namespace phase_shifter::ui
......@@ -28,7 +28,9 @@ namespace phase_shifter::ui {
mirrage::ecs::Entity_manager& _ecs;
mirrage::util::Deferred_action_container _actions;
std::vector<Tombstone> _tombstones;
std::vector<Tombstone> _tombstones;
mirrage::ecs::Entity_facet _special_attack_marker;
float _time_to_free_special_attack_marker = 0;
};
} // namespace phase_shifter::ui
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