💫 Smooth health bar
This commit is contained in:
parent
58caef0014
commit
f14a29d4e3
@ -7,7 +7,6 @@
|
||||
<list default="true" id="c7bd02c7-bbb4-431f-81ca-d2f8b7b09b37" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.CodingLand/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.CodingLand/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Scenes/Player.tscn" beforeDir="false" afterPath="$PROJECT_DIR$/Scenes/Player.tscn" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Scripts/Effects/CameraShake.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Scripts/Effects/CameraShake.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Scripts/Player.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Scripts/Player.cs" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@ -30,6 +29,7 @@
|
||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/9fd3b083f28f40c0827cc635e2e56ca7459200/2d/aa985d46/Mathf.cs" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/9fd3b083f28f40c0827cc635e2e56ca7459200/60/341003fb/Vector2.cs" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/9fd3b083f28f40c0827cc635e2e56ca7459200/b8/f49a7aff/MultiplayerApi.cs" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/9fd3b083f28f40c0827cc635e2e56ca7459200/cf/35622650/Tween.cs" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/9fd3b083f28f40c0827cc635e2e56ca7459200/dd/26a79861/Transform2D.cs" root0="SKIP_HIGHLIGHTING" />
|
||||
</component>
|
||||
<component name="MetaFilesCheckinStateConfiguration" checkMetaFiles="true" />
|
||||
@ -110,7 +110,7 @@
|
||||
<workItem from="1722846222698" duration="9239000" />
|
||||
<workItem from="1722855558149" duration="11578000" />
|
||||
<workItem from="1723040712804" duration="74000" />
|
||||
<workItem from="1723040934916" duration="7673000" />
|
||||
<workItem from="1723040934916" duration="9355000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary=":sparkles: Usable multiplayer">
|
||||
<option name="closed" value="true" />
|
||||
|
@ -18,6 +18,9 @@ properties/0/replication_mode = 1
|
||||
properties/1/path = NodePath(".:PlayerId")
|
||||
properties/1/spawn = true
|
||||
properties/1/replication_mode = 1
|
||||
properties/2/path = NodePath("RotationCentre:rotation")
|
||||
properties/2/spawn = true
|
||||
properties/2/replication_mode = 1
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_hojn2"]
|
||||
properties/0/path = NodePath("InputSynchronizer:IsDashing")
|
||||
@ -34,11 +37,11 @@ PlayerInput = NodePath("InputSynchronizer")
|
||||
BulletScene = ExtResource("2_nmop0")
|
||||
|
||||
[node name="HUD" type="VBoxContainer" parent="."]
|
||||
offset_left = -70.0
|
||||
offset_left = -90.0
|
||||
offset_top = -80.0
|
||||
offset_right = 70.0
|
||||
offset_right = 90.0
|
||||
offset_bottom = -20.0
|
||||
theme_override_constants/separation = 6
|
||||
theme_override_constants/separation = 4
|
||||
alignment = 1
|
||||
|
||||
[node name="NameTag" type="Label" parent="HUD"]
|
||||
@ -49,6 +52,7 @@ vertical_alignment = 1
|
||||
clip_text = true
|
||||
|
||||
[node name="HealthBar" type="ProgressBar" parent="HUD"]
|
||||
custom_minimum_size = Vector2(2.08165e-12, 8)
|
||||
layout_mode = 2
|
||||
rounded = true
|
||||
allow_greater = true
|
||||
@ -79,6 +83,10 @@ Noise = SubResource("FastNoiseLite_cfnx7")
|
||||
[node name="DashCountdown" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[node name="ProtectionCountdown" type="Timer" parent="."]
|
||||
wait_time = 0.05
|
||||
one_shot = true
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_bekoo")
|
||||
|
||||
|
@ -106,11 +106,19 @@ public partial class Player : CharacterBody2D
|
||||
|
||||
[Rpc(MultiplayerApi.RpcMode.AnyPeer, CallLocal = true)]
|
||||
private void GotDamage(double damage)
|
||||
{
|
||||
var protection = GetNode<Timer>("ProtectionCountdown");
|
||||
|
||||
if (protection.IsStopped())
|
||||
{
|
||||
Health -= damage;
|
||||
|
||||
var tween = CreateTween();
|
||||
var bar = GetNode<ProgressBar>("HUD/HealthBar");
|
||||
bar.Value = Health / MaxHealth * 100;
|
||||
tween.TweenProperty(bar, "value", Health / MaxHealth * 100, 0.3);
|
||||
|
||||
protection.Start();
|
||||
}
|
||||
|
||||
var shakableCamera = GetNode<CameraShake>("Camera2D");
|
||||
shakableCamera.AddTrauma(0.5f);
|
||||
|
Loading…
Reference in New Issue
Block a user