Compare commits
2 Commits
021e984877
...
257a492f72
Author | SHA1 | Date | |
---|---|---|---|
257a492f72 | |||
fd10e566b3 |
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=59 format=3 uid="uid://bqi5s710xb1ju"]
|
[gd_scene load_steps=60 format=3 uid="uid://bqi5s710xb1ju"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://csel4s0e4g5uf" path="res://scripts/components/PlayerController.cs" id="1_yysbb"]
|
[ext_resource type="Script" uid="uid://csel4s0e4g5uf" path="res://scripts/components/PlayerController.cs" id="1_yysbb"]
|
||||||
[ext_resource type="Shader" uid="uid://bs4xvm4qkurpr" path="res://shaders/hit_flash.tres" id="2_lgb3u"]
|
[ext_resource type="Shader" uid="uid://bs4xvm4qkurpr" path="res://shaders/hit_flash.tres" id="2_lgb3u"]
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
[ext_resource type="Script" uid="uid://cecelixl41t3j" path="res://scripts/components/InvulnerabilityComponent.cs" id="15_xuhvf"]
|
[ext_resource type="Script" uid="uid://cecelixl41t3j" path="res://scripts/components/InvulnerabilityComponent.cs" id="15_xuhvf"]
|
||||||
[ext_resource type="Script" uid="uid://dvyd26ricriql" path="res://scripts/components/FlashingComponent.cs" id="16_uno3u"]
|
[ext_resource type="Script" uid="uid://dvyd26ricriql" path="res://scripts/components/FlashingComponent.cs" id="16_uno3u"]
|
||||||
[ext_resource type="Script" uid="uid://dtg6115je7b5s" path="res://scripts/components/StompDamageComponent.cs" id="17_bl1gx"]
|
[ext_resource type="Script" uid="uid://dtg6115je7b5s" path="res://scripts/components/StompDamageComponent.cs" id="17_bl1gx"]
|
||||||
[ext_resource type="Script" uid="uid://di572axt0c3s8" path="res://scripts/SkillManager.cs" id="18_6lsog"]
|
[ext_resource type="Script" path="res://Autoloads/SkillManager.cs" id="18_6lsog"]
|
||||||
[ext_resource type="AudioStream" uid="uid://duj2q0rqytaxg" path="res://sfx/jump.wav" id="18_pysae"]
|
[ext_resource type="AudioStream" uid="uid://duj2q0rqytaxg" path="res://sfx/jump.wav" id="18_pysae"]
|
||||||
[ext_resource type="AudioStream" uid="uid://bmfn6p88gy575" path="res://sfx/player_hurt.wav" id="19_7anly"]
|
[ext_resource type="AudioStream" uid="uid://bmfn6p88gy575" path="res://sfx/player_hurt.wav" id="19_7anly"]
|
||||||
[ext_resource type="Script" uid="uid://d4crrfmbgxnqf" path="res://scripts/Resources/SkillData.cs" id="19_yysbb"]
|
[ext_resource type="Script" uid="uid://d4crrfmbgxnqf" path="res://scripts/Resources/SkillData.cs" id="19_yysbb"]
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
[ext_resource type="AudioStream" uid="uid://dyev46uqusimi" path="res://sfx/shoot.wav" id="32_x2b7c"]
|
[ext_resource type="AudioStream" uid="uid://dyev46uqusimi" path="res://sfx/shoot.wav" id="32_x2b7c"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dtem8jgcyoqar" path="res://objects/entities/green_laser.tscn" id="36_oxudy"]
|
[ext_resource type="PackedScene" uid="uid://dtem8jgcyoqar" path="res://objects/entities/green_laser.tscn" id="36_oxudy"]
|
||||||
[ext_resource type="Script" uid="uid://diw6opv6yutgi" path="res://scripts/components/KillPlayerOutOfScreenComponent.cs" id="37_qec3q"]
|
[ext_resource type="Script" uid="uid://diw6opv6yutgi" path="res://scripts/components/KillPlayerOutOfScreenComponent.cs" id="37_qec3q"]
|
||||||
|
[ext_resource type="Script" uid="uid://dupnaark1f7gm" path="res://scripts/components/ProgressiveDamageComponent.cs" id="38_dhjci"]
|
||||||
[ext_resource type="Script" uid="uid://dssa2taiwktis" path="res://scripts/components/Movement/PlayerInputHandler.cs" id="42_e5pae"]
|
[ext_resource type="Script" uid="uid://dssa2taiwktis" path="res://scripts/components/Movement/PlayerInputHandler.cs" id="42_e5pae"]
|
||||||
[ext_resource type="Script" uid="uid://ceoxet1nqws8w" path="res://scripts/components/SpriteTilterComponent.cs" id="43_xuhvf"]
|
[ext_resource type="Script" uid="uid://ceoxet1nqws8w" path="res://scripts/components/SpriteTilterComponent.cs" id="43_xuhvf"]
|
||||||
[ext_resource type="Script" uid="uid://b1h8r5irryxcx" path="res://scripts/components/PlayerSfxComponent.cs" id="49_qec3q"]
|
[ext_resource type="Script" uid="uid://b1h8r5irryxcx" path="res://scripts/components/PlayerSfxComponent.cs" id="49_qec3q"]
|
||||||
@@ -226,9 +227,8 @@ Root = NodePath("..")
|
|||||||
script = ExtResource("18_6lsog")
|
script = ExtResource("18_6lsog")
|
||||||
AvailableSkills = Array[ExtResource("19_yysbb")]([ExtResource("20_o1ihh"), ExtResource("21_ur2y5"), ExtResource("22_7til7"), ExtResource("23_e5pae"), ExtResource("24_xuhvf")])
|
AvailableSkills = Array[ExtResource("19_yysbb")]([ExtResource("20_o1ihh"), ExtResource("21_ur2y5"), ExtResource("22_7til7"), ExtResource("23_e5pae"), ExtResource("24_xuhvf")])
|
||||||
|
|
||||||
[node name="SkillUnlockerComponent" type="Node" parent="." node_paths=PackedStringArray("SkillManager")]
|
[node name="SkillUnlockerComponent" type="Node" parent="."]
|
||||||
script = ExtResource("25_yysbb")
|
script = ExtResource("25_yysbb")
|
||||||
SkillManager = NodePath("../SkillManager")
|
|
||||||
|
|
||||||
[node name="HitComponent" type="Node" parent="." node_paths=PackedStringArray("Sprite", "Health", "HitFx")]
|
[node name="HitComponent" type="Node" parent="." node_paths=PackedStringArray("Sprite", "Health", "HitFx")]
|
||||||
script = ExtResource("26_6n1ss")
|
script = ExtResource("26_6n1ss")
|
||||||
@@ -314,3 +314,9 @@ script = ExtResource("50_dhjci")
|
|||||||
DefaultSprite = NodePath("../Graphics/Root")
|
DefaultSprite = NodePath("../Graphics/Root")
|
||||||
SpaceshipSprite = NodePath("../Graphics/Ship")
|
SpaceshipSprite = NodePath("../Graphics/Ship")
|
||||||
metadata/_custom_type_script = "uid://b2aanqykvdnev"
|
metadata/_custom_type_script = "uid://b2aanqykvdnev"
|
||||||
|
|
||||||
|
[node name="ProgressiveDamageComponent" type="Node" parent="." node_paths=PackedStringArray("HealthComponent", "Sprite")]
|
||||||
|
script = ExtResource("38_dhjci")
|
||||||
|
HealthComponent = NodePath("../HealthComponent")
|
||||||
|
Sprite = NodePath("../Graphics/Root/Base")
|
||||||
|
metadata/_custom_type_script = "uid://dupnaark1f7gm"
|
||||||
|
39
scripts/components/ProgressiveDamageComponent.cs
Normal file
39
scripts/components/ProgressiveDamageComponent.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Mr.BrickAdventures.scripts.components;
|
||||||
|
|
||||||
|
[GlobalClass]
|
||||||
|
public partial class ProgressiveDamageComponent : Node
|
||||||
|
{
|
||||||
|
[Export] public HealthComponent HealthComponent { get; set; }
|
||||||
|
[Export] public Sprite2D Sprite { get; set; }
|
||||||
|
|
||||||
|
private float _maxHealth;
|
||||||
|
private float _ogJumpHeight;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
_maxHealth = HealthComponent.MaxHealth;
|
||||||
|
HealthComponent.HealthChanged += OnHealthChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnHealthChanged(float delta, float totalHealth)
|
||||||
|
{
|
||||||
|
var frame = GetDamageFrame();
|
||||||
|
if (frame < 0 || frame >= Sprite.GetHframes()) return;
|
||||||
|
|
||||||
|
Sprite.Frame = frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int GetDamageFrame()
|
||||||
|
{
|
||||||
|
if (Sprite == null || HealthComponent == null) return 0;
|
||||||
|
|
||||||
|
var framesCount = Sprite.GetHframes();
|
||||||
|
if (framesCount == 0) return 0;
|
||||||
|
|
||||||
|
var currentHealth = HealthComponent.Health;
|
||||||
|
var healthRatio = currentHealth / _maxHealth;
|
||||||
|
return (int)(framesCount * (1f - healthRatio));
|
||||||
|
}
|
||||||
|
}
|
1
scripts/components/ProgressiveDamageComponent.cs.uid
Normal file
1
scripts/components/ProgressiveDamageComponent.cs.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://dupnaark1f7gm
|
Reference in New Issue
Block a user