diff --git a/DungeonShooting_Godot/prefab/role/Player.tscn b/DungeonShooting_Godot/prefab/role/Player.tscn index 9089f4d..0440d22 100644 --- a/DungeonShooting_Godot/prefab/role/Player.tscn +++ b/DungeonShooting_Godot/prefab/role/Player.tscn @@ -9,5 +9,5 @@ script = ExtResource( 2 ) GunPrefab = ExtResource( 4 ) -[node name="AnimatedSprite" parent="." index="0"] +[node name="AnimatedSprite" parent="." index="1"] frame = 1 diff --git a/DungeonShooting_Godot/prefab/role/Role.tscn b/DungeonShooting_Godot/prefab/role/Role.tscn index a3c93fe..246469e 100644 --- a/DungeonShooting_Godot/prefab/role/Role.tscn +++ b/DungeonShooting_Godot/prefab/role/Role.tscn @@ -88,6 +88,7 @@ position = Vector2( 0, -12 ) frames = SubResource( 6 ) animation = "idle" +frame = 3 playing = true [node name="Collision" type="CollisionShape2D" parent="."] diff --git a/DungeonShooting_Godot/src/role/Player.cs b/DungeonShooting_Godot/src/role/Player.cs index 4ccf0e4..c57f4ea 100644 --- a/DungeonShooting_Godot/src/role/Player.cs +++ b/DungeonShooting_Godot/src/role/Player.cs @@ -101,8 +101,11 @@ } else if (Input.IsActionJustPressed("interactive")) //互动物体 { - TriggerTnteractive(); - RefreshGunTexture(); + var item = TriggerTnteractive(); + if (item is Gun) + { + RefreshGunTexture(); + } } else if (Input.IsActionJustPressed("reload")) //换弹 { diff --git a/DungeonShooting_Godot/src/role/Role.cs b/DungeonShooting_Godot/src/role/Role.cs index 9674d66..1f37b51 100644 --- a/DungeonShooting_Godot/src/role/Role.cs +++ b/DungeonShooting_Godot/src/role/Role.cs @@ -92,6 +92,9 @@ private Vector2 StartScele; //所有角色碰撞的道具 private readonly List InteractiveItemList = new List(); + + private CheckInteractiveResult TempResultData; + /// /// 可以互动的道具 /// @@ -147,13 +150,17 @@ if (result.CanInteractive) //可以互动 { findFlag = true; - if (InteractiveItem != item) + if (InteractiveItem != item) //更改互动物体 { InteractiveItem = item; - //GD.Print("--------change"); + ChangeInteractiveItem(result); + } + else if (result.ShowIcon != TempResultData.ShowIcon) //切换状态 + { ChangeInteractiveItem(result); } } + TempResultData = result; } } } @@ -161,7 +168,6 @@ if (!findFlag && InteractiveItem != null) { InteractiveItem = null; - //GD.Print("--------remove1"); ChangeInteractiveItem(null); } } @@ -218,14 +224,17 @@ } /// - /// 触发与碰撞的物体互动 + /// 触发与碰撞的物体互动, 并返回与其互动的物体 /// - public void TriggerTnteractive() + public IProp TriggerTnteractive() { if (HasTnteractive()) { - InteractiveItem.Interactive(this); + var item = InteractiveItem; + item.Interactive(this); + return item; } + return null; } /// @@ -299,7 +308,6 @@ if (!InteractiveItemList.Contains(prop)) { InteractiveItemList.Add(prop); - //GD.Print("--------add"); } } } @@ -315,7 +323,6 @@ if (InteractiveItemList.Contains(prop)) { InteractiveItemList.Remove(prop); - //GD.Print("--------remove2"); } if (InteractiveItem == prop) { diff --git a/DungeonShooting_Godot/src/ui/InteractiveTipBar.cs b/DungeonShooting_Godot/src/ui/InteractiveTipBar.cs index 287ebcb..09f1f1b 100644 --- a/DungeonShooting_Godot/src/ui/InteractiveTipBar.cs +++ b/DungeonShooting_Godot/src/ui/InteractiveTipBar.cs @@ -1,5 +1,8 @@ using Godot; +/// +/// 互动提示文本 +/// public class InteractiveTipBar : Node2D { @@ -7,6 +10,8 @@ private Sprite Icon; private Sprite Bg; + private string currImage; + public override void _Ready() { Message = GetNode