aboutsummaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2024-03-22 15:42:19 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2024-03-22 15:42:19 +0100
commit2d8740b1e29fc356fbe88cea21059ec83d8c0cf0 (patch)
tree63dce5c6502861d52a1d982b705c65a2d2e4c60d /src/shared
parent91419fb01ef5dcdc06d9f6774d16d3ccca1e4b57 (diff)
feat: minions
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/champion.rs14
-rw-r--r--src/shared/minion.rs60
-rw-r--r--src/shared/shape.rs4
3 files changed, 78 insertions, 0 deletions
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::<PlayerId>();
+ replicate.enable_replicate_once::<PlayerColor>();
+ replicate.target::<Champion>(NetworkTarget::Single(id));
+ replicate.target::<Cooldown>(NetworkTarget::Single(id));
+ replicate.target::<EffectiveStats>(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. }
+ }
}