ammo system
* heads have abilities * health and ammo shows in ui
This commit is contained in:
@@ -1,38 +1,18 @@
|
||||
mod backpack_ui;
|
||||
mod ui_head_state;
|
||||
|
||||
use crate::{GameState, heads_ui::HEAD_COUNT};
|
||||
use crate::{
|
||||
GameState,
|
||||
active_heads::{HEAD_COUNT, HeadState},
|
||||
};
|
||||
use bevy::prelude::*;
|
||||
|
||||
pub use backpack_ui::BackpackAction;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Reflect)]
|
||||
pub struct BackpackHead {
|
||||
pub head: usize,
|
||||
pub health: f32,
|
||||
pub ammo: f32,
|
||||
}
|
||||
|
||||
impl BackpackHead {
|
||||
pub fn new(head: usize) -> Self {
|
||||
Self {
|
||||
head,
|
||||
health: 1.0,
|
||||
ammo: 1.0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn damage(&self) -> f32 {
|
||||
1. - self.health
|
||||
}
|
||||
|
||||
pub fn ammo_used(&self) -> f32 {
|
||||
1. - self.ammo
|
||||
}
|
||||
}
|
||||
pub use ui_head_state::UiHeadState;
|
||||
|
||||
#[derive(Resource, Default)]
|
||||
pub struct Backpack {
|
||||
pub heads: Vec<BackpackHead>,
|
||||
pub heads: Vec<HeadState>,
|
||||
}
|
||||
|
||||
#[derive(Event)]
|
||||
@@ -47,11 +27,7 @@ pub fn plugin(app: &mut App) {
|
||||
fn setup(mut commands: Commands) {
|
||||
commands.insert_resource(Backpack {
|
||||
heads: (0usize..HEAD_COUNT)
|
||||
.map(|i| BackpackHead {
|
||||
head: i,
|
||||
health: 1.,
|
||||
ammo: 1.,
|
||||
})
|
||||
.map(|i| HeadState::new(i, 10))
|
||||
.collect(),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user