|
|
|
@ -1,4 +1,4 @@
|
|
|
|
use std::f32::consts::PI;
|
|
|
|
use std::{f32::consts::PI, ops::RangeInclusive};
|
|
|
|
|
|
|
|
|
|
|
|
use crate::{deck::*, *};
|
|
|
|
use crate::{deck::*, *};
|
|
|
|
use bevy::{
|
|
|
|
use bevy::{
|
|
|
|
@ -120,30 +120,57 @@ fn setup_animations(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Pre-req: requires deck location and helper function for each spot's placement
|
|
|
|
|
|
|
|
// For each spot on board
|
|
|
|
// For each spot on board
|
|
|
|
// Move from deck location (TBD) to spot
|
|
|
|
RangeInclusive::<u8>::new(0, 3).for_each(|x| {
|
|
|
|
// For each card
|
|
|
|
RangeInclusive::<u8>::new(0, 3).for_each(|y| {
|
|
|
|
// Assign this curve to the target
|
|
|
|
let a = Vec3::new(-100.0, 0.0, 0.0);
|
|
|
|
// todo!("Setup deal animations");
|
|
|
|
let b = play::card_placement(&play::PlayLocation { x, y });
|
|
|
|
}
|
|
|
|
let c = Vec3::new(100.0, 0.0, 0.0);
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
// Serve Deck -> Spot Animation
|
|
|
|
// Pre-req: requires discard location and helper function for each spot's placement
|
|
|
|
{
|
|
|
|
// For each spot on board
|
|
|
|
let mut animation = AnimationClip::default();
|
|
|
|
// Move from spot location to discard pile (location TBD)
|
|
|
|
targets.iter().for_each(|target| {
|
|
|
|
// For each card
|
|
|
|
let curve = AnimatableCurve::new(
|
|
|
|
// Assign this curve to the target
|
|
|
|
animated_field!(Transform::translation),
|
|
|
|
// todo!("Setup discard animations");
|
|
|
|
AnimatableKeyframeCurve::new([0.0, 1.0].into_iter().zip([a, b]))
|
|
|
|
|
|
|
|
.expect("Serve Card animation"),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
animation.add_curve_to_target(*target, curve);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
let animation_handle = clips.add(animation);
|
|
|
|
|
|
|
|
let (graph, animation_index) = AnimationGraph::from_clip(animation_handle);
|
|
|
|
|
|
|
|
let graph_handle = AnimationGraphHandle(graphs.add(graph));
|
|
|
|
|
|
|
|
animation_store.store.insert(
|
|
|
|
|
|
|
|
format!("deck->{:?}", (x, y)),
|
|
|
|
|
|
|
|
(graph_handle, animation_index),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Spot -> Discard Animation
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let mut animation = AnimationClip::default();
|
|
|
|
|
|
|
|
targets.iter().for_each(|target| {
|
|
|
|
|
|
|
|
let curve = AnimatableCurve::new(
|
|
|
|
|
|
|
|
animated_field!(Transform::translation),
|
|
|
|
|
|
|
|
AnimatableKeyframeCurve::new([0.0, 1.0].into_iter().zip([b, c]))
|
|
|
|
|
|
|
|
.expect("Serve Card animation"),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
animation.add_curve_to_target(*target, curve);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
let animation_handle = clips.add(animation);
|
|
|
|
|
|
|
|
let (graph, animation_index) = AnimationGraph::from_clip(animation_handle);
|
|
|
|
|
|
|
|
let graph_handle = AnimationGraphHandle(graphs.add(graph));
|
|
|
|
|
|
|
|
animation_store.store.insert(
|
|
|
|
|
|
|
|
format!("{:?}->discard", (x, y)),
|
|
|
|
|
|
|
|
(graph_handle, animation_index),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
commands.insert_resource(animation_store);
|
|
|
|
commands.insert_resource(animation_store);
|
|
|
|
// Card Animations:
|
|
|
|
|
|
|
|
// active_card_animation = AnimationClip::default() // simple rotation
|
|
|
|
|
|
|
|
// for each (X, Y) in board:
|
|
|
|
|
|
|
|
// deck_to_X_Y = AnimationClip::default() // Move from deck to X Y position
|
|
|
|
|
|
|
|
// X_Y_to_sets = AnimationClip::default() // Move from X Y position to sets pile
|
|
|
|
|
|
|
|
// All need AnimationTarget, AnimationGraphHandle, and AnimationPlayer
|
|
|
|
|
|
|
|
// TODO: (example: https://bevyengine.org/examples/animation/animated-transform/)
|
|
|
|
// TODO: (example: https://bevyengine.org/examples/animation/animated-transform/)
|
|
|
|
// Button Animations:
|
|
|
|
// Button Animations:
|
|
|
|
// active_button_animation = AnimationClip::default() // color and size
|
|
|
|
// active_button_animation = AnimationClip::default() // color and size
|
|
|
|
|