|
|
|
@ -33,7 +33,12 @@ pub(crate) struct AnimationStore {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Setup drawing our cards on the screen
|
|
|
|
/// Setup drawing our cards on the screen
|
|
|
|
pub(crate) fn setup_cards(mut commands: Commands, deck: Res<Deck>) {
|
|
|
|
pub(crate) fn setup_cards(
|
|
|
|
|
|
|
|
mut commands: Commands,
|
|
|
|
|
|
|
|
deck: Res<Deck>,
|
|
|
|
|
|
|
|
mut layouts: ResMut<Assets<TextureAtlasLayout>>,
|
|
|
|
|
|
|
|
server: Res<AssetServer>,
|
|
|
|
|
|
|
|
) {
|
|
|
|
let animation_player = AnimationPlayer::default();
|
|
|
|
let animation_player = AnimationPlayer::default();
|
|
|
|
commands
|
|
|
|
commands
|
|
|
|
.spawn((
|
|
|
|
.spawn((
|
|
|
|
@ -43,6 +48,29 @@ pub(crate) fn setup_cards(mut commands: Commands, deck: Res<Deck>) {
|
|
|
|
animation_player,
|
|
|
|
animation_player,
|
|
|
|
))
|
|
|
|
))
|
|
|
|
.with_children(|parent| {
|
|
|
|
.with_children(|parent| {
|
|
|
|
|
|
|
|
// Top of card pile is a "face down" card
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let top_card_transform = Transform {
|
|
|
|
|
|
|
|
translation: Vec3::new(-400.0, -200.0, 1.0),
|
|
|
|
|
|
|
|
..default()
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
let top_card_sprite = Sprite {
|
|
|
|
|
|
|
|
custom_size: Some(Vec2::new(80.0, 128.0)),
|
|
|
|
|
|
|
|
texture_atlas: Some(TextureAtlas {
|
|
|
|
|
|
|
|
index: 108,
|
|
|
|
|
|
|
|
layout: layouts.add(TextureAtlasLayout::from_grid(
|
|
|
|
|
|
|
|
UVec2 { x: 20, y: 32 },
|
|
|
|
|
|
|
|
9,
|
|
|
|
|
|
|
|
13,
|
|
|
|
|
|
|
|
None,
|
|
|
|
|
|
|
|
None,
|
|
|
|
|
|
|
|
)),
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
image: server.load("cards.png"),
|
|
|
|
|
|
|
|
..default()
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
parent.spawn((top_card_transform, top_card_sprite, Visibility::Inherited));
|
|
|
|
|
|
|
|
}
|
|
|
|
Deck::iter_shuffled()
|
|
|
|
Deck::iter_shuffled()
|
|
|
|
.enumerate()
|
|
|
|
.enumerate()
|
|
|
|
.for_each(|(i, this_card)| {
|
|
|
|
.for_each(|(i, this_card)| {
|
|
|
|
@ -53,7 +81,7 @@ pub(crate) fn setup_cards(mut commands: Commands, deck: Res<Deck>) {
|
|
|
|
.clone();
|
|
|
|
.clone();
|
|
|
|
let this_sprite = Sprite {
|
|
|
|
let this_sprite = Sprite {
|
|
|
|
custom_size: Some(Vec2::new(80.0, 128.0)),
|
|
|
|
custom_size: Some(Vec2::new(80.0, 128.0)),
|
|
|
|
..this
|
|
|
|
..this.clone()
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let order = play::DeckOrder(i as u8);
|
|
|
|
let order = play::DeckOrder(i as u8);
|
|
|
|
|
|
|
|
|
|
|
|
@ -69,7 +97,9 @@ pub(crate) fn setup_cards(mut commands: Commands, deck: Res<Deck>) {
|
|
|
|
|
|
|
|
|
|
|
|
// Spawn card with a simple Transform parent so we can adjust the Z-axis for
|
|
|
|
// Spawn card with a simple Transform parent so we can adjust the Z-axis for
|
|
|
|
// card ordering
|
|
|
|
// card ordering
|
|
|
|
parent.spawn(Transform::default()).with_children(|parent| {
|
|
|
|
parent
|
|
|
|
|
|
|
|
.spawn((Transform::default(), Visibility::Inherited))
|
|
|
|
|
|
|
|
.with_children(|parent| {
|
|
|
|
let mut child = parent.spawn_empty();
|
|
|
|
let mut child = parent.spawn_empty();
|
|
|
|
let entity_id = child.id();
|
|
|
|
let entity_id = child.id();
|
|
|
|
let animation_target = AnimationTarget {
|
|
|
|
let animation_target = AnimationTarget {
|
|
|
|
|