|
|
|
|
@ -91,10 +91,10 @@ impl Plugin for Display3dPlugin {
|
|
|
|
|
.or_else(any_component_removed::<Selected>())
|
|
|
|
|
),
|
|
|
|
|
// vantage point camera when playing against AI
|
|
|
|
|
// vantage_point
|
|
|
|
|
// .run_if(in_state(GameState::Play))
|
|
|
|
|
// .run_if(in_state(PlayState::AiBogo).and_then(in_state(TurnState(Side::B))))
|
|
|
|
|
// .run_if(any_component_added::<Selected>().or_else(any_component_removed::<Selected>())),
|
|
|
|
|
vantage_point
|
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
|
.run_if(in_state(PlayState::AiBogo).and_then(in_state(TurnState(Side::B))))
|
|
|
|
|
.run_if(any_component_added::<Selected>().or_else(state_changed::<TurnState>)),
|
|
|
|
|
// vantage point camera when playing against human
|
|
|
|
|
vantage_point
|
|
|
|
|
.run_if(in_state(GameState::Play))
|
|
|
|
|
@ -1036,10 +1036,12 @@ fn switch_sides(
|
|
|
|
|
fn vantage_point(
|
|
|
|
|
selected: Query<Entity, With<Selected>>,
|
|
|
|
|
mut players: Query<&mut AnimationPlayer, (With<Camera>, With<Display3d>)>,
|
|
|
|
|
events: EventReader<StateTransitionEvent<TurnState>>,
|
|
|
|
|
gltfs: Res<Assets<Gltf>>,
|
|
|
|
|
state: Res<State<game::TurnState>>,
|
|
|
|
|
tweaks: Res<Assets<Tweaks>>,
|
|
|
|
|
tweaks_file: Res<tweak::GameTweaks>,
|
|
|
|
|
mut up: Local<bool>
|
|
|
|
|
) {
|
|
|
|
|
let tweak = tweaks
|
|
|
|
|
.get(tweaks_file.handle.clone())
|
|
|
|
|
@ -1051,28 +1053,32 @@ fn vantage_point(
|
|
|
|
|
players.iter_mut().for_each(|mut player| {
|
|
|
|
|
info!("Getting a better view");
|
|
|
|
|
|
|
|
|
|
let animation_key = match state.get() {
|
|
|
|
|
game::TurnState(game::Side::A) => {
|
|
|
|
|
if selected.iter().count() == 1 {
|
|
|
|
|
"display3d_models_animations_turn_up_a"
|
|
|
|
|
} else {
|
|
|
|
|
"display3d_models_animations_turn_down_a"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
game::TurnState(game::Side::B) => {
|
|
|
|
|
if selected.iter().count() == 1 {
|
|
|
|
|
"display3d_models_animations_turn_up_b"
|
|
|
|
|
} else {
|
|
|
|
|
"display3d_models_animations_turn_down_b"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// play down events on state transitions
|
|
|
|
|
let animation_key = if events.len() > 0 && *up {
|
|
|
|
|
*up = false;
|
|
|
|
|
match state.get() {
|
|
|
|
|
game::TurnState(game::Side::A) => "display3d_models_animations_turn_down_a",
|
|
|
|
|
game::TurnState(game::Side::B) => "display3d_models_animations_turn_down_b",
|
|
|
|
|
}
|
|
|
|
|
// Play up events when selected > 0
|
|
|
|
|
} else if selected.iter().count() == 1 && !*up {
|
|
|
|
|
*up = true;
|
|
|
|
|
match state.get() {
|
|
|
|
|
game::TurnState(game::Side::A) => "display3d_models_animations_turn_up_a",
|
|
|
|
|
game::TurnState(game::Side::B) => "display3d_models_animations_turn_up_b",
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
""
|
|
|
|
|
};
|
|
|
|
|
let animation_val = tweak.get::<String>(animation_key).unwrap();
|
|
|
|
|
let animation = gltf.named_animations.get(animation_val.as_str()).expect("Camera Transition Animation");
|
|
|
|
|
player.start_with_transition(
|
|
|
|
|
animation.clone(),
|
|
|
|
|
Duration::from_secs_f32(1.00),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if animation_key != "" {
|
|
|
|
|
let animation_val = tweak.get::<String>(animation_key).unwrap();
|
|
|
|
|
let animation = gltf.named_animations.get(animation_val.as_str()).expect("Camera Transition Animation");
|
|
|
|
|
player.start_with_transition(
|
|
|
|
|
animation.clone(),
|
|
|
|
|
Duration::from_secs_f32(1.00),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|