diff --git a/DungeonShooting_Godot/src/game/activity/role/Role.cs b/DungeonShooting_Godot/src/game/activity/role/Role.cs index 7ca7b05..b7a454b 100644 --- a/DungeonShooting_Godot/src/game/activity/role/Role.cs +++ b/DungeonShooting_Godot/src/game/activity/role/Role.cs @@ -1145,6 +1145,17 @@ } /// + /// 切换到指定索引到武器 + /// + public void ExchangeWeaponByIndex(int index) + { + if (WeaponPack.ActiveIndex != index) + { + WeaponPack.ExchangeByIndex(index); + } + } + + /// /// 扔掉当前使用的武器, 切换到上一个武器 /// public void ThrowWeapon() diff --git a/DungeonShooting_Godot/src/game/camera/GameCamera.cs b/DungeonShooting_Godot/src/game/camera/GameCamera.cs index 9ae3e69..afb01f0 100644 --- a/DungeonShooting_Godot/src/game/camera/GameCamera.cs +++ b/DungeonShooting_Godot/src/game/camera/GameCamera.cs @@ -87,7 +87,7 @@ _Shake(newDelta); var world = World.Current; - if (world != null && !world.Pause && _followTarget != null) + if (world != null && _followTarget != null) { var mousePosition = InputManager.CursorPosition; var targetPosition = _followTarget.GlobalPosition; diff --git a/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponRoulettePanel.cs b/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponRoulettePanel.cs index 165e43b..c2edf03 100644 --- a/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponRoulettePanel.cs +++ b/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponRoulettePanel.cs @@ -13,12 +13,18 @@ /// public const int SlotCount = 6; + /// + /// 选中的武器 + /// + public Weapon ActiveWeapon; + //是否展开轮盘 private bool _pressRouletteFlag = false; private bool _isMagnifyRoulette = false; //所有武器插槽 private List _slotNodes = new List(); + public override void OnCreateUi() { S_RouletteBg.Instance.Visible = false; @@ -63,16 +69,20 @@ ExpandRoulette(); } } - else if (!InputManager.Roulette && _isMagnifyRoulette) //缩小轮盘 + else if (!InputManager.Roulette && _isMagnifyRoulette) //关闭轮盘 { ShrinkRoulette(); } - + //已经打开地图 if (InputManager.Roulette) { S_MouseArea.Instance.GlobalPosition = GetGlobalMousePosition(); } + else + { + ActiveWeapon = null; + } } private void ExpandRoulette() @@ -95,6 +105,12 @@ _isMagnifyRoulette = false; World.Current.Pause = false; SetEnableSectorCollision(false); + + //如果选中了物体 + if (ActiveWeapon != null) + { + Player.Current.ExchangeWeaponByIndex(ActiveWeapon.PackageIndex); + } } //设置是否启用扇形碰撞检测 @@ -135,15 +151,18 @@ slotNode.L_Control.L_WeaponIcon.Instance.Texture = weapon.GetDefaultTexture(); slotNode.L_Control.L_AmmoLabel.Instance.Text = (weapon.CurrAmmo + weapon.ResidueAmmo).ToString() + "/" + weapon.Attribute.MaxAmmoCapacity; + slotNode.Instance.SetWeapon(weapon); } else { slotNode.L_Control.Instance.Visible = false; + slotNode.Instance.ClearWeapon(); } } else { slotNode.L_Control.Instance.Visible = false; + slotNode.Instance.ClearWeapon(); } } } diff --git a/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponSlot.cs b/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponSlot.cs index 37922c1..1d2341d 100644 --- a/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponSlot.cs +++ b/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponSlot.cs @@ -5,6 +5,8 @@ public partial class WeaponSlot : Node2D, IUiNodeScript { private WeaponRoulette.WeaponSlotNode _node; + private Weapon _weapon; + public void SetUiNode(IUiNode uiNode) { _node = (WeaponRoulette.WeaponSlotNode)uiNode; @@ -15,9 +17,20 @@ public void OnDestroy() { } + + public void SetWeapon(Weapon weapon) + { + _weapon = weapon; + } + + public void ClearWeapon() + { + _weapon = null; + } private void OnAreaEntered(Area2D other) { + _node.UiPanel.ActiveWeapon = _weapon; _node.Instance.Scale = new Vector2(1.1f, 1.1f); _node.L_Control.L_WeaponIcon.Instance.Material.SetShaderMaterialParameter(ShaderParamNames.OutlineColor, Colors.White); }