diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/champion.rs | 14 | ||||
-rw-r--r-- | src/shared/faction.rs | 16 | ||||
-rw-r--r-- | src/shared/minion.rs | 7 | ||||
-rw-r--r-- | src/shared/nexus.rs | 77 | ||||
-rw-r--r-- | src/shared/shape.rs | 4 | ||||
-rw-r--r-- | src/shared/tower.rs | 7 |
6 files changed, 121 insertions, 4 deletions
diff --git a/src/shared/champion.rs b/src/shared/champion.rs index 711e520..64fc32e 100644 --- a/src/shared/champion.rs +++ b/src/shared/champion.rs @@ -11,6 +11,7 @@ pub enum Champion { Ranged, Tower, Minion, + Nexus, } impl Default for Champion { @@ -28,6 +29,7 @@ impl FromStr for Champion { "meele" => Ok(Champion::Meele), "tower" => Ok(Champion::Tower), "minion" => Ok(Champion::Minion), + "nexus" => Ok(Champion::Nexus), _ => Err(format!("unknown champion: {}", s)), } } @@ -60,6 +62,12 @@ impl Champion { max_health: 50., movement_speed: 60., }), + Champion::Nexus => BaseStats(Stats { + attack_range: 0., + attack_speed: 0., + max_health: 2000., + movement_speed: 0., + }), } } @@ -113,6 +121,9 @@ impl Champion { Champion::Minion => match ability_slot { _ => Ability::Targeted(TargetedAbility::RangedAttack(RangedAttack { damage: 2. })), }, + Champion::Nexus => match ability_slot { + _ => Ability::Targeted(TargetedAbility::MeeleAttack(MeeleAttack { damage: 0. })), + }, } } @@ -130,6 +141,9 @@ impl Champion { Champion::Minion => { BaseCooldown([1., 1., 1., 1., 1., 1., 1.].map(Duration::from_secs_f32)) } + Champion::Nexus => { + BaseCooldown([0., 0., 0., 0., 0., 0., 0.].map(Duration::from_secs_f32)) + } } } } diff --git a/src/shared/faction.rs b/src/shared/faction.rs new file mode 100644 index 0000000..4ff4a02 --- /dev/null +++ b/src/shared/faction.rs @@ -0,0 +1,16 @@ +use crate::shared::*; + +#[derive(Component, Clone, Copy, PartialEq, Eq)] +pub enum Faction { + Red, + Blue, +} + +impl Faction { + pub fn to_color(self) -> Color { + match self { + Faction::Red => Color::RED, + Faction::Blue => Color::BLUE, + } + } +} diff --git a/src/shared/minion.rs b/src/shared/minion.rs index 5d41f7a..4aa824e 100644 --- a/src/shared/minion.rs +++ b/src/shared/minion.rs @@ -1,5 +1,6 @@ use crate::shared::activation::*; use crate::shared::buffs::*; +use crate::shared::faction::*; use crate::shared::player::*; use crate::shared::shape::*; use crate::shared::stats::*; @@ -19,11 +20,12 @@ pub struct MinionBundle { activation: Activation, shape: Shape, minion: Minion, + faction: Faction, replicate: Replicate, } impl MinionBundle { - pub fn new(id: ClientId, position: Vec2, color: Color) -> Self { + pub fn new(id: ClientId, position: Vec2, faction: Faction) -> Self { let mut replicate = Replicate { replication_group: ReplicationGroup::default().set_priority(10.), ..Default::default() @@ -38,7 +40,7 @@ impl MinionBundle { MinionBundle { id: PlayerId(id), position: PlayerPosition(position), - color: PlayerColor(color), + color: PlayerColor(faction.to_color()), imperative: Imperative::Idle, cooldown: Cooldown::default(), health: Health { @@ -51,6 +53,7 @@ impl MinionBundle { activation: Activation::default(), shape: Shape::minion(), minion: Minion, + faction, replicate, } } diff --git a/src/shared/nexus.rs b/src/shared/nexus.rs new file mode 100644 index 0000000..df91db9 --- /dev/null +++ b/src/shared/nexus.rs @@ -0,0 +1,77 @@ +use crate::shared::activation::*; +use crate::shared::buffs::*; +use crate::shared::faction::*; +use crate::shared::immovable::*; +use crate::shared::player::*; +use crate::shared::shape::*; +use crate::shared::stats::*; +use crate::shared::*; +use bevy::utils::Duration; + +#[derive(Bundle)] +pub struct NexusBundle { + id: PlayerId, + position: PlayerPosition, + color: PlayerColor, + imperative: Imperative, + cooldown: Cooldown, + health: Health, + champion: Champion, + effective_stats: EffectiveStats, + buffs: Buffs, + activation: Activation, + shape: Shape, + nexus: Nexus, + immovable: Immovable, + faction: Faction, + replicate: Replicate, +} + +impl NexusBundle { + pub fn new(id: ClientId, position: Vec2, faction: Faction) -> 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::Nexus; + let effective_stats = EffectiveStats(champion.base_stats().0); + NexusBundle { + id: PlayerId(id), + position: PlayerPosition(position), + color: PlayerColor(faction.to_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::nexus(), + nexus: Nexus::default(), + immovable: Immovable, + faction, + replicate, + } + } +} + +#[derive(Component)] +pub struct Nexus { + pub spawn_minions: Timer, +} + +impl Default for Nexus { + fn default() -> Self { + let mut spawn_minions = Timer::from_seconds(60., TimerMode::Repeating); + spawn_minions.set_elapsed(Duration::from_secs_f32(60.)); + Nexus { spawn_minions } + } +} diff --git a/src/shared/shape.rs b/src/shared/shape.rs index 6e11c56..d77403d 100644 --- a/src/shared/shape.rs +++ b/src/shared/shape.rs @@ -17,4 +17,8 @@ impl Shape { pub fn minion() -> Self { Shape { radius: 5. } } + + pub fn nexus() -> Self { + Shape { radius: 35. } + } } diff --git a/src/shared/tower.rs b/src/shared/tower.rs index 5b62b7a..a21048a 100644 --- a/src/shared/tower.rs +++ b/src/shared/tower.rs @@ -1,5 +1,6 @@ use crate::shared::activation::*; use crate::shared::buffs::*; +use crate::shared::faction::*; use crate::shared::immovable::*; use crate::shared::player::*; use crate::shared::shape::*; @@ -21,11 +22,12 @@ pub struct TowerBundle { shape: Shape, tower: Tower, immovable: Immovable, + faction: Faction, replicate: Replicate, } impl TowerBundle { - pub fn new(id: ClientId, position: Vec2, color: Color) -> Self { + pub fn new(id: ClientId, position: Vec2, faction: Faction) -> Self { let mut replicate = Replicate { replication_group: ReplicationGroup::default().set_priority(10.), ..Default::default() @@ -40,7 +42,7 @@ impl TowerBundle { TowerBundle { id: PlayerId(id), position: PlayerPosition(position), - color: PlayerColor(color), + color: PlayerColor(faction.to_color()), imperative: Imperative::Idle, cooldown: Cooldown::default(), health: Health { @@ -54,6 +56,7 @@ impl TowerBundle { shape: Shape::tower(), tower: Tower::default(), immovable: Immovable, + faction, replicate, } } |