DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

13931c45f8ab0d1dc61d7e6ff73568af447da3d6 — Jonni Liljamo 1 year, 7 months ago 4eea99d
feat(client): render name and cost on supply piles
1 files changed, 39 insertions(+), 0 deletions(-)

M client/src/plugins/game/card/mod.rs
M client/src/plugins/game/card/mod.rs => client/src/plugins/game/card/mod.rs +39 -0
@@ 8,6 8,7 @@

use bevy::prelude::*;
use bevy_rapier3d::prelude::*;
use bevy_text_mesh::prelude::*;

use crate::game_status::Card;



@@ 90,6 91,9 @@ impl Default for VisualCardBundle {

#[derive(Resource)]
pub struct VisualCardData {
    font_normal: Handle<TextMeshFont>,
    font_medium: Handle<TextMeshFont>,
    font_bold: Handle<TextMeshFont>,
    mesh: Handle<Mesh>,
    card_background: Handle<StandardMaterial>,
}


@@ 109,6 113,9 @@ impl FromWorld for VisualCardData {
        };

        Self {
            font_normal: asset_server.load("fonts/FiraMono-Regular.ttf#mesh"),
            font_medium: asset_server.load("fonts/FiraMono-Medium.ttf#mesh"),
            font_bold: asset_server.load("fonts/FiraMono-Bold.ttf#mesh"),
            mesh: meshes.add(
                      shape::Quad {
                          size: Vec2::new(VisualCard::ASPECT_RATIO / 2., VisualCard::ASPECT_RATIO),


@@ 137,6 144,38 @@ fn on_spawn_card(
                },
                ..Default::default()
            });

            // card name
            parent.spawn(TextMeshBundle {
                text_mesh: TextMesh {
                    text: card.card.name.clone(),
                    style: TextMeshStyle {
                        font: card_data.font_medium.clone(),
                        font_size: SizeUnit::NonStandard(5.),
                        color: Color::rgb(0.2, 0.2, 0.2),
                        ..Default::default()
                    },
                    ..Default::default()
                },
                transform: Transform::from_xyz(-0.3, 0.2, 0.),
                ..Default::default()
            });

            // card cost
            parent.spawn(TextMeshBundle {
                text_mesh: TextMesh {
                    text: card.card.cost.to_string(),
                    style: TextMeshStyle {
                        font: card_data.font_bold.clone(),
                        font_size: SizeUnit::NonStandard(7.),
                        color: Color::rgb(1., 1., 1.),
                        ..Default::default()
                    },
                    ..Default::default()
                },
                transform: Transform::from_xyz(0.2, -0.575, 0.),
                ..Default::default()
            });
        });
    }
}