From a4274ef8aa05cf1d80d4124b2a0171591830caf9 Mon Sep 17 00:00:00 2001 From: Monty Marz Date: Fri, 17 Jan 2020 22:00:00 +0000 Subject: [PATCH] Charge Icon and flashing skillbar --- assets/common/npc_names.json | 2 +- assets/voxygen/element/icons/skill_charge.vox | 3 + .../voxygen/element/icons/skill_charge_2.vox | 3 + .../voxygen/element/icons/skill_charge_3.vox | 3 + .../voxygen/element/icons/skill_slice_2.vox | 3 + .../element/skillbar/skillbar_slot_active.vox | 3 + .../skillbar/skillbar_slot_big_active.vox | 3 + .../skillbar/skillbar_slot_l_active.vox | 3 + .../skillbar/skillbar_slot_r_active.vox | 3 + voxygen/src/hud/img_ids.rs | 16 ++- voxygen/src/hud/mod.rs | 8 +- voxygen/src/hud/skillbar.rs | 100 +++++++++++++++--- voxygen/src/settings.rs | 2 +- world/src/block/mod.rs | 13 +-- 14 files changed, 134 insertions(+), 31 deletions(-) create mode 100644 assets/voxygen/element/icons/skill_charge.vox create mode 100644 assets/voxygen/element/icons/skill_charge_2.vox create mode 100644 assets/voxygen/element/icons/skill_charge_3.vox create mode 100644 assets/voxygen/element/icons/skill_slice_2.vox create mode 100644 assets/voxygen/element/skillbar/skillbar_slot_active.vox create mode 100644 assets/voxygen/element/skillbar/skillbar_slot_big_active.vox create mode 100644 assets/voxygen/element/skillbar/skillbar_slot_l_active.vox create mode 100644 assets/voxygen/element/skillbar/skillbar_slot_r_active.vox diff --git a/assets/common/npc_names.json b/assets/common/npc_names.json index e8bdc06b71..3158058f5b 100644 --- a/assets/common/npc_names.json +++ b/assets/common/npc_names.json @@ -240,7 +240,7 @@ "Ginger", "Gizmo", "Gwenivere", - "Hagrid", + "Hogrid", "Hazel", "Hector", "Herman", diff --git a/assets/voxygen/element/icons/skill_charge.vox b/assets/voxygen/element/icons/skill_charge.vox new file mode 100644 index 0000000000..a9bffe8990 --- /dev/null +++ b/assets/voxygen/element/icons/skill_charge.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bec1cad802a5751cfa9cd4d4d0159adb51e4af3e67ced65db25fcaff059e0b6f +size 57497 diff --git a/assets/voxygen/element/icons/skill_charge_2.vox b/assets/voxygen/element/icons/skill_charge_2.vox new file mode 100644 index 0000000000..d81971f6c4 --- /dev/null +++ b/assets/voxygen/element/icons/skill_charge_2.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:02751d68177ade46c3692a7abdc64f6ad222f41bab01dcb0be8beb49f91b3ae4 +size 63221 diff --git a/assets/voxygen/element/icons/skill_charge_3.vox b/assets/voxygen/element/icons/skill_charge_3.vox new file mode 100644 index 0000000000..93eaf74626 --- /dev/null +++ b/assets/voxygen/element/icons/skill_charge_3.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bd3f960fa3f1a26feb6ece373060873720d36f9644c4d3302461f97068685f84 +size 57509 diff --git a/assets/voxygen/element/icons/skill_slice_2.vox b/assets/voxygen/element/icons/skill_slice_2.vox new file mode 100644 index 0000000000..565f4a2280 --- /dev/null +++ b/assets/voxygen/element/icons/skill_slice_2.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b86b496d708546a05dca97b53805061b4c6d430fa5ff34b22400e08dccc2ae64 +size 62249 diff --git a/assets/voxygen/element/skillbar/skillbar_slot_active.vox b/assets/voxygen/element/skillbar/skillbar_slot_active.vox new file mode 100644 index 0000000000..3ffc53119a --- /dev/null +++ b/assets/voxygen/element/skillbar/skillbar_slot_active.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b3349a0ac930db681061036315a4136ba2a0009014ce659e287e1ea8c882915e +size 56172 diff --git a/assets/voxygen/element/skillbar/skillbar_slot_big_active.vox b/assets/voxygen/element/skillbar/skillbar_slot_big_active.vox new file mode 100644 index 0000000000..aa30d8875a --- /dev/null +++ b/assets/voxygen/element/skillbar/skillbar_slot_big_active.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ad9d070daefe97358d640d23f92651353e8185300c995a6a196b253e200097b4 +size 58108 diff --git a/assets/voxygen/element/skillbar/skillbar_slot_l_active.vox b/assets/voxygen/element/skillbar/skillbar_slot_l_active.vox new file mode 100644 index 0000000000..af526240ec --- /dev/null +++ b/assets/voxygen/element/skillbar/skillbar_slot_l_active.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2330b4bb03aa2eff449dcd55640198bdc805020080c0f81055eae5a866d49774 +size 56164 diff --git a/assets/voxygen/element/skillbar/skillbar_slot_r_active.vox b/assets/voxygen/element/skillbar/skillbar_slot_r_active.vox new file mode 100644 index 0000000000..9c4cadf52b --- /dev/null +++ b/assets/voxygen/element/skillbar/skillbar_slot_r_active.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3e87dca4630698130ff836d412a4e18d43d398169dbb446c375433b8cf102138 +size 56164 diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index ff0f81d731..750534e663 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -30,10 +30,14 @@ image_ids! { xp_bar_left: "voxygen.element.skillbar.xp_bar_left", xp_bar_right: "voxygen.element.skillbar.xp_bar_right", skillbar_slot: "voxygen.element.skillbar.skillbar_slot", + skillbar_slot_act: "voxygen.element.skillbar.skillbar_slot_active", skillbar_slot_l: "voxygen.element.skillbar.skillbar_slot_l", skillbar_slot_r: "voxygen.element.skillbar.skillbar_slot_r", + skillbar_slot_l_act: "voxygen.element.skillbar.skillbar_slot_l_active", + skillbar_slot_r_act: "voxygen.element.skillbar.skillbar_slot_r_active", skillbar_slot_bg: "voxygen.element.skillbar.skillbar_slot_bg", skillbar_slot_big: "voxygen.element.skillbar.skillbar_slot_big", + skillbar_slot_big_act: "voxygen.element.skillbar.skillbar_slot_big_active", skillbar_slot_big_bg: "voxygen.element.skillbar.skillbar_slot_big_bg", healthbar_bg: "voxygen.element.skillbar.healthbar_bg", energybar_bg: "voxygen.element.skillbar.energybar_bg", @@ -97,7 +101,12 @@ image_ids! { // Crosshair crosshair_inner: "voxygen.element.misc_bg.crosshair_inner", - // Icons + + +//////////////////////////////////////////////////////////////////////// + + + // Skill Icons twohsword_m1: "voxygen.element.icons.2hsword_m1", twohsword_m2: "voxygen.element.icons.2hsword_m2", twohhammer_m1: "voxygen.element.icons.2hhammer_m1", @@ -111,8 +120,9 @@ image_ids! { flyingrod_m1: "voxygen.element.icons.debug_wand_m1", flyingrod_m2: "voxygen.element.icons.debug_wand_m2", -//////////////////////////////////////////////////////////////////////// - + charge: "voxygen.element.icons.skill_charge_2", + + // Icons flower: "voxygen.element.icons.item_flower", grass: "voxygen.element.icons.item_grass", diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index a318424935..ac28a706f8 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -1649,14 +1649,20 @@ impl Hud { let ecs = client.state().ecs(); let stats = ecs.read_storage::(); let energy = ecs.read_storage::(); + let character_state = ecs.read_storage::(); let entity = client.entity(); - if let (Some(stats), Some(energy)) = (stats.get(entity), energy.get(entity)) { + if let (Some(stats), Some(energy), Some(character_state)) = ( + stats.get(entity), + energy.get(entity), + character_state.get(entity), + ) { Skillbar::new( global_state, &self.imgs, &self.fonts, &stats, &energy, + &character_state, self.pulse, ) .set(self.ids.skillbar, ui_widgets); diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index cd935021c1..2422c8b3d5 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -3,7 +3,7 @@ use super::{ /*FOCUS_COLOR, RAGE_COLOR,*/ HP_COLOR, LOW_HP_COLOR, MANA_COLOR, TEXT_COLOR, XP_COLOR, }; use crate::GlobalState; -use common::comp::{item::Debug, item::Tool, Energy, ItemKind, Stats}; +use common::comp::{item::Debug, item::Tool, ActionState, CharacterState, Energy, ItemKind, Stats}; use conrod_core::{ color, widget::{self, Button, Image, Rectangle, Text}, @@ -32,14 +32,18 @@ widget_ids! { m1_slot, m1_slot_bg, m1_text, + m1_slot_act, m1_content, m2_slot, m2_slot_bg, m2_text, + m2_slot_act, m2_content, slot1, slot1_bg, slot1_text, + slot1_icon, + slot1_act, slot2, slot2_bg, slot2_text, @@ -98,6 +102,7 @@ pub struct Skillbar<'a> { fonts: &'a Fonts, stats: &'a Stats, energy: &'a Energy, + character_state: &'a CharacterState, pulse: f32, #[conrod(common_builder)] common: widget::CommonBuilder, @@ -111,6 +116,7 @@ impl<'a> Skillbar<'a> { fonts: &'a Fonts, stats: &'a Stats, energy: &'a Energy, + character_state: &'a CharacterState, pulse: f32, ) -> Self { Self { @@ -121,6 +127,7 @@ impl<'a> Skillbar<'a> { global_state, current_resource: ResourceType::Mana, common: widget::CommonBuilder::default(), + character_state, pulse, } } @@ -516,13 +523,32 @@ impl<'a> Widget for Skillbar<'a> { .mid_bottom_with_margin_on(ui.window, 9.0) .set(state.ids.hotbar_align, ui); // M1 Slot - Image::new(self.imgs.skillbar_slot_big) - .w_h(40.0 * scale, 40.0 * scale) - .top_left_with_margins_on(state.ids.hotbar_align, -40.0 * scale, 0.0) - .set(state.ids.m1_slot, ui); + + match self.character_state.action { + ActionState::Attack { .. } => { + let fade_pulse = (self.pulse * 4.0/*speed factor*/).cos() * 0.5 + 0.6; //Animation timer; + Image::new(self.imgs.skillbar_slot_big) + .w_h(40.0 * scale, 40.0 * scale) + .top_left_with_margins_on(state.ids.hotbar_align, -40.0 * scale, 0.0) + .set(state.ids.m1_slot, ui); + Image::new(self.imgs.skillbar_slot_big_act) + .w_h(40.0 * scale, 40.0 * scale) + .middle_of(state.ids.m1_slot) + .color(Some(Color::Rgba(1.0, 1.0, 1.0, fade_pulse))) + .floating(true) + .set(state.ids.m1_slot_act, ui); + } + _ => { + Image::new(self.imgs.skillbar_slot_big) + .w_h(40.0 * scale, 40.0 * scale) + .top_left_with_margins_on(state.ids.hotbar_align, -40.0 * scale, 0.0) + .set(state.ids.m1_slot, ui); + } + } } } // M1 Slot + Image::new(self.imgs.skillbar_slot_big_bg) .w_h(36.0 * scale, 36.0 * scale) .color(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { @@ -566,10 +592,28 @@ impl<'a> Widget for Skillbar<'a> { .middle_of(state.ids.m1_slot_bg) .set(state.ids.m1_content, ui); // M2 Slot - Image::new(self.imgs.skillbar_slot_big) - .w_h(40.0 * scale, 40.0 * scale) - .right_from(state.ids.m1_slot, 0.0) - .set(state.ids.m2_slot, ui); + match self.character_state.action { + ActionState::Block { .. } => { + let fade_pulse = (self.pulse * 4.0/*speed factor*/).cos() * 0.5 + 0.6; //Animation timer; + Image::new(self.imgs.skillbar_slot_big) + .w_h(40.0 * scale, 40.0 * scale) + .right_from(state.ids.m1_slot, 0.0) + .set(state.ids.m2_slot, ui); + Image::new(self.imgs.skillbar_slot_big_act) + .w_h(40.0 * scale, 40.0 * scale) + .middle_of(state.ids.m2_slot) + .color(Some(Color::Rgba(1.0, 1.0, 1.0, fade_pulse))) + .floating(true) + .set(state.ids.m2_slot_act, ui); + } + _ => { + Image::new(self.imgs.skillbar_slot_big) + .w_h(40.0 * scale, 40.0 * scale) + .right_from(state.ids.m1_slot, 0.0) + .set(state.ids.m2_slot, ui); + } + } + Image::new(self.imgs.skillbar_slot_big_bg) .w_h(36.0 * scale, 36.0 * scale) .color(match self.stats.equipment.main.as_ref().map(|i| &i.kind) { @@ -653,15 +697,45 @@ impl<'a> Widget for Skillbar<'a> { .middle_of(state.ids.slot2) .set(state.ids.slot2_bg, ui); // Slot 1 - Image::new(self.imgs.skillbar_slot_l) - .w_h(20.0 * scale, 20.0 * scale) - .left_from(state.ids.slot2, 0.0) - .set(state.ids.slot1, ui); + // TODO: Don't hardcode this to one Skill... + // Frame flashes whenever the active skill inside this slot is activated + match self.character_state.action { + ActionState::Charge { time_left } => { + let fade = time_left.as_secs_f32() * 10.0; + Image::new(self.imgs.skillbar_slot_l) + .w_h(20.0 * scale, 20.0 * scale) + .left_from(state.ids.slot2, 0.0) + .set(state.ids.slot1, ui); + Image::new(self.imgs.skillbar_slot_l_act) + .w_h(20.0 * scale, 20.0 * scale) + .middle_of(state.ids.slot1) + .color(Some(Color::Rgba( + 1.0, + 1.0, + 1.0, + if fade > 0.6 { 0.6 } else { fade }, + ))) + .floating(true) + .set(state.ids.slot1_act, ui); + } + _ => { + Image::new(self.imgs.skillbar_slot_l) + .w_h(20.0 * scale, 20.0 * scale) + .left_from(state.ids.slot2, 0.0) + .set(state.ids.slot1, ui); + } + } Image::new(self.imgs.skillbar_slot_bg) .w_h(19.0 * scale, 19.0 * scale) .color(Some(BG_COLOR)) .middle_of(state.ids.slot1) .set(state.ids.slot1_bg, ui); + // TODO: Changeable slot image + Image::new(self.imgs.charge) + .w_h(18.0 * scale, 18.0 * scale) + //.color(Some(BG_COLOR)) + .middle_of(state.ids.slot1_bg) + .set(state.ids.slot1_icon, ui); // Slot 6 Image::new(self.imgs.skillbar_slot) .w_h(20.0 * scale, 20.0 * scale) diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index 940823465f..1e5dcb0b0d 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -88,7 +88,7 @@ impl Default for ControlSettings { respawn: KeyMouse::Key(VirtualKeyCode::Space), interact: KeyMouse::Mouse(MouseButton::Right), toggle_wield: KeyMouse::Key(VirtualKeyCode::T), - charge: KeyMouse::Key(VirtualKeyCode::V), + charge: KeyMouse::Key(VirtualKeyCode::Key1), } } } diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 9559185177..f680f25ab0 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -281,10 +281,7 @@ impl<'a> BlockGen<'a> { && (marble * 3173.7).fract() < 0.6 && humidity > 0.4 { - let treasures = [ - BlockKind::Chest, - //BlockKind::Velorite, - ]; + let treasures = [BlockKind::Chest, BlockKind::Velorite]; let flowers = [ BlockKind::BlueFlower, @@ -334,14 +331,6 @@ impl<'a> BlockGen<'a> { }, Rgb::broadcast(0), )) - } else if (wposf.z as f32) < height + 0.9 - && chaos > 0.6 - && (wposf.z as f32 > water_height + 3.0) - && marble > 0.75 - && marble_small > 0.3 - && (marble * 7323.07).fract() < 0.75 - { - Some(Block::new(BlockKind::Velorite, Rgb::broadcast(0))) } else { None }