From 2d8740b1e29fc356fbe88cea21059ec83d8c0cf0 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Fri, 22 Mar 2024 15:42:19 +0100 Subject: feat: minions --- src/shared/champion.rs | 14 ++++++++++++ src/shared/minion.rs | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/shared/shape.rs | 4 ++++ 3 files changed, 78 insertions(+) create mode 100644 src/shared/minion.rs (limited to 'src/shared') diff --git a/src/shared/champion.rs b/src/shared/champion.rs index 1667672..711e520 100644 --- a/src/shared/champion.rs +++ b/src/shared/champion.rs @@ -10,6 +10,7 @@ pub enum Champion { Meele, Ranged, Tower, + Minion, } impl Default for Champion { @@ -26,6 +27,7 @@ impl FromStr for Champion { "ranged" => Ok(Champion::Ranged), "meele" => Ok(Champion::Meele), "tower" => Ok(Champion::Tower), + "minion" => Ok(Champion::Minion), _ => Err(format!("unknown champion: {}", s)), } } @@ -52,6 +54,12 @@ impl Champion { max_health: 500., movement_speed: 0., }), + Champion::Minion => BaseStats(Stats { + attack_range: 30., + attack_speed: 1., + max_health: 50., + movement_speed: 60., + }), } } @@ -102,6 +110,9 @@ impl Champion { Ability::Targeted(TargetedAbility::RangedAttack(RangedAttack { damage: 100. })) } }, + Champion::Minion => match ability_slot { + _ => Ability::Targeted(TargetedAbility::RangedAttack(RangedAttack { damage: 2. })), + }, } } @@ -116,6 +127,9 @@ impl Champion { Champion::Tower => { BaseCooldown([10., 10., 10., 10., 10., 10., 10.].map(Duration::from_secs_f32)) } + Champion::Minion => { + BaseCooldown([1., 1., 1., 1., 1., 1., 1.].map(Duration::from_secs_f32)) + } } } } diff --git a/src/shared/minion.rs b/src/shared/minion.rs new file mode 100644 index 0000000..5d41f7a --- /dev/null +++ b/src/shared/minion.rs @@ -0,0 +1,60 @@ +use crate::shared::activation::*; +use crate::shared::buffs::*; +use crate::shared::player::*; +use crate::shared::shape::*; +use crate::shared::stats::*; +use crate::shared::*; + +#[derive(Bundle)] +pub struct MinionBundle { + id: PlayerId, + position: PlayerPosition, + color: PlayerColor, + imperative: Imperative, + cooldown: Cooldown, + health: Health, + champion: Champion, + effective_stats: EffectiveStats, + buffs: Buffs, + activation: Activation, + shape: Shape, + minion: Minion, + replicate: Replicate, +} + +impl MinionBundle { + pub fn new(id: ClientId, position: Vec2, color: Color) -> Self { + let mut replicate = Replicate { + replication_group: ReplicationGroup::default().set_priority(10.), + ..Default::default() + }; + replicate.enable_replicate_once::(); + replicate.enable_replicate_once::(); + replicate.target::(NetworkTarget::Single(id)); + replicate.target::(NetworkTarget::Single(id)); + replicate.target::(NetworkTarget::Single(id)); + let champion = Champion::Minion; + let effective_stats = EffectiveStats(champion.base_stats().0); + MinionBundle { + id: PlayerId(id), + position: PlayerPosition(position), + color: PlayerColor(color), + imperative: Imperative::Idle, + cooldown: Cooldown::default(), + health: Health { + health: effective_stats.0.max_health, + shield: 0., + }, + champion, + effective_stats, + buffs: Buffs::default(), + activation: Activation::default(), + shape: Shape::minion(), + minion: Minion, + replicate, + } + } +} + +#[derive(Component, Message, Serialize, Deserialize, Clone, Copy, Debug, PartialEq)] +pub struct Minion; diff --git a/src/shared/shape.rs b/src/shared/shape.rs index 7423375..6e11c56 100644 --- a/src/shared/shape.rs +++ b/src/shared/shape.rs @@ -13,4 +13,8 @@ impl Shape { pub fn tower() -> Self { Shape { radius: 25. } } + + pub fn minion() -> Self { + Shape { radius: 5. } + } } -- cgit v1.2.3