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