diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/ability.rs | 8 | ||||
-rw-r--r-- | src/shared/activation.rs | 16 | ||||
-rw-r--r-- | src/shared/buffs.rs | 7 | ||||
-rw-r--r-- | src/shared/champion.rs | 15 | ||||
-rw-r--r-- | src/shared/imperative.rs | 2 | ||||
-rw-r--r-- | src/shared/player.rs | 15 | ||||
-rw-r--r-- | src/shared/stats.rs | 22 |
7 files changed, 63 insertions, 22 deletions
diff --git a/src/shared/ability.rs b/src/shared/ability.rs index cab7ae6..e776015 100644 --- a/src/shared/ability.rs +++ b/src/shared/ability.rs @@ -6,8 +6,9 @@ use std::ops::*; #[derive(Copy, Clone, PartialEq, Debug, Deserialize, Serialize)] pub enum Ability { - Targeted(TargetedAbility), + Activated(ActivatedAbility), Directional(DirectionalAbility), + Targeted(TargetedAbility), } #[derive(Copy, Clone, PartialEq, Debug, Deserialize, Serialize)] @@ -42,6 +43,11 @@ impl TargetedAbility { } #[derive(Copy, Clone, PartialEq, Debug, Deserialize, Serialize)] +pub enum ActivatedAbility { + Speed, +} + +#[derive(Copy, Clone, PartialEq, Debug, Deserialize, Serialize)] pub enum DirectionalAbility { Spear, } diff --git a/src/shared/activation.rs b/src/shared/activation.rs new file mode 100644 index 0000000..3ca6956 --- /dev/null +++ b/src/shared/activation.rs @@ -0,0 +1,16 @@ +use crate::shared::ability::*; +use crate::shared::*; +use serde::Deserialize; +use serde::Serialize; + +#[derive(Component, Message, Copy, Clone, PartialEq, Debug, Deserialize, Serialize)] +pub enum Activation { + Activate(AbilitySlot), + None, +} + +impl Default for Activation { + fn default() -> Self { + Activation::None + } +} diff --git a/src/shared/buffs.rs b/src/shared/buffs.rs new file mode 100644 index 0000000..4fe033d --- /dev/null +++ b/src/shared/buffs.rs @@ -0,0 +1,7 @@ +use crate::shared::*; + +#[derive(Clone, Component, Default, Debug)] +pub struct Buffs { + pub slow: Option<Timer>, + pub speed: Option<Timer>, +} diff --git a/src/shared/champion.rs b/src/shared/champion.rs index 28d1ff2..c32d3d5 100644 --- a/src/shared/champion.rs +++ b/src/shared/champion.rs @@ -26,28 +26,17 @@ impl FromStr for Champion { } } -pub struct Stats { - pub attack_range: f32, -} - -impl Stats { - pub fn from_champion(champion: Champion) -> Self { - match champion { - Champion::Meele => Stats { attack_range: 25. }, - Champion::Ranged => Stats { attack_range: 60. }, - } - } -} - impl Champion { pub fn to_ability(self, ability_slot: AbilitySlot) -> Ability { match self { Champion::Meele => match ability_slot { AbilitySlot::Q => Ability::Directional(DirectionalAbility::Spear), + AbilitySlot::G => Ability::Activated(ActivatedAbility::Speed), _ => Ability::Targeted(TargetedAbility::MeeleAttack), }, Champion::Ranged => match ability_slot { AbilitySlot::Q => Ability::Directional(DirectionalAbility::Spear), + AbilitySlot::G => Ability::Activated(ActivatedAbility::Speed), _ => Ability::Targeted(TargetedAbility::RangedAttack), }, } diff --git a/src/shared/imperative.rs b/src/shared/imperative.rs index 44a0e43..4291368 100644 --- a/src/shared/imperative.rs +++ b/src/shared/imperative.rs @@ -8,6 +8,6 @@ use serde::Serialize; pub enum Imperative { Idle, WalkTo(Vec2), - AttackTarget(AbilitySlot, PlayerId), AttackDirection(AbilitySlot, Vec2), + AttackTarget(AbilitySlot, PlayerId), } diff --git a/src/shared/player.rs b/src/shared/player.rs index a886499..4f571d8 100644 --- a/src/shared/player.rs +++ b/src/shared/player.rs @@ -1,3 +1,6 @@ +use crate::shared::activation::*; +use crate::shared::buffs::*; +use crate::shared::stats::*; use crate::shared::*; #[derive(Bundle)] @@ -9,6 +12,9 @@ pub struct PlayerBundle { cooldown: Cooldown, health: Health, champion: Champion, + effective_stats: EffectiveStats, + buffs: Buffs, + activation: Activation, replicate: Replicate, } @@ -20,8 +26,10 @@ impl PlayerBundle { }; replicate.enable_replicate_once::<PlayerId>(); replicate.enable_replicate_once::<PlayerColor>(); - replicate.target::<Cooldown>(NetworkTarget::Single(id)); replicate.target::<Champion>(NetworkTarget::Single(id)); + replicate.target::<Cooldown>(NetworkTarget::Single(id)); + replicate.target::<EffectiveStats>(NetworkTarget::Single(id)); + let champion = Champion::default(); PlayerBundle { id: PlayerId(id), position: PlayerPosition(position), @@ -29,7 +37,10 @@ impl PlayerBundle { imperative: Imperative::Idle, cooldown: Cooldown::default(), health: Health::default(), - champion: Champion::default(), + champion, + effective_stats: EffectiveStats(BaseStats::from_champion(champion).0), + buffs: Buffs::default(), + activation: Activation::default(), replicate, } } diff --git a/src/shared/stats.rs b/src/shared/stats.rs index 278a19f..749453c 100644 --- a/src/shared/stats.rs +++ b/src/shared/stats.rs @@ -1,16 +1,28 @@ -use crate::shared::champion::*; use crate::shared::*; -#[derive(Component, Message, Clone, Serialize, Deserialize, PartialEq)] +#[derive(Clone, Copy, Serialize, Deserialize, PartialEq)] pub struct Stats { pub attack_range: f32, + pub movement_speed: f32, } -impl Stats { +#[derive(Component, Message, Clone, Copy, Serialize, Deserialize, PartialEq)] +pub struct BaseStats(pub Stats); + +#[derive(Component, Message, Clone, Copy, Serialize, Deserialize, PartialEq)] +pub struct EffectiveStats(pub Stats); + +impl BaseStats { pub fn from_champion(champion: Champion) -> Self { match champion { - Champion::Meele => Stats { attack_range: 35. }, - Champion::Ranged => Stats { attack_range: 60. }, + Champion::Meele => BaseStats(Stats { + attack_range: 25., + movement_speed: 75., + }), + Champion::Ranged => BaseStats(Stats { + attack_range: 60., + movement_speed: 85., + }), } } } |