WIP animation

This commit is contained in:
Monty Marz 2021-03-25 02:12:15 +01:00 committed by Sam
parent c0c6ff3063
commit cc70560027
5 changed files with 38 additions and 3 deletions

BIN
assets/voxygen/element/skillbar/flame_0.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/skillbar/flame_1.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/skillbar/flame_2.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -299,6 +299,9 @@ image_ids! {
skillbar_frame: "voxygen.element.skillbar.frame",
health_bg: "voxygen.element.skillbar.health_bg",
health_frame: "voxygen.element.skillbar.health_frame",
flame_frame_0: "voxygen.element.skillbar.flame_0",
flame_frame_1: "voxygen.element.skillbar.flame_1",
flame_frame_2: "voxygen.element.skillbar.flame_2",
stamina_bg: "voxygen.element.skillbar.stamina_bg",
stamina_frame: "voxygen.element.skillbar.stamina_frame",
m1_ico: "voxygen.element.icons.m1",

View File

@ -3,7 +3,7 @@ use super::{
img_ids::{Imgs, ImgsRot},
item_imgs::ItemImgs,
slots, BarNumbers, ShortcutNumbers, BLACK, CRITICAL_HP_COLOR, HP_COLOR, LOW_HP_COLOR,
STAMINA_COLOR, TEXT_COLOR, UI_HIGHLIGHT_0,
STAMINA_COLOR, QUALITY_EPIC, TEXT_COLOR, UI_HIGHLIGHT_0,
};
use crate::{
hud::ComboFloater,
@ -31,6 +31,8 @@ use conrod_core::{
widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
};
use vek::*;
use rand::Rng;
use inline_tweak::*;
widget_ids! {
struct Ids {
@ -71,6 +73,8 @@ widget_ids! {
hp_txt_alignment,
hp_txt_bg,
hp_txt,
decay_flames,
decay_flames_align,
// Stamina-Bar
stamina_alignment,
stamina_filling,
@ -310,12 +314,31 @@ impl<'a> Widget for Skillbar<'a> {
.top_left_with_margins_on(state.ids.hp_alignment, 0.0, 0.0)
.set(state.ids.hp_filling, ui);
let decayed_health = 1.0 - self.health.maximum() as f64 / self.health.base_max() as f64;
if decayed_health > 0.0 {
let decay_bar_len = 480.0 * decayed_health * 0.5;
Image::new(self.imgs.bar_content)
.w_h(480.0 * decayed_health, 18.0)
.color(Some(BLACK))
.w_h(decay_bar_len, 18.0)
.color(Some(QUALITY_EPIC))
.top_right_with_margins_on(state.ids.hp_alignment, 0.0, 0.0)
.set(state.ids.hp_decayed, ui);
Rectangle::fill_with([decay_bar_len, 12.0], color::TRANSPARENT)
.top_right_with_margins_on(state.ids.hp_decayed, tweak!(-11.0), 0.0)
.crop_kids()
.set(state.ids.decay_flames_align, ui);
let mut rng = rand::thread_rng();
let max = tweak!(2);
let frame_no = rng.gen_range(0..max);
Image::new(match frame_no {
0 => self.imgs.flame_frame_0,
1 => self.imgs.flame_frame_2,
_ => self.imgs.flame_frame_0,
})
.w_h(480.0, 12.0)
.color(Some(QUALITY_EPIC))
.bottom_right_with_margins_on(state.ids.decay_flames_align, 0.0, 0.0)
.set(state.ids.decay_flames, ui);
}
Image::new(self.imgs.health_frame)
.w_h(484.0, 24.0)