dash animation

This commit is contained in:
jshipsey 2020-09-17 00:18:09 -04:00 committed by Sam
parent a8e834e754
commit e79cef4824
10 changed files with 181 additions and 91 deletions

View File

@ -127,8 +127,8 @@ impl Tool {
knockback: 10.0,
range: 4.0,
angle: 30.0,
base_buildup_duration: Duration::from_millis(500),
base_swing_duration: Duration::from_millis(200),
base_buildup_duration: Duration::from_millis(350),
base_swing_duration: Duration::from_millis(100),
base_recover_duration: Duration::from_millis(400),
forward_movement: 0.5,
},
@ -176,7 +176,7 @@ impl Tool {
angle: 45.0,
energy_drain: 500,
forward_speed: 4.0,
buildup_duration: Duration::from_millis(200),
buildup_duration: Duration::from_millis(250),
charge_duration: Duration::from_millis(400),
swing_duration: Duration::from_millis(100),
recover_duration: Duration::from_millis(500),
@ -195,7 +195,7 @@ impl Tool {
is_helicopter: false,
forward_speed: 1.0,
num_spins: 3,
}
},
],
Axe(_) => vec![
BasicMelee {

View File

@ -52,8 +52,7 @@ impl CharacterBehavior for Data {
let mut update = StateUpdate::from(data);
if self.static_data.is_helicopter {
update.vel.0 =
Vec3::new(data.inputs.move_dir.x, data.inputs.move_dir.y, 0.0) * 5.0;
update.vel.0 = Vec3::new(data.inputs.move_dir.x, data.inputs.move_dir.y, 0.0) * 5.0;
} else {
handle_orientation(data, &mut update, 1.0);
forward_move(data, &mut update, 0.1, self.static_data.forward_speed);
@ -90,7 +89,7 @@ impl CharacterBehavior for Data {
knockback: self.static_data.knockback,
});
} else if self.stage_section == StageSection::Swing
&& self.timer < self.static_data.swing_duration
&& self.timer < self.static_data.swing_duration
{
// Swings
update.character = CharacterState::SpinMelee(Data {
@ -111,7 +110,7 @@ impl CharacterBehavior for Data {
stage_section: StageSection::Recover,
})
} else if self.stage_section == StageSection::Recover
&& self.timer < self.static_data.recover_duration
&& self.timer < self.static_data.recover_duration
{
// Recover
update.character = CharacterState::SpinMelee(Data {
@ -123,7 +122,10 @@ impl CharacterBehavior for Data {
spins_remaining: self.spins_remaining,
stage_section: self.stage_section,
})
} else if update.energy.current() >= self.static_data.energy_cost && (self.spins_remaining != 0 || (self.static_data.is_infinite && data.inputs.secondary.is_pressed())) {
} else if update.energy.current() >= self.static_data.energy_cost
&& (self.spins_remaining != 0
|| (self.static_data.is_infinite && data.inputs.secondary.is_pressed()))
{
let new_spins_remaining = if self.static_data.is_infinite {
self.spins_remaining
} else {
@ -136,9 +138,10 @@ impl CharacterBehavior for Data {
stage_section: StageSection::Buildup,
});
// Consumes energy if there's enough left and RMB is held down
update
.energy
.change_by(-(self.static_data.energy_cost as i32), EnergySource::Ability);
update.energy.change_by(
-(self.static_data.energy_cost as i32),
EnergySource::Ability,
);
} else {
// Done
update.character = CharacterState::Wielding;

View File

@ -84,10 +84,8 @@ impl Animation for AlphaAnimation {
next.main.orientation = Quaternion::rotation_x(-0.1)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.head.position = Vec3::new(0.0, skeleton_attr.head.0+0.0, skeleton_attr.head.1);
next.head.position = Vec3::new(0.0, skeleton_attr.head.0 + 0.0, skeleton_attr.head.1);
if let Some(stage_section) = stage_section {
match stage_section {
@ -133,8 +131,8 @@ impl Animation for AlphaAnimation {
next.chest.orientation = Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-1.57 + movement * 0.5);
next.head.orientation =
Quaternion::rotation_y(0.0) * Quaternion::rotation_z(1.57+movement*-0.5);
next.head.orientation = Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(1.57 + movement * -0.5);
},
_ => {},
}

View File

@ -69,7 +69,7 @@ impl Animation for BetaAnimation {
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
if let Some(stage_section) = stage_section {
match stage_section {

View File

@ -6,6 +6,7 @@ use common::{
comp::item::{Hands, ToolKind},
states::utils::StageSection,
};
use std::f32::consts::PI;
pub struct Input {
pub attack: bool,
@ -37,67 +38,150 @@ impl Animation for DashAnimation {
let mut next = (*skeleton).clone();
let lab = 1.0;
let foot = (((5.0)
/ (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 25.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 25.0).sin());
let slow = (((5.0)
/ (1.1 + 3.9 * ((anim_time as f32 * lab as f32 * 12.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 12.4).sin());
let short = (((5.0)
/ (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 5.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 5.0).sin());
let foothoril = (anim_time as f32 * 5.0 * lab as f32 + PI * 1.45).sin();
let foothorir = (anim_time as f32 * 5.0 * lab as f32 + PI * (0.45)).sin();
let footvertl = (anim_time as f32 * 5.0 * lab as f32).sin();
let footvertr = (anim_time as f32 * 5.0 * lab as f32 + PI).sin();
let footrotl = (((1.0)
/ (0.05
+ (0.95)
* ((anim_time as f32 * 5.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 5.0 * lab as f32 + PI * 1.4).sin());
let footrotr = (((1.0)
/ (0.05
+ (0.95)
* ((anim_time as f32 * 5.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 5.0 * lab as f32 + PI * 0.4).sin());
let shortalt = (anim_time as f32 * lab as f32 * 5.0 + PI / 2.0).sin();
let movement = (anim_time as f32 * 1.0).min(1.0);
next.head.position = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.l_hand.position = Vec3::new(-0.75, -1.0, 2.5);
next.l_hand.orientation = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.position = Vec3::new(0.75, -1.5, -0.5);
next.r_hand.orientation = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(0.0, 0.0, 2.0);
next.main.orientation = Quaternion::rotation_x(-0.1)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
match active_tool_kind {
//TODO: Inventory
Some(ToolKind::Sword(_)) => {
if let Some(stage_section) = stage_section {
match stage_section {
StageSection::Buildup => {},
StageSection::Charge => {},
StageSection::Swing => {},
StageSection::Recover => {},
StageSection::Buildup => {
next.head.orientation = Quaternion::rotation_z(movement * -0.9);
next.chest.orientation = Quaternion::rotation_z(movement * 1.1);
next.control.position = Vec3::new(-7.0 + movement * -5.0, 7.0, 2.0);
next.control.orientation = Quaternion::rotation_x(movement * -1.0)
* Quaternion::rotation_y(movement * 1.5)
* Quaternion::rotation_z(0.0);
next.control.scale = Vec3::one();
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1 + movement * -12.0,
skeleton_attr.foot.2,
);
next.l_foot.orientation = Quaternion::rotation_x(movement * -1.0);
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
);
},
StageSection::Charge => {
next.head.position = Vec3::new(
0.0,
-2.0 + skeleton_attr.head.0,
skeleton_attr.head.1 + movement * 1.0,
);
next.head.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(movement * -0.3)
* Quaternion::rotation_z(-0.9 + movement * -0.2 + short * -0.05);
next.chest.position = Vec3::new(
0.0,
skeleton_attr.chest.0,
skeleton_attr.chest.1 + 2.0 + shortalt * -2.5,
);
next.chest.orientation = Quaternion::rotation_x(movement * -0.4)
* Quaternion::rotation_y(movement * -0.2)
* Quaternion::rotation_z(1.1);
next.control.position =
Vec3::new(-13.0, 7.0 + movement * -2.0, 2.0 + movement * 2.0);
next.control.orientation =
Quaternion::rotation_x(-1.0) * Quaternion::rotation_y(1.5);
next.control.scale = Vec3::one();
next.shorts.orientation = Quaternion::rotation_z(short * 0.25);
next.belt.orientation = Quaternion::rotation_z(short * 0.1);
next.l_foot.position = Vec3::new(
2.0 - skeleton_attr.foot.0,
skeleton_attr.foot.1 + foothoril * -7.5,
2.0 + skeleton_attr.foot.2 + ((footvertl * -4.0).max(-1.0)),
);
next.l_foot.orientation =
Quaternion::rotation_x(-0.6 + footrotl * -0.6)
* Quaternion::rotation_z(-0.2);
next.r_foot.position = Vec3::new(
2.0 + skeleton_attr.foot.0,
skeleton_attr.foot.1 + foothorir * -7.5,
2.0 + skeleton_attr.foot.2 + ((footvertr * -4.0).max(-1.0)),
);
next.r_foot.orientation =
Quaternion::rotation_x(-0.6 + footrotr * -0.6)
* Quaternion::rotation_z(-0.2);
},
StageSection::Swing => {
next.head.orientation = Quaternion::rotation_y(0.2 + movement * -0.2)
* Quaternion::rotation_z(-1.1 + movement * 1.8);
next.chest.orientation = Quaternion::rotation_y(-0.2 + movement * 0.3)
* Quaternion::rotation_z(1.1 + movement * -2.2);
next.control.position = Vec3::new(-13.0 + movement * -2.0, 5.0, 4.0);
next.control.orientation =
Quaternion::rotation_x(-1.0 + movement * -0.5)
* Quaternion::rotation_y(1.5 + movement * -2.5);
next.control.scale = Vec3::one();
},
StageSection::Recover => {
next.head.orientation = Quaternion::rotation_z(0.7);
next.chest.orientation = Quaternion::rotation_z(-1.1);
next.control.position = Vec3::new(-15.0, 5.0, 2.0);
next.control.orientation =
Quaternion::rotation_x(-1.5) * Quaternion::rotation_y(-1.0);
next.control.scale = Vec3::one();
},
}
}
next.head.position = Vec3::new(
0.0,
-2.0 + skeleton_attr.head.0,
-2.0 + skeleton_attr.head.1,
);
next.head.orientation = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.position = Vec3::new(0.0, 0.0, 7.0 + slow * 2.0);
next.chest.orientation =
Quaternion::rotation_x(-0.5) * Quaternion::rotation_z(-0.7);
next.belt.position = Vec3::new(0.0, 1.0, -1.0);
next.belt.orientation = Quaternion::rotation_x(0.2) * Quaternion::rotation_z(0.2);
next.shorts.position = Vec3::new(0.0, 3.0, -3.0);
next.shorts.orientation = Quaternion::rotation_x(0.4) * Quaternion::rotation_z(0.3);
next.l_hand.position = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.orientation = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.position = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.orientation = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(0.0, 6.0, -1.0);
next.main.orientation = Quaternion::rotation_x(-0.3);
next.main.scale = Vec3::one();
next.control.position = Vec3::new(-8.0 - slow * 0.5, 3.0 - foot * 0.6, 3.0);
next.control.orientation =
Quaternion::rotation_x(-0.3) * Quaternion::rotation_z(1.1 + slow * 0.2);
next.control.scale = Vec3::one();
next.l_foot.position = Vec3::new(-1.4, foot * 3.0 + 2.0, skeleton_attr.foot.2);
next.l_foot.orientation = Quaternion::rotation_x(foot * -0.4 - 0.8);
next.r_foot.position = Vec3::new(5.4, foot * -3.0 - 1.0, skeleton_attr.foot.2);
next.r_foot.orientation = Quaternion::rotation_x(foot * 0.4 - 0.8);
},
Some(ToolKind::Dagger(_)) => {
next.head.position = Vec3::new(
@ -130,15 +214,15 @@ impl Animation for DashAnimation {
next.main.orientation = Quaternion::rotation_x(-0.3);
next.main.scale = Vec3::one();
next.control.position = Vec3::new(-8.0 - slow * 0.5, 3.0 - foot * 0.6, 3.0);
next.control.position = Vec3::new(-8.0 - slow * 0.5, 3.0, 3.0);
next.control.orientation =
Quaternion::rotation_x(-0.3) * Quaternion::rotation_z(1.1 + slow * 0.2);
next.control.scale = Vec3::one();
next.l_foot.position = Vec3::new(-1.4, foot * 3.0 + 2.0, skeleton_attr.foot.2);
next.l_foot.orientation = Quaternion::rotation_x(foot * -0.4 - 0.8);
next.l_foot.position = Vec3::new(-1.4, 2.0, skeleton_attr.foot.2);
next.l_foot.orientation = Quaternion::rotation_x(-0.8);
next.r_foot.position = Vec3::new(5.4, foot * -3.0 - 1.0, skeleton_attr.foot.2);
next.r_foot.orientation = Quaternion::rotation_x(foot * 0.4 - 0.8);
next.r_foot.position = Vec3::new(5.4, -1.0, skeleton_attr.foot.2);
next.r_foot.orientation = Quaternion::rotation_x(-0.8);
},
_ => {},
}
@ -189,11 +273,11 @@ impl Animation for DashAnimation {
next.second.orientation = Quaternion::rotation_x(-0.3);
next.second.scale = Vec3::one();
next.l_foot.position = Vec3::new(-1.4, foot * 3.0 + 2.0, skeleton_attr.foot.2);
next.l_foot.orientation = Quaternion::rotation_x(foot * -0.4 - 0.8);
next.l_foot.position = Vec3::new(-1.4, 2.0, skeleton_attr.foot.2);
next.l_foot.orientation = Quaternion::rotation_x(-0.8);
next.r_foot.position = Vec3::new(5.4, foot * -3.0 - 1.0, skeleton_attr.foot.2);
next.r_foot.orientation = Quaternion::rotation_x(foot * 0.4 - 0.8);
next.r_foot.position = Vec3::new(5.4, -1.0, skeleton_attr.foot.2);
next.r_foot.orientation = Quaternion::rotation_x(-0.8);
},
_ => {},
}
@ -207,9 +291,6 @@ impl Animation for DashAnimation {
Quaternion::rotation_x(slow * -0.7 + 0.4) * Quaternion::rotation_y(slow * 0.4);
next.hold.scale = Vec3::one() * 0.0;
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.l_control.scale = Vec3::one();

View File

@ -54,9 +54,8 @@ impl Animation for SpinAnimation {
let movement = anim_time as f32 * 1.0;
let test = (anim_time as f32 * 8.0).sin();
let test2 = (anim_time as f32 * 1.0).sin();
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
if let Some(ToolKind::Sword(_)) = active_tool_kind {
next.l_hand.position = Vec3::new(-0.75, -1.0, 2.5);

View File

@ -68,7 +68,7 @@ impl Animation for SpinMeleeAnimation {
_ => {},
}
}
}
},
Some(ToolKind::Axe(_)) => {
next.l_hand.position = Vec3::new(-0.5, 0.0, 4.0);
next.l_hand.orientation = Quaternion::rotation_x(PI / 2.0)

View File

@ -41,7 +41,7 @@ impl Animation for StandAnimation {
);
next.head.position = Vec3::new(
0.0,
-3.0 + skeleton_attr.head.0,
-2.0 + skeleton_attr.head.0,
skeleton_attr.head.1 + slow * 0.3 + breathe * -0.05,
);
next.head.orientation = Quaternion::rotation_z(head_look.x)
@ -174,7 +174,7 @@ impl Animation for StandAnimation {
next.lantern.orientation = Quaternion::rotation_x(0.1) * Quaternion::rotation_y(0.1);
next.lantern.scale = Vec3::one() * 0.65;
next.torso.position = Vec3::new(0.0, 0.0, 0.) * skeleton_attr.scaler;
next.torso.position = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;

View File

@ -805,7 +805,7 @@ impl<'a> Widget for Skillbar<'a> {
)),
ToolKind::Sword(_) => Some((
"Whirlwind",
"\nMove forward while spinning with \n your sword."
"\nMove forward while spinning with \n your sword.",
)),
ToolKind::Debug(kind) => match kind.as_ref() {
"Boost" => Some((

View File

@ -25,8 +25,9 @@ use anim::{
};
use common::{
comp::{
item::{ItemKind, ToolKind}, Body, CharacterState, Item, Last, LightAnimation, LightEmitter, Loadout,
Ori, PhysicsState, Pos, Scale, Stats, Vel,
item::{ItemKind, ToolKind},
Body, CharacterState, Item, Last, LightAnimation, LightEmitter, Loadout, Ori, PhysicsState,
Pos, Scale, Stats, Vel,
},
span,
state::{DeltaTime, State},
@ -941,23 +942,31 @@ impl FigureMgr {
let stage_time = s.timer.as_secs_f64();
match s.stage_section {
StageSection::Buildup => {
stage_time / s.static_data.buildup_duration.as_secs_f64()
stage_time
/ s.static_data.buildup_duration.as_secs_f64()
},
StageSection::Swing => {
stage_time / s.static_data.swing_duration.as_secs_f64()
},
StageSection::Recover => {
stage_time / s.static_data.recover_duration.as_secs_f64()
stage_time
/ s.static_data.recover_duration.as_secs_f64()
},
_ => 0.0,
}
},
_ => state.state_time
_ => state.state_time,
};
anim::character::SpinMeleeAnimation::update_skeleton(
&target_base,
(active_tool_kind, second_tool_kind, vel.0, time, Some(s.stage_section),),
(
active_tool_kind,
second_tool_kind,
vel.0,
time,
Some(s.stage_section),
),
stage_progress,
&mut state_animation_rate,
skeleton_attr,