diff --git a/DungeonShooting_Godot/prefab/role/Player.tscn b/DungeonShooting_Godot/prefab/role/Player.tscn index eb6fbe7..ececbbf 100644 --- a/DungeonShooting_Godot/prefab/role/Player.tscn +++ b/DungeonShooting_Godot/prefab/role/Player.tscn @@ -12,7 +12,10 @@ script = ExtResource( 2 ) GunPrefab = ExtResource( 4 ) -[node name="ColorRect" type="ColorRect" parent="." index="6"] +[node name="AnimatedSprite" parent="." index="0"] +frame = 1 + +[node name="TipBar" type="ColorRect" parent="." index="6"] visible = false margin_left = -9.0 margin_top = -24.0 @@ -20,7 +23,7 @@ margin_bottom = -18.0 color = Color( 0.784314, 0.784314, 0.784314, 0.588235 ) -[node name="ShellCase" type="TextureRect" parent="ColorRect" index="0"] +[node name="ShellCase" type="TextureRect" parent="TipBar" index="0"] margin_left = 1.0 margin_top = 5.0 margin_right = 5.0 @@ -28,7 +31,7 @@ rect_rotation = -90.0 texture = ExtResource( 5 ) -[node name="Label" type="Label" parent="ColorRect" index="1"] +[node name="Label" type="Label" parent="TipBar" index="1"] margin_left = 1.0 margin_top = -2.0 margin_right = 21.0 @@ -37,7 +40,7 @@ custom_fonts/font = ExtResource( 6 ) text = "M1911" -[node name="E" type="TextureRect" parent="ColorRect" index="2"] +[node name="E" type="TextureRect" parent="TipBar" index="2"] margin_left = 5.0 margin_top = -12.0 margin_right = 14.0 diff --git a/DungeonShooting_Godot/src/role/Player.cs b/DungeonShooting_Godot/src/role/Player.cs index 1d60a92..aa1481e 100644 --- a/DungeonShooting_Godot/src/role/Player.cs +++ b/DungeonShooting_Godot/src/role/Player.cs @@ -16,6 +16,8 @@ /// public Vector2 Velocity = Vector2.Zero; + public Control TipBar; + /// /// 当前护盾值 /// @@ -53,6 +55,8 @@ { base._EnterTree(); RoomManager.Current.Player = this; + + TipBar = GetNode("TipBar"); } public override void _Ready() @@ -139,12 +143,14 @@ if (InteractiveItem == null) { GD.Print("没有可互动的道具了"); + TipBar.Visible = false; } else { if (InteractiveItem is Gun gun) { GD.Print("更新可互动的道具: " + gun.Attribute.Name); + TipBar.Visible = true; } } }