boss UI
parent
8071fb2d18
commit
82c8e85c63
|
@ -0,0 +1,7 @@
|
||||||
|
[gd_resource type="FontVariation" load_steps=2 format=3 uid="uid://ndkrorerbxft"]
|
||||||
|
|
||||||
|
[ext_resource type="FontFile" uid="uid://cgwa8bjiyv534" path="res://Assets/Fonts/alagard.ttf" id="1_krbnd"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
base_font = ExtResource("1_krbnd")
|
||||||
|
spacing_glyph = 4
|
|
@ -0,0 +1,7 @@
|
||||||
|
[gd_resource type="FontVariation" load_steps=2 format=3 uid="uid://bjnmfgt5yqle7"]
|
||||||
|
|
||||||
|
[ext_resource type="FontFile" uid="uid://bo3obq6sos7lu" path="res://Assets/Fonts/compass-pro.ttf" id="1_brr65"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
base_font = ExtResource("1_brr65")
|
||||||
|
spacing_glyph = 4
|
Binary file not shown.
|
@ -0,0 +1,33 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="font_data_dynamic"
|
||||||
|
type="FontFile"
|
||||||
|
uid="uid://bo3obq6sos7lu"
|
||||||
|
path="res://.godot/imported/compass-pro.ttf-5e813dda823d14f9501edd94273a527c.fontdata"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Assets/Fonts/compass-pro.ttf"
|
||||||
|
dest_files=["res://.godot/imported/compass-pro.ttf-5e813dda823d14f9501edd94273a527c.fontdata"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
Rendering=null
|
||||||
|
antialiasing=1
|
||||||
|
generate_mipmaps=false
|
||||||
|
multichannel_signed_distance_field=false
|
||||||
|
msdf_pixel_range=8
|
||||||
|
msdf_size=48
|
||||||
|
allow_system_fallback=true
|
||||||
|
force_autohinter=false
|
||||||
|
hinting=1
|
||||||
|
subpixel_positioning=1
|
||||||
|
oversampling=0.0
|
||||||
|
Fallbacks=null
|
||||||
|
fallbacks=[]
|
||||||
|
Compress=null
|
||||||
|
compress=true
|
||||||
|
preload=[]
|
||||||
|
language_support={}
|
||||||
|
script_support={}
|
||||||
|
opentype_features={}
|
Binary file not shown.
|
@ -0,0 +1,19 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="mp3"
|
||||||
|
type="AudioStreamMP3"
|
||||||
|
uid="uid://ipss4y2gkk3y"
|
||||||
|
path="res://.godot/imported/gillette.mp3-5dd6f93f1f9df01778f80e3dd2caeb1e.mp3str"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Assets/Music/gillette.mp3"
|
||||||
|
dest_files=["res://.godot/imported/gillette.mp3-5dd6f93f1f9df01778f80e3dd2caeb1e.mp3str"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
loop=false
|
||||||
|
loop_offset=0
|
||||||
|
bpm=0
|
||||||
|
beat_count=0
|
||||||
|
bar_beats=4
|
|
@ -0,0 +1,22 @@
|
||||||
|
[gd_resource type="ParticleProcessMaterial" load_steps=3 format=3 uid="uid://rcjujd5dv7lm"]
|
||||||
|
|
||||||
|
[sub_resource type="Gradient" id="Gradient_v7xci"]
|
||||||
|
offsets = PackedFloat32Array(0.525926, 0.6)
|
||||||
|
colors = PackedColorArray(0, 0, 0, 1, 1, 0, 0, 1)
|
||||||
|
|
||||||
|
[sub_resource type="GradientTexture1D" id="GradientTexture1D_pntll"]
|
||||||
|
gradient = SubResource("Gradient_v7xci")
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
particle_flag_disable_z = true
|
||||||
|
spread = 180.0
|
||||||
|
gravity = Vector3(0, 0, 0)
|
||||||
|
initial_velocity_min = 64.0
|
||||||
|
initial_velocity_max = 96.0
|
||||||
|
orbit_velocity_min = 0.0
|
||||||
|
orbit_velocity_max = 0.0
|
||||||
|
linear_accel_min = -128.0
|
||||||
|
linear_accel_max = -96.0
|
||||||
|
scale_min = 0.1
|
||||||
|
scale_max = 0.2
|
||||||
|
color_initial_ramp = SubResource("GradientTexture1D_pntll")
|
Binary file not shown.
After Width: | Height: | Size: 102 B |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://b07x1uedfexfi"
|
||||||
|
path="res://.godot/imported/boss-bar.png-14402f9e8d9c8a30b766d18572a90e44.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Assets/Sprites/UI/boss-bar.png"
|
||||||
|
dest_files=["res://.godot/imported/boss-bar.png-14402f9e8d9c8a30b766d18572a90e44.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
|
@ -43,6 +43,12 @@ public partial class Hurtbox : BoundingBox, IFaction
|
||||||
Vector2 knockbackOrigin = default,
|
Vector2 knockbackOrigin = default,
|
||||||
Vector2 knockbackVector = default)
|
Vector2 knockbackVector = default)
|
||||||
{
|
{
|
||||||
|
if (!IsInstanceValid(this))
|
||||||
|
{
|
||||||
|
// this should fix the error of the object being invalid
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Vector2 knockbackDir = knockbackVector;
|
Vector2 knockbackDir = knockbackVector;
|
||||||
if (knockbackDir == default)
|
if (knockbackDir == default)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using Godot;
|
using Godot;
|
||||||
|
using GodotUtilities;
|
||||||
|
|
||||||
namespace SupaLidlGame.Characters;
|
namespace SupaLidlGame.Characters;
|
||||||
|
|
||||||
|
@ -7,8 +8,24 @@ public abstract partial class Boss : Enemy
|
||||||
[Export]
|
[Export]
|
||||||
public State.NPC.NPCStateMachine BossStateMachine { get; set; }
|
public State.NPC.NPCStateMachine BossStateMachine { get; set; }
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public string BossName { get; set; }
|
||||||
|
|
||||||
public abstract int Intensity { get; }
|
public abstract int Intensity { get; }
|
||||||
|
|
||||||
|
private bool _isActive;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public bool IsActive { get; set; }
|
public bool IsActive
|
||||||
|
{
|
||||||
|
get => _isActive;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_isActive = value;
|
||||||
|
|
||||||
|
// register or deregister ourselves when we are active/inactive
|
||||||
|
this.GetAncestor<Utils.World>()
|
||||||
|
.RegisterBoss(_isActive ? this : null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,16 @@ public partial class Doc : Boss
|
||||||
{
|
{
|
||||||
TelegraphAnimation = GetNode<AnimationPlayer>("Animations/Telegraph");
|
TelegraphAnimation = GetNode<AnimationPlayer>("Animations/Telegraph");
|
||||||
base._Ready();
|
base._Ready();
|
||||||
|
|
||||||
|
// when we are hurt, start the boss fight
|
||||||
|
Hurt += (Events.HealthChangedArgs args) =>
|
||||||
|
{
|
||||||
|
if (!IsActive)
|
||||||
|
{
|
||||||
|
IsActive = true;
|
||||||
|
Inventory.SelectedItem = Inventory.Items[0];
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=47 format=3 uid="uid://d2skjvvx6fal0"]
|
[gd_scene load_steps=52 format=3 uid="uid://d2skjvvx6fal0"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Characters/Doc.cs" id="2_3elet"]
|
[ext_resource type="Script" path="res://Characters/Doc.cs" id="2_3elet"]
|
||||||
[ext_resource type="Shader" path="res://Shaders/Flash.gdshader" id="2_5jxom"]
|
[ext_resource type="Shader" path="res://Shaders/Flash.gdshader" id="2_5jxom"]
|
||||||
|
@ -22,6 +22,9 @@
|
||||||
[ext_resource type="Script" path="res://Utils/AnimationManager.cs" id="16_bsvls"]
|
[ext_resource type="Script" path="res://Utils/AnimationManager.cs" id="16_bsvls"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bd8l8kafb42dt" path="res://Assets/Sprites/Particles/circle.png" id="16_x277j"]
|
[ext_resource type="Texture2D" uid="uid://bd8l8kafb42dt" path="res://Assets/Sprites/Particles/circle.png" id="16_x277j"]
|
||||||
[ext_resource type="Material" uid="uid://bat28samf7ukd" path="res://Assets/Sprites/Particles/NPCDamageProcessMaterial.tres" id="17_iomdx"]
|
[ext_resource type="Material" uid="uid://bat28samf7ukd" path="res://Assets/Sprites/Particles/NPCDamageProcessMaterial.tres" id="17_iomdx"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://c1a7lvb4uuwfy" path="res://Assets/Sprites/Particles/circle-16.png" id="19_p0p6c"]
|
||||||
|
[ext_resource type="Material" uid="uid://rcjujd5dv7lm" path="res://Assets/Sprites/Particles/DocIntroParticles.tres" id="19_q4rt1"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dvqap2uhcah63" path="res://Items/Weapons/Sword.tscn" id="24_y1go8"]
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_7n7iy"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_7n7iy"]
|
||||||
resource_local_to_scene = true
|
resource_local_to_scene = true
|
||||||
|
@ -376,6 +379,14 @@ _data = {
|
||||||
"hurt": SubResource("Animation_dxevc")
|
"hurt": SubResource("Animation_dxevc")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_uemm6"]
|
||||||
|
resource_name = "intro"
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_kjxam"]
|
||||||
|
_data = {
|
||||||
|
"intro": SubResource("Animation_uemm6")
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="Gradient" id="Gradient_lcoxi"]
|
[sub_resource type="Gradient" id="Gradient_lcoxi"]
|
||||||
offsets = PackedFloat32Array(0.37037, 0.651852)
|
offsets = PackedFloat32Array(0.37037, 0.651852)
|
||||||
colors = PackedColorArray(0.367549, 0.894801, 1, 1, 0.992095, 0.364069, 1, 1)
|
colors = PackedColorArray(0.367549, 0.894801, 1, 1, 0.992095, 0.364069, 1, 1)
|
||||||
|
@ -429,6 +440,7 @@ collision_layer = 10
|
||||||
collision_mask = 17
|
collision_mask = 17
|
||||||
script = ExtResource("2_3elet")
|
script = ExtResource("2_3elet")
|
||||||
BossStateMachine = NodePath("BossStateMachine")
|
BossStateMachine = NodePath("BossStateMachine")
|
||||||
|
BossName = "Doc, The Two-Time"
|
||||||
Health = 1000.0
|
Health = 1000.0
|
||||||
Sprite = NodePath("Sprite")
|
Sprite = NodePath("Sprite")
|
||||||
Inventory = NodePath("Inventory")
|
Inventory = NodePath("Inventory")
|
||||||
|
@ -520,6 +532,11 @@ libraries = {
|
||||||
"": SubResource("AnimationLibrary_xe5eq")
|
"": SubResource("AnimationLibrary_xe5eq")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[node name="Misc" type="AnimationPlayer" parent="Animations"]
|
||||||
|
libraries = {
|
||||||
|
"": SubResource("AnimationLibrary_kjxam")
|
||||||
|
}
|
||||||
|
|
||||||
[node name="Effects" type="Node2D" parent="."]
|
[node name="Effects" type="Node2D" parent="."]
|
||||||
|
|
||||||
[node name="UnwantedFrequenciesParticles" type="GPUParticles2D" parent="Effects"]
|
[node name="UnwantedFrequenciesParticles" type="GPUParticles2D" parent="Effects"]
|
||||||
|
@ -539,6 +556,13 @@ lifetime = 0.4
|
||||||
one_shot = true
|
one_shot = true
|
||||||
explosiveness = 1.0
|
explosiveness = 1.0
|
||||||
|
|
||||||
|
[node name="IntroParticles" type="GPUParticles2D" parent="Effects"]
|
||||||
|
position = Vector2(0, -8)
|
||||||
|
emitting = false
|
||||||
|
amount = 32
|
||||||
|
process_material = ExtResource("19_q4rt1")
|
||||||
|
texture = ExtResource("19_p0p6c")
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite2D" parent="."]
|
[node name="Sprite" type="Sprite2D" parent="."]
|
||||||
y_sort_enabled = true
|
y_sort_enabled = true
|
||||||
use_parent_material = true
|
use_parent_material = true
|
||||||
|
@ -563,6 +587,8 @@ y_sort_enabled = true
|
||||||
script = ExtResource("8_r8ejq")
|
script = ExtResource("8_r8ejq")
|
||||||
Items = Array[Node2D]([])
|
Items = Array[Node2D]([])
|
||||||
|
|
||||||
|
[node name="Sword" parent="Inventory" instance=ExtResource("24_y1go8")]
|
||||||
|
|
||||||
[node name="HurtSound" type="AudioStreamPlayer2D" parent="."]
|
[node name="HurtSound" type="AudioStreamPlayer2D" parent="."]
|
||||||
stream = ExtResource("9_stm0e")
|
stream = ExtResource("9_stm0e")
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,8 @@ public partial class NPC : Character
|
||||||
|
|
||||||
public bool ShouldMove { get; set; } = true;
|
public bool ShouldMove { get; set; } = true;
|
||||||
|
|
||||||
|
public bool CanAttack { get; set; } = true;
|
||||||
|
|
||||||
protected float[] _weights = new float[16];
|
protected float[] _weights = new float[16];
|
||||||
protected int _bestWeightIdx;
|
protected int _bestWeightIdx;
|
||||||
protected double _thinkTimeElapsed = 0;
|
protected double _thinkTimeElapsed = 0;
|
||||||
|
@ -232,7 +234,7 @@ public partial class NPC : Character
|
||||||
float dist = GlobalPosition.DistanceSquaredTo(pos);
|
float dist = GlobalPosition.DistanceSquaredTo(pos);
|
||||||
UpdateWeights(pos);
|
UpdateWeights(pos);
|
||||||
|
|
||||||
if (dist < 1024)
|
if (dist < 1600 && CanAttack)
|
||||||
{
|
{
|
||||||
if (Inventory.SelectedItem is Weapon weapon)
|
if (Inventory.SelectedItem is Weapon weapon)
|
||||||
{
|
{
|
||||||
|
|
|
@ -108,7 +108,7 @@ public abstract partial class Weapon : Item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void _on_hitbox_hit(BoundingBox box)
|
public virtual void OnHitboxHit(BoundingBox box)
|
||||||
{
|
{
|
||||||
if (box is Hurtbox hurtbox)
|
if (box is Hurtbox hurtbox)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,27 +1,57 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://1pb3mpmrl7lc"]
|
[gd_scene load_steps=6 format=3 uid="uid://1pb3mpmrl7lc"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Utils/World.cs" id="1_1k6ew"]
|
[ext_resource type="Script" path="res://Utils/World.cs" id="1_1k6ew"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b2x17su05ou5w" path="res://Scenes/Maps/Arena.tscn" id="2_avsrq"]
|
[ext_resource type="PackedScene" uid="uid://b2x17su05ou5w" path="res://Scenes/Maps/Arena.tscn" id="2_avsrq"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bxo553hblp6nf" path="res://UI/HealthBar.tscn" id="3_5rhge"]
|
[ext_resource type="PackedScene" uid="uid://bxo553hblp6nf" path="res://UI/HealthBar.tscn" id="3_5rhge"]
|
||||||
|
[ext_resource type="Script" path="res://UI/UIController.cs" id="3_fe62s"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://01d24ij5av1y" path="res://UI/BossBar.tscn" id="5_8njq4"]
|
||||||
|
|
||||||
[node name="World" type="Node2D" node_paths=PackedStringArray("Control")]
|
[node name="World" type="Node2D" node_paths=PackedStringArray("UIController")]
|
||||||
script = ExtResource("1_1k6ew")
|
script = ExtResource("1_1k6ew")
|
||||||
StartingArea = ExtResource("2_avsrq")
|
StartingArea = ExtResource("2_avsrq")
|
||||||
Control = NodePath("CanvasLayer/UI")
|
UIController = NodePath("CanvasLayer/UI")
|
||||||
|
|
||||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
[node name="UI" type="Control" parent="CanvasLayer"]
|
[node name="UI" type="Control" parent="CanvasLayer" node_paths=PackedStringArray("BossBar")]
|
||||||
z_index = 128
|
z_index = 128
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 0
|
anchors_preset = 15
|
||||||
offset_right = 640.0
|
anchor_right = 1.0
|
||||||
offset_bottom = 480.0
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
script = ExtResource("3_fe62s")
|
||||||
|
BossBar = NodePath("Bottom/BossBar")
|
||||||
|
|
||||||
[node name="HealthBar" parent="CanvasLayer/UI" instance=ExtResource("3_5rhge")]
|
[node name="Top" type="HBoxContainer" parent="CanvasLayer/UI"]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 1
|
anchors_preset = 10
|
||||||
anchor_left = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 0.0
|
offset_bottom = 40.0
|
||||||
grow_horizontal = 0
|
grow_horizontal = 2
|
||||||
grow_vertical = 1
|
|
||||||
|
[node name="Margin" type="MarginContainer" parent="CanvasLayer/UI/Top"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/margin_left = 16
|
||||||
|
theme_override_constants/margin_top = 16
|
||||||
|
|
||||||
|
[node name="HealthBar" parent="CanvasLayer/UI/Top/Margin" instance=ExtResource("3_5rhge")]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="Bottom" type="HBoxContainer" parent="CanvasLayer/UI"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 12
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_top = -44.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 0
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="BossBar" parent="CanvasLayer/UI/Bottom" instance=ExtResource("5_8njq4")]
|
||||||
|
layout_mode = 2
|
||||||
|
|
|
@ -251,7 +251,7 @@ physics_layer_0/collision_layer = 1
|
||||||
sources/2 = SubResource("TileSetAtlasSource_5yxvt")
|
sources/2 = SubResource("TileSetAtlasSource_5yxvt")
|
||||||
sources/0 = SubResource("TileSetAtlasSource_fcd6d")
|
sources/0 = SubResource("TileSetAtlasSource_fcd6d")
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_88hwc"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_spvk4"]
|
||||||
resource_local_to_scene = true
|
resource_local_to_scene = true
|
||||||
shader = ExtResource("5_h8k5p")
|
shader = ExtResource("5_h8k5p")
|
||||||
shader_parameter/color = Quaternion(1, 1, 1, 1)
|
shader_parameter/color = Quaternion(1, 1, 1, 1)
|
||||||
|
@ -342,7 +342,7 @@ visible = false
|
||||||
position = Vector2(120, -112)
|
position = Vector2(120, -112)
|
||||||
|
|
||||||
[node name="Doc" parent="Entities" index="18" instance=ExtResource("4_ej0f3")]
|
[node name="Doc" parent="Entities" index="18" instance=ExtResource("4_ej0f3")]
|
||||||
material = SubResource("ShaderMaterial_88hwc")
|
material = SubResource("ShaderMaterial_spvk4")
|
||||||
|
|
||||||
[node name="PointLight2D" type="PointLight2D" parent="Entities" index="19"]
|
[node name="PointLight2D" type="PointLight2D" parent="Entities" index="19"]
|
||||||
position = Vector2(168, -42)
|
position = Vector2(168, -42)
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
using Godot;
|
||||||
|
using SupaLidlGame.Characters;
|
||||||
|
|
||||||
|
namespace SupaLidlGame.UI;
|
||||||
|
|
||||||
|
public partial class BossBar : VBoxContainer
|
||||||
|
{
|
||||||
|
public TextureProgressBar ProgressBar { get; set; }
|
||||||
|
public Label BossNameLabel { get; set; }
|
||||||
|
|
||||||
|
private Boss _boss;
|
||||||
|
|
||||||
|
public Boss Boss
|
||||||
|
{
|
||||||
|
get => _boss;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetupBoss(value);
|
||||||
|
_boss = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
ProgressBar = GetNode<TextureProgressBar>("BarMargin/BossBar");
|
||||||
|
BossNameLabel = GetNode<Label>("LabelMargin/BossNameLabel");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnBossHurt(Events.HealthChangedArgs args)
|
||||||
|
{
|
||||||
|
ProgressBar.Value = args.NewHealth;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnBossDeath(Events.HealthChangedArgs args)
|
||||||
|
{
|
||||||
|
Visible = false;
|
||||||
|
Boss = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetupBoss(Boss newBoss)
|
||||||
|
{
|
||||||
|
if (_boss is not null)
|
||||||
|
{
|
||||||
|
_boss.Hurt -= OnBossHurt;
|
||||||
|
_boss.Death -= OnBossDeath;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newBoss is not null)
|
||||||
|
{
|
||||||
|
newBoss.Hurt += OnBossHurt;
|
||||||
|
newBoss.Death += OnBossDeath;
|
||||||
|
|
||||||
|
ProgressBar.MaxValue = newBoss.Health;
|
||||||
|
ProgressBar.Value = newBoss.Health;
|
||||||
|
|
||||||
|
Visible = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
[gd_scene load_steps=7 format=3 uid="uid://01d24ij5av1y"]
|
||||||
|
|
||||||
|
[ext_resource type="Theme" uid="uid://cksjbu3vrup5" path="res://UI/Themes/supalidl.tres" id="1_2r0jo"]
|
||||||
|
[ext_resource type="Script" path="res://UI/BossBar.cs" id="1_x3sqy"]
|
||||||
|
[ext_resource type="FontFile" uid="uid://cgwa8bjiyv534" path="res://Assets/Fonts/alagard.ttf" id="2_ctee6"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://b75oak1nd2q6x" path="res://Assets/Sprites/UI/over-under-bar.png" id="3_0ftem"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://co7xm7i5f6n51" path="res://Assets/Sprites/UI/progress-bar.png" id="4_6pnyx"]
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_njgrw"]
|
||||||
|
font = ExtResource("2_ctee6")
|
||||||
|
font_color = Color(0.921569, 0.929412, 0.913725, 1)
|
||||||
|
outline_size = 4
|
||||||
|
outline_color = Color(0.117647, 0.113725, 0.223529, 1)
|
||||||
|
|
||||||
|
[node name="BossBar" type="VBoxContainer"]
|
||||||
|
offset_right = 139.0
|
||||||
|
offset_bottom = 44.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
script = ExtResource("1_x3sqy")
|
||||||
|
|
||||||
|
[node name="LabelMargin" type="MarginContainer" parent="."]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/margin_top = 8
|
||||||
|
|
||||||
|
[node name="BossNameLabel" type="Label" parent="LabelMargin"]
|
||||||
|
texture_filter = 1
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
theme = ExtResource("1_2r0jo")
|
||||||
|
text = "Doc, The Two Time"
|
||||||
|
label_settings = SubResource("LabelSettings_njgrw")
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|
||||||
|
[node name="BarMargin" type="MarginContainer" parent="."]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
theme_override_constants/margin_left = 64
|
||||||
|
theme_override_constants/margin_right = 64
|
||||||
|
theme_override_constants/margin_bottom = 8
|
||||||
|
|
||||||
|
[node name="BossBar" type="TextureProgressBar" parent="BarMargin"]
|
||||||
|
texture_filter = 1
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
value = 50.0
|
||||||
|
nine_patch_stretch = true
|
||||||
|
stretch_margin_left = 3
|
||||||
|
stretch_margin_top = 3
|
||||||
|
stretch_margin_right = 3
|
||||||
|
stretch_margin_bottom = 3
|
||||||
|
texture_under = ExtResource("3_0ftem")
|
||||||
|
texture_progress = ExtResource("4_6pnyx")
|
|
@ -6,11 +6,9 @@
|
||||||
|
|
||||||
[node name="HealthBar" type="Control"]
|
[node name="HealthBar" type="Control"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 0
|
||||||
anchor_right = 1.0
|
offset_right = 128.0
|
||||||
anchor_bottom = 1.0
|
offset_bottom = 8.0
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
script = ExtResource("1_54tsn")
|
script = ExtResource("1_54tsn")
|
||||||
|
|
||||||
[node name="TextureProgressBar" type="TextureProgressBar" parent="."]
|
[node name="TextureProgressBar" type="TextureProgressBar" parent="."]
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
[gd_resource type="Theme" format=3 uid="uid://cksjbu3vrup5"]
|
[gd_resource type="Theme" load_steps=2 format=3 uid="uid://cksjbu3vrup5"]
|
||||||
|
|
||||||
|
[ext_resource type="FontFile" uid="uid://cgwa8bjiyv534" path="res://Assets/Fonts/alagard.ttf" id="1_gdvg0"]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
|
default_font = ExtResource("1_gdvg0")
|
||||||
|
/fonts/Alagard = ExtResource("1_gdvg0")
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace SupaLidlGame.UI;
|
||||||
|
|
||||||
|
public partial class UIController : Control
|
||||||
|
{
|
||||||
|
[Export]
|
||||||
|
public TextureProgressBar PlayerHealthBar { get; set; }
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public BossBar BossBar { get; set; }
|
||||||
|
}
|
|
@ -18,7 +18,7 @@ public partial class World : Node2D
|
||||||
public Player CurrentPlayer { get; set; }
|
public Player CurrentPlayer { get; set; }
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public Control Control { get; set; }
|
public UI.UIController UIController { get; set; }
|
||||||
|
|
||||||
private Dictionary<string, Map> _maps;
|
private Dictionary<string, Map> _maps;
|
||||||
|
|
||||||
|
@ -61,14 +61,19 @@ public partial class World : Node2D
|
||||||
|
|
||||||
CurrentPlayer.Hurt += (Events.HealthChangedArgs args) =>
|
CurrentPlayer.Hurt += (Events.HealthChangedArgs args) =>
|
||||||
{
|
{
|
||||||
var bar = Control.GetNode<UI.HealthBar>("HealthBar");
|
// TODO: move this to UI controller and add a setup method
|
||||||
GD.Print("Set health bar");
|
var bar = UIController.GetNode<UI.HealthBar>("Top/Margin/HealthBar");
|
||||||
bar.ProgressBar.Value = args.NewHealth;
|
bar.ProgressBar.Value = args.NewHealth;
|
||||||
};
|
};
|
||||||
|
|
||||||
base._Ready();
|
base._Ready();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RegisterBoss(Boss boss)
|
||||||
|
{
|
||||||
|
UIController.BossBar.Boss = boss;
|
||||||
|
}
|
||||||
|
|
||||||
private void LoadMap(Map map)
|
private void LoadMap(Map map)
|
||||||
{
|
{
|
||||||
GD.Print("Loading map " + map.Name);
|
GD.Print("Loading map " + map.Name);
|
||||||
|
|
Loading…
Reference in New Issue