different ammo per head (#30)
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
([
|
||||
(key:"angry demonstrator", ability:Thrown, range:80, projectile:"molotov"),//0
|
||||
(key:"carnival knife thrower", range:60),//1
|
||||
(key:"chicago gangster", ability:Gun, range:60),//2
|
||||
(key:"commando", ability:Gun, range:60),//3
|
||||
(key:"angry demonstrator", ability:Thrown, ammo: 10, range:90, projectile:"molotov"),//0
|
||||
(key:"carnival knife thrower", range:60, ammo: 5, ),//1
|
||||
(key:"chicago gangster", ability:Gun, ammo: 25, range:60),//2
|
||||
(key:"commando", ability:Gun, ammo: 26, range:60),//3
|
||||
(key:"field medic"),//4
|
||||
(key:"geisha"),//5
|
||||
(key:"goblin", ability:Arrow, range:60),//6
|
||||
(key:"green grocer", range:60),//7
|
||||
(key:"highland hammer thrower", ability:Thrown, range:80, projectile:"hammer"),//8
|
||||
(key:"legionnaire", ability:Gun, range:60),//9
|
||||
(key:"mig pilot", ability:Gun, range:60, controls:Plane),//10
|
||||
(key:"goblin", ability:Arrow, ammo: 5, range:90),//6
|
||||
(key:"green grocer", range:60, ammo: 10, ),//7
|
||||
(key:"highland hammer thrower", ability:Thrown, ammo: 10, range:80, projectile:"hammer"),//8
|
||||
(key:"legionnaire", ability:Gun, ammo: 25, range:60),//9
|
||||
(key:"mig pilot", ability:Gun, ammo: 5, range:60, controls:Plane),//10
|
||||
(key:"nanny", ability:Thrown, range:60),//11
|
||||
(key:"panic attack"),//12
|
||||
(key:"salty sea dog"),//13
|
||||
(key:"snow plough operator"),//14
|
||||
(key:"soldier ant"),//15
|
||||
(key:"super market shopper", ability:Thrown, range:80, projectile:"handbag"),//16
|
||||
(key:"troll", ability:Thrown, range:80),//17
|
||||
(key:"super market shopper", ability:Thrown, ammo: 10, range:80, projectile:"handbag"),//16
|
||||
(key:"troll", ability:Thrown, ammo: 10, range:80),//17
|
||||
])
|
||||
|
||||
@@ -77,7 +77,7 @@ fn update(
|
||||
t.translation,
|
||||
t.rotation,
|
||||
t.forward(),
|
||||
&ShapeCastConfig::from_max_distance(80.),
|
||||
&ShapeCastConfig::from_max_distance(150.),
|
||||
&filter,
|
||||
) {
|
||||
cmds.entity(first_hit.entity).trigger(Hit { damage: 50 });
|
||||
|
||||
@@ -4,6 +4,7 @@ mod ui_head_state;
|
||||
use crate::{
|
||||
GameState,
|
||||
heads::{HEAD_COUNT, HeadState},
|
||||
heads_database::HeadsDatabase,
|
||||
};
|
||||
use bevy::prelude::*;
|
||||
|
||||
@@ -36,10 +37,10 @@ pub fn plugin(app: &mut App) {
|
||||
app.add_systems(OnEnter(GameState::Playing), setup);
|
||||
}
|
||||
|
||||
fn setup(mut commands: Commands) {
|
||||
fn setup(mut commands: Commands, heads: Res<HeadsDatabase>) {
|
||||
commands.insert_resource(Backpack {
|
||||
heads: (0usize..HEAD_COUNT)
|
||||
.map(|i| HeadState::new(i, 10))
|
||||
.map(|i| HeadState::new(i, heads.as_ref()))
|
||||
.collect(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -31,7 +31,8 @@ pub struct HeadState {
|
||||
}
|
||||
|
||||
impl HeadState {
|
||||
pub fn new(head: usize, ammo: u32) -> Self {
|
||||
pub fn new(head: usize, heads_db: &HeadsDatabase) -> Self {
|
||||
let ammo = heads_db.head_stats(head).ammo;
|
||||
Self {
|
||||
head,
|
||||
health: 100,
|
||||
|
||||
@@ -20,6 +20,12 @@ pub struct HeadStats {
|
||||
pub controls: HeadControls,
|
||||
#[serde(default)]
|
||||
pub projectile: String,
|
||||
#[serde(default = "default_ammo")]
|
||||
pub ammo: u32,
|
||||
}
|
||||
|
||||
fn default_ammo() -> u32 {
|
||||
10
|
||||
}
|
||||
|
||||
#[derive(Debug, Asset, Reflect, Serialize, Deserialize)]
|
||||
|
||||
@@ -34,7 +34,13 @@ fn init(mut commands: Commands, query: Query<(Entity, &EnemySpawn)>, heads_db: R
|
||||
Hitpoints::new(100),
|
||||
Npc,
|
||||
ActiveHead(id),
|
||||
ActiveHeads::new([Some(HeadState::new(id, 10)), None, None, None, None]),
|
||||
ActiveHeads::new([
|
||||
Some(HeadState::new(id, heads_db.as_ref())),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
]),
|
||||
Ai,
|
||||
))
|
||||
.observe(on_kill);
|
||||
|
||||
@@ -57,6 +57,7 @@ fn spawn(
|
||||
asset_server: Res<AssetServer>,
|
||||
query: Query<&Transform, With<SpawnPoint>>,
|
||||
assets: Res<GameAssets>,
|
||||
heads_db: Res<HeadsDatabase>,
|
||||
) {
|
||||
let Some(spawn) = query.iter().next() else {
|
||||
return;
|
||||
@@ -76,11 +77,11 @@ fn spawn(
|
||||
Player,
|
||||
ActiveHead(0),
|
||||
ActiveHeads::new([
|
||||
Some(HeadState::new(0, 10)),
|
||||
Some(HeadState::new(3, 10)),
|
||||
Some(HeadState::new(6, 10)),
|
||||
Some(HeadState::new(10, 10)),
|
||||
Some(HeadState::new(9, 10)),
|
||||
Some(HeadState::new(0, heads_db.as_ref())),
|
||||
Some(HeadState::new(3, heads_db.as_ref())),
|
||||
Some(HeadState::new(6, heads_db.as_ref())),
|
||||
Some(HeadState::new(10, heads_db.as_ref())),
|
||||
Some(HeadState::new(9, heads_db.as_ref())),
|
||||
]),
|
||||
Hitpoints::new(100),
|
||||
CameraTarget,
|
||||
|
||||
Reference in New Issue
Block a user