diff --git a/Resources/BossPhases/Rumia_SP1.tres b/Resources/BossPhases/Rumia_SP1.tres index 00e15883..0dd3c9fe 100644 --- a/Resources/BossPhases/Rumia_SP1.tres +++ b/Resources/BossPhases/Rumia_SP1.tres @@ -1,8 +1,9 @@ -[gd_resource type="Resource" script_class="BossPhase" load_steps=12 format=3 uid="uid://ccj0cqbveey8c"] +[gd_resource type="Resource" script_class="BossPhase" load_steps=14 format=3 uid="uid://ccj0cqbveey8c"] [ext_resource type="Script" path="res://Scripts/Resources/SimpleMovementPattern.cs" id="1_lw82i"] [ext_resource type="PackedScene" uid="uid://dohakkayqj4w2" path="res://Scenes/Weapons/Bullets/enemyBullet_green.tscn" id="1_o4um1"] [ext_resource type="Script" path="res://Scripts/AttackPatterns/SpiralPattern.cs" id="2_7268a"] +[ext_resource type="Script" path="res://Scripts/Resources/SpeedModifier.cs" id="3_606tl"] [ext_resource type="Script" path="res://Scripts/Resources/BossPhase.cs" id="3_o6234"] [ext_resource type="PackedScene" uid="uid://by2rk6gx67f7e" path="res://Scenes/Weapons/Bullets/enemyBullet_yellow.tscn" id="4_ruawj"] [ext_resource type="Script" path="res://Scripts/Resources/PatternGroup.cs" id="6_6mg1u"] @@ -15,19 +16,28 @@ transitionType = 1 easeType = 2 WaitForCompletion = true +[sub_resource type="Resource" id="Resource_80ngy"] +script = ExtResource("3_606tl") +ModifierType = 0 +Easing = 0 +Invert = true +MinimumSpeed = 10.0 +ScalingFactor = 10.0 + [sub_resource type="Resource" id="Resource_0v4v8"] script = ExtResource("2_7268a") BulletScene = ExtResource("1_o4um1") bulletSpeed = 80.0 bulletCount = 12 rotationSpeed = 0.0 -_rotationOffset = 0.0 +_rotationOffset = 45.0 duration = 1.0 burstInterval = 1.0 spread = 180.0 owner = 2 _damageType = 0 _bulletDamage = 1.0 +_modifier = SubResource("Resource_80ngy") _timeModifiers = Array[Resource]([]) _targetPlayer = false WaitForCompletion = true @@ -38,13 +48,14 @@ BulletScene = ExtResource("4_ruawj") bulletSpeed = 80.0 bulletCount = 12 rotationSpeed = 0.0 -_rotationOffset = 0.0 +_rotationOffset = -45.0 duration = 1.0 burstInterval = 1.0 spread = 180.0 owner = 2 _damageType = 0 _bulletDamage = 1.0 +_modifier = SubResource("Resource_80ngy") _timeModifiers = null _targetPlayer = false WaitForCompletion = true @@ -64,6 +75,7 @@ WaitForCompletion = true [resource] script = ExtResource("3_o6234") +PhaseName = "Night Sign \"Night Bird\"" Threshold = 900 PlayAnimation = true Patterns = Array[Resource]([SubResource("Resource_upj22"), SubResource("Resource_gm1rv"), SubResource("Resource_5fq8v"), SubResource("Resource_gm1rv")]) diff --git a/Resources/BossPhases/TestBoss1.tres b/Resources/BossPhases/TestBoss1.tres index 2e0b8cfc..bf8aa00f 100644 --- a/Resources/BossPhases/TestBoss1.tres +++ b/Resources/BossPhases/TestBoss1.tres @@ -39,6 +39,6 @@ WaitForCompletion = false [resource] script = ExtResource("1_0cgch") -Threshold = 990 +Threshold = 950 PlayAnimation = false Patterns = Array[Resource]([SubResource("Resource_acaax"), ExtResource("2_7n56o"), ExtResource("3_mwcf3"), SubResource("Resource_o8win"), ExtResource("2_7n56o"), ExtResource("3_mwcf3"), SubResource("Resource_k77ig"), ExtResource("2_7n56o"), ExtResource("3_mwcf3"), SubResource("Resource_5ocg5"), ExtResource("2_7n56o"), ExtResource("3_mwcf3")]) diff --git a/Resources/Patterns/rumia_ns_1_spiralized.tres b/Resources/Patterns/rumia_ns_1_spiralized.tres index a11f21b4..c6142e7a 100644 --- a/Resources/Patterns/rumia_ns_1_spiralized.tres +++ b/Resources/Patterns/rumia_ns_1_spiralized.tres @@ -15,7 +15,7 @@ bulletSpeed = 70.0 bulletCount = 10 rotationSpeed = 0.0 _rotationOffset = 0.0 -duration = 3.0 +duration = 4.0 burstInterval = 0.3 spread = 0.0 owner = 2 diff --git a/Resources/Patterns/rumia_ns_2.tres b/Resources/Patterns/rumia_ns_2.tres index d0cdc953..6cc653d8 100644 --- a/Resources/Patterns/rumia_ns_2.tres +++ b/Resources/Patterns/rumia_ns_2.tres @@ -8,49 +8,52 @@ [sub_resource type="Resource" id="Resource_ne4q3"] script = ExtResource("2_ee42k") BulletScene = ExtResource("1_4xpdn") -bulletSpeed = 20.0 +bulletSpeed = 40.0 bulletCount = 10 rotationSpeed = 120.0 _rotationOffset = 0.0 -duration = 1.0 +duration = 0.4 burstInterval = 2.0 spread = 360.0 owner = 2 _damageType = 0 _bulletDamage = 1.0 _timeModifiers = null +_targetPlayer = false WaitForCompletion = true [sub_resource type="Resource" id="Resource_kohuh"] script = ExtResource("2_ee42k") BulletScene = ExtResource("3_gr7a3") -bulletSpeed = 20.0 +bulletSpeed = 50.0 bulletCount = 16 rotationSpeed = 60.0 _rotationOffset = 0.0 -duration = 1.0 +duration = 0.4 burstInterval = 2.0 spread = 360.0 owner = 2 _damageType = 0 _bulletDamage = 1.0 _timeModifiers = null +_targetPlayer = false WaitForCompletion = true [sub_resource type="Resource" id="Resource_depjj"] script = ExtResource("2_ee42k") BulletScene = ExtResource("1_4xpdn") -bulletSpeed = 20.0 +bulletSpeed = 50.0 bulletCount = 10 rotationSpeed = 60.0 _rotationOffset = 0.0 -duration = 4.0 +duration = 0.4 burstInterval = 2.0 spread = 360.0 owner = 2 _damageType = 0 _bulletDamage = 1.0 _timeModifiers = null +_targetPlayer = false WaitForCompletion = true [resource] diff --git a/Resources/Weapons/EnemyWeapon.tres b/Resources/Weapons/EnemyWeapon.tres index e2b5a426..a763a968 100644 --- a/Resources/Weapons/EnemyWeapon.tres +++ b/Resources/Weapons/EnemyWeapon.tres @@ -1,6 +1,5 @@ -[gd_resource type="Resource" script_class="WeaponResource" load_steps=4 format=3 uid="uid://cdfmedtgp2rcn"] +[gd_resource type="Resource" script_class="WeaponResource" load_steps=3 format=3 uid="uid://cdfmedtgp2rcn"] -[ext_resource type="PackedScene" uid="uid://cuixq5ex0j40h" path="res://Scenes/enemyBullet.tscn" id="1_c5ala"] [ext_resource type="Resource" uid="uid://dqnvesdj0dk3v" path="res://Resources/Bullets/simple_enemy_bullet.tres" id="1_eps1c"] [ext_resource type="Script" path="res://Scripts/Resources/WeaponResource.cs" id="2_8ycgt"] @@ -8,7 +7,6 @@ script = ExtResource("2_8ycgt") Name = "Enemy Weapon" BulletData = ExtResource("1_eps1c") -BulletScene = ExtResource("1_c5ala") RateOfFire = 0.4 BulletCapacity = 4 ReloadTime = 1.0 @@ -18,10 +16,4 @@ BulletsPerShot = 1 SpreadAngle = 0.0 RandomSpread = 0.0 AmmoKey = "" -BulletSpeed = 50.0 -BulletDamage = 1.0 -LifeTime = 10.0 _rotationOffset = 0.0 -owner = 2 -_damageType = 0 -_timeModifiers = null diff --git a/Scenes/Actors/Rumia.tscn b/Scenes/Actors/Rumia.tscn index c338df15..e6046d84 100644 --- a/Scenes/Actors/Rumia.tscn +++ b/Scenes/Actors/Rumia.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=14 format=3 uid="uid://d1rlw6ddpmrn8"] +[gd_scene load_steps=15 format=3 uid="uid://d1rlw6ddpmrn8"] [ext_resource type="Script" path="res://Scripts/Actors/Boss.cs" id="1_na4uq"] [ext_resource type="Resource" uid="uid://ks6fypeil6gk" path="res://Resources/BossPhases/TestBoss1.tres" id="2_1rhf6"] @@ -6,6 +6,7 @@ [ext_resource type="Script" path="res://Scripts/Components/ProximityPlayerDetection.cs" id="3_gka5j"] [ext_resource type="Resource" uid="uid://ccj0cqbveey8c" path="res://Resources/BossPhases/Rumia_SP1.tres" id="3_j7lbl"] [ext_resource type="Texture2D" uid="uid://csuprfskdo1qp" path="res://Sprites/Portraits/Rumia.png" id="4_at5iq"] +[ext_resource type="PackedScene" uid="uid://bwlstkdibs7oc" path="res://Scenes/HUD/BossHud.tscn" id="4_ehp8q"] [ext_resource type="PackedScene" uid="uid://crry0rgk7a8sm" path="res://Scenes/Weapons/BaseWeapon.tscn" id="4_xc6nm"] [ext_resource type="PackedScene" uid="uid://cuixq5ex0j40h" path="res://Scenes/enemyBullet.tscn" id="5_g1p0m"] [ext_resource type="Script" path="res://Scripts/Components/BulletSpawner.cs" id="7_2obh7"] @@ -26,7 +27,9 @@ size = Vector2(8, 12) collision_layer = 16 collision_mask = 9 script = ExtResource("1_na4uq") +BossName = "Rumia" Phases = Array[Resource]([ExtResource("2_1rhf6"), ExtResource("3_j7lbl")]) +BossHudPrefab = ExtResource("4_ehp8q") _bossPortraitTexture = ExtResource("4_at5iq") Health = 1000.0 metadata/_edit_group_ = true diff --git a/Scenes/HUD/BossHud.tscn b/Scenes/HUD/BossHud.tscn new file mode 100644 index 00000000..e2d99524 --- /dev/null +++ b/Scenes/HUD/BossHud.tscn @@ -0,0 +1,88 @@ +[gd_scene load_steps=5 format=3 uid="uid://bwlstkdibs7oc"] + +[ext_resource type="LabelSettings" uid="uid://buk3e7bbwmnv1" path="res://Resources/Styles/Hud_Text_Style.tres" id="1_a0we0"] +[ext_resource type="Script" path="res://Scripts/UI/BossHud.cs" id="1_n2ke0"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_u7d4e"] +bg_color = Color(0.406489, 0.00678394, 4.81308e-08, 1) +corner_radius_top_left = 2 +corner_radius_top_right = 2 +corner_radius_bottom_right = 2 +corner_radius_bottom_left = 2 +anti_aliasing = false + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_c8usm"] +bg_color = Color(0.713167, 0.181152, 0.0413054, 1) +corner_radius_top_left = 2 +corner_radius_top_right = 2 +corner_radius_bottom_right = 2 +corner_radius_bottom_left = 2 +anti_aliasing = false + +[node name="CanvasLayer" type="CanvasLayer" node_paths=PackedStringArray("BossNameLabel", "SpellCardNameLabel", "SpellCardsCountLabel", "SpellCardTimerLabel", "BossHealthBar")] +script = ExtResource("1_n2ke0") +BossNameLabel = NodePath("Boss Bar/HBoxContainer/VBoxContainer/BossName") +SpellCardNameLabel = NodePath("Boss Bar/HBoxContainer/SpellCardName") +SpellCardsCountLabel = NodePath("Boss Bar/HBoxContainer/VBoxContainer2/PhasesCount") +SpellCardTimerLabel = NodePath("Boss Bar/HBoxContainer/VBoxContainer2/Time") +BossHealthBar = NodePath("Boss Bar/HBoxContainer/VBoxContainer/BossHealthBar") + +[node name="Boss Bar" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 0 +offset_left = 87.0 +offset_top = 2.0 +offset_right = 315.0 +offset_bottom = 42.0 + +[node name="HBoxContainer" type="HBoxContainer" parent="Boss Bar"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer2" type="VBoxContainer" parent="Boss Bar/HBoxContainer"] +layout_mode = 2 + +[node name="Time" type="Label" parent="Boss Bar/HBoxContainer/VBoxContainer2"] +layout_mode = 2 +text = "30" +label_settings = ExtResource("1_a0we0") + +[node name="PhasesCount" type="Label" parent="Boss Bar/HBoxContainer/VBoxContainer2"] +layout_mode = 2 +text = "x3" +label_settings = ExtResource("1_a0we0") + +[node name="VBoxContainer" type="VBoxContainer" parent="Boss Bar/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="BossName" type="Label" parent="Boss Bar/HBoxContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 0 +text = "Boss Name" +label_settings = ExtResource("1_a0we0") +horizontal_alignment = 1 + +[node name="BossHealthBar" type="ProgressBar" parent="Boss Bar/HBoxContainer/VBoxContainer"] +custom_minimum_size = Vector2(0, 2) +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_constants/outline_size = 0 +theme_override_styles/background = SubResource("StyleBoxFlat_u7d4e") +theme_override_styles/fill = SubResource("StyleBoxFlat_c8usm") +value = 50.0 +show_percentage = false + +[node name="SpellCardName" type="Label" parent="Boss Bar/HBoxContainer"] +custom_minimum_size = Vector2(100, 30) +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 0 +text = "Attack name goes here and it should wrap " +label_settings = ExtResource("1_a0we0") +horizontal_alignment = 2 +autowrap_mode = 2 diff --git a/Scenes/HUD/HUD.tscn b/Scenes/HUD/HUD.tscn index 4197ae7d..46101754 100644 --- a/Scenes/HUD/HUD.tscn +++ b/Scenes/HUD/HUD.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=12 format=3 uid="uid://dkwi1hu1bixoe"] +[gd_scene load_steps=13 format=3 uid="uid://dkwi1hu1bixoe"] [ext_resource type="Script" path="res://Scripts/Hud.cs" id="1_m0hb0"] [ext_resource type="FontFile" uid="uid://ccm3u37q1hvux" path="res://fonts/Xolonium-Regular.ttf" id="2_0xmx2"] [ext_resource type="LabelSettings" uid="uid://buk3e7bbwmnv1" path="res://Resources/Styles/Hud_Text_Style.tres" id="2_x7kl7"] [ext_resource type="Texture2D" uid="uid://dde36pgb8fbwc" path="res://Sprites/selector_big.png" id="3_hee3i"] +[ext_resource type="PackedScene" uid="uid://bwlstkdibs7oc" path="res://Scenes/HUD/BossHud.tscn" id="5_vmict"] [sub_resource type="AtlasTexture" id="AtlasTexture_h626b"] atlas = ExtResource("3_hee3i") @@ -133,3 +134,6 @@ label_settings = ExtResource("2_x7kl7") [node name="ItemsContainer" type="VBoxContainer" parent="VBoxContainer"] layout_mode = 2 theme_override_constants/separation = 0 + +[node name="BossHud" parent="." instance=ExtResource("5_vmict")] +visible = false diff --git a/Scripts/Actors/Boss.cs b/Scripts/Actors/Boss.cs index eade4c05..4792606d 100644 --- a/Scripts/Actors/Boss.cs +++ b/Scripts/Actors/Boss.cs @@ -8,7 +8,9 @@ namespace Cirno.Scripts.Actors; public partial class Boss : Enemy, IActivable { + [Export] public string BossName { get; private set; } [Export] private Array Phases; + [Export] private PackedScene BossHudPrefab; private int currentPhaseIndex = 0; private bool _started = false; @@ -26,6 +28,8 @@ public partial class Boss : Enemy, IActivable [Export] private Texture2D _bossPortraitTexture; + + private BossHud _bossHud; public override void _Ready() { @@ -34,28 +38,45 @@ public partial class Boss : Enemy, IActivable _homePosition = this.GlobalPosition; - if (_bossPortraitTexture is not null) + if (BossHudPrefab is not null) { - var canvas = new CanvasLayer(); - canvas.Name = "BossPhaseAnimationCanvas"; + _bossHud = BossHudPrefab.Instantiate(); + _gameManager.CallDeferred("add_child", _bossHud); + + _bossHud.BossName = BossName; + _bossHud.BossMaxHealth = this.Health; + _bossHud.BossHealth = this._currentHealth; + _bossHud.SpellCardName = CurrentPhase.PhaseName; + + // TODO: Do some translation for health values to match the thresholds + this.HealthChanged += (float newValue) => {_bossHud.BossHealth = newValue;}; + + if (_bossPortraitTexture is not null) + { + // var canvas = new CanvasLayer(); + // canvas.Name = "BossPhaseAnimationCanvas"; - _gameManager.CallDeferred("add_child", canvas); + // _gameManager.CallDeferred("add_child", canvas); - _animationTextureRect = new TextureRect(); - _animationTextureRect.Texture = _bossPortraitTexture; + _animationTextureRect = new TextureRect(); + _animationTextureRect.Texture = _bossPortraitTexture; - canvas.CallDeferred("add_child", _animationTextureRect); + _bossHud.CallDeferred("add_child", _animationTextureRect); - //canvas.AddChild(animationTextureRect); + //canvas.AddChild(animationTextureRect); - _animationTextureRect.Position = new Vector2(180, 10); + _animationTextureRect.Position = new Vector2(180, 10); - _animationTextureRect.Visible = false; + _animationTextureRect.Visible = false; - //var animation = _bossPhaseAnimationPrefab.Instantiate(); + //var animation = _bossPhaseAnimationPrefab.Instantiate(); // _gameManager.AddChild(animation); + } + } + + } public override void _Process(double delta) @@ -68,6 +89,7 @@ public partial class Boss : Enemy, IActivable if (_currentHealth <= CurrentPhase.Threshold && currentPhaseIndex + 1 < Phases.Count) { currentPhaseIndex++; + _bossHud.SpellCardName = CurrentPhase.PhaseName; StartPhase(CurrentPhase); } diff --git a/Scripts/Enemy.cs b/Scripts/Enemy.cs index a9471dd3..3b2e0318 100644 --- a/Scripts/Enemy.cs +++ b/Scripts/Enemy.cs @@ -51,6 +51,13 @@ public partial class Enemy : CharacterBody2D set => _navigationEnabled = value; } + #region Events + + [Signal] + public delegate void HealthChangedEventHandler(float newValue); + + #endregion + // Called when the node enters the scene tree for the first time. public override void _Ready() { @@ -220,6 +227,7 @@ public partial class Enemy : CharacterBody2D if (_isDestroyed) return; _currentHealth -= damage; + EmitSignal(nameof(HealthChanged), _currentHealth); if (!(_currentHealth <= 0)) return; _isDestroyed = true; Explode(); diff --git a/Scripts/Resources/BossPhase.cs b/Scripts/Resources/BossPhase.cs index 58bdd112..32237954 100644 --- a/Scripts/Resources/BossPhase.cs +++ b/Scripts/Resources/BossPhase.cs @@ -7,6 +7,7 @@ namespace Cirno.Scripts.Resources; [GlobalClass] public partial class BossPhase : Resource { + [Export] public string PhaseName = string.Empty; [Export] public int Threshold; [Export] public bool PlayAnimation; [Export] public Array Patterns; diff --git a/Scripts/UI/BossHud.cs b/Scripts/UI/BossHud.cs new file mode 100644 index 00000000..8418f08d --- /dev/null +++ b/Scripts/UI/BossHud.cs @@ -0,0 +1,54 @@ +using Godot; + +namespace Cirno.Scripts.UI; + +public partial class BossHud : CanvasLayer +{ + [Export] public Label BossNameLabel { get; set; } + [Export] public Label SpellCardNameLabel { get; set; } + [Export] public Label SpellCardsCountLabel { get; set; } + [Export] public Label SpellCardTimerLabel { get; set; } + [Export] public ProgressBar BossHealthBar { get; set; } + + public string BossName + { + get => BossNameLabel.Text; + set => BossNameLabel.Text = value; + } + + public string SpellCardName + { + get => SpellCardNameLabel.Text; + set => SpellCardNameLabel.Text = value; + } + + public string SpellCardsCount + { + get => SpellCardsCountLabel.Text; + set => SpellCardsCountLabel.Text = value; + } + + public string SpellCardTimer + { + get => SpellCardTimerLabel.Text; + set => SpellCardTimerLabel.Text = value; + } + + public double BossHealth + { + get => BossHealthBar.Value; + set => BossHealthBar.Value = value; + } + + public double BossMaxHealth + { + get => BossHealthBar.MaxValue; + set => BossHealthBar.MaxValue = value; + } + + public void Init() + { + + } + +} \ No newline at end of file