diff --git a/DungeonShooting_Godot/prefab/ui/WeaponRoulette.tscn b/DungeonShooting_Godot/prefab/ui/WeaponRoulette.tscn index 8850c5a..77d62b4 100644 --- a/DungeonShooting_Godot/prefab/ui/WeaponRoulette.tscn +++ b/DungeonShooting_Godot/prefab/ui/WeaponRoulette.tscn @@ -21,6 +21,7 @@ grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_1uvbk") +metadata/_edit_vertical_guides_ = [960.0] [node name="Bg" type="ColorRect" parent="."] layout_mode = 1 @@ -46,7 +47,6 @@ grow_vertical = 2 [node name="RouletteBg" type="Sprite2D" parent="Control"] -position = Vector2(32.5, -27) scale = Vector2(4, 4) texture = ExtResource("2_k6gjh") @@ -88,6 +88,56 @@ [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Control/RouletteBg/WeaponSlotNode/SlotAreaNode"] +[node name="ColorRect" type="ColorRect" parent="Control"] +layout_mode = 0 +offset_left = -383.0 +offset_top = -480.0 +offset_right = 385.0 +offset_bottom = -424.0 +color = Color(0.184314, 0.184314, 0.184314, 0.784314) + +[node name="Label" type="Label" parent="Control/ColorRect"] +layout_mode = 1 +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_left = 10.5 +offset_top = -20.0 +offset_right = 162.5 +offset_bottom = 20.0 +grow_vertical = 2 +text = "按Q上一页" + +[node name="Label2" type="Label" parent="Control/ColorRect"] +layout_mode = 1 +anchors_preset = 6 +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = -162.5 +offset_top = -20.0 +offset_right = -10.5 +offset_bottom = 20.0 +grow_horizontal = 0 +grow_vertical = 2 +text = "按E下一页" + +[node name="PageLabel" type="Label" parent="Control/ColorRect"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -4.5 +offset_top = -20.0 +offset_right = 4.5 +offset_bottom = 20.0 +grow_horizontal = 2 +grow_vertical = 2 +text = "1/1" + [node name="MouseArea" type="Area2D" parent="."] collision_layer = 8192 collision_mask = 0 diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start/Preinstall.json b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start/Preinstall.json index df10eda..30bf56e 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start/Preinstall.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start/Preinstall.json @@ -1 +1 @@ -[{"Name":"Preinstall1","Weight":100,"Remark":"","AutoFill":false,"WaveList":[[{"Position":{"X":39,"Y":8},"Size":{"X":0,"Y":0},"SpecialMarkType":1,"DelayTime":0,"MarkList":[]},{"Position":{"X":-16,"Y":-18},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0001","Weight":100,"Attr":{"CurrAmmon":"30","ResidueAmmo":"210"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":66,"Y":6},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0009","Weight":100,"Attr":{"CurrAmmon":"1","ResidueAmmo":"25"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":66,"Y":47},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0010","Weight":100,"Attr":{"CurrAmmon":"10","ResidueAmmo":"120"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":47,"Y":-32},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0008","Weight":100,"Attr":{"CurrAmmon":"10","ResidueAmmo":"120"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":23,"Y":37},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0010","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":2,"Y":18},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0005","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":24,"Y":-30},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0006","Weight":100,"Attr":{"CurrAmmon":"20","ResidueAmmo":"300"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":40,"Y":-10},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0003","Weight":100,"Attr":{"CurrAmmon":"12","ResidueAmmo":"90"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":2,"Y":-37},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0007","Weight":100,"Attr":{"CurrAmmon":"60","ResidueAmmo":"300"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-2,"Y":47},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0002","Weight":100,"Attr":{"CurrAmmon":"7","ResidueAmmo":"70"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":29,"Y":63},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0013","Weight":100,"Attr":{"CurrAmmon":"50","ResidueAmmo":"250"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-30,"Y":39},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0003","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-19,"Y":71},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0003","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":48,"Y":29},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0004","Weight":100,"Attr":{"CurrAmmon":"180","ResidueAmmo":"90"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":20,"Y":94},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0014","Weight":100,"Attr":{"CurrAmmon":"5","ResidueAmmo":"60"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-14,"Y":97},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0011","Weight":100,"Attr":{"CurrAmmon":"20","ResidueAmmo":"300"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":9,"Y":-7},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0011","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-41,"Y":61},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0016","Weight":100,"Attr":{"CurrAmmon":"5","ResidueAmmo":"60"},"Altitude":8,"VerticalSpeed":0}]}]]}] \ No newline at end of file +[{"Name":"Preinstall1","Weight":100,"Remark":"","AutoFill":false,"WaveList":[[{"Position":{"X":39,"Y":8},"Size":{"X":0,"Y":0},"SpecialMarkType":1,"DelayTime":0,"MarkList":[]},{"Position":{"X":-16,"Y":-18},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0001","Weight":100,"Attr":{"CurrAmmon":"30","ResidueAmmo":"210"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":66,"Y":6},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0009","Weight":100,"Attr":{"CurrAmmon":"1","ResidueAmmo":"25"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":66,"Y":47},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0010","Weight":100,"Attr":{"CurrAmmon":"10","ResidueAmmo":"120"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":47,"Y":-32},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0008","Weight":100,"Attr":{"CurrAmmon":"10","ResidueAmmo":"120"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":23,"Y":37},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0010","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":2,"Y":18},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0005","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":24,"Y":-30},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0006","Weight":100,"Attr":{"CurrAmmon":"20","ResidueAmmo":"300"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":40,"Y":-10},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0003","Weight":100,"Attr":{"CurrAmmon":"12","ResidueAmmo":"90"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":2,"Y":-37},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0007","Weight":100,"Attr":{"CurrAmmon":"60","ResidueAmmo":"300"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-2,"Y":47},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0002","Weight":100,"Attr":{"CurrAmmon":"7","ResidueAmmo":"70"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":29,"Y":63},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0013","Weight":100,"Attr":{"CurrAmmon":"50","ResidueAmmo":"250"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-30,"Y":39},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0003","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-19,"Y":71},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0003","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":48,"Y":29},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0004","Weight":100,"Attr":{"CurrAmmon":"180","ResidueAmmo":"90"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":20,"Y":94},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0014","Weight":100,"Attr":{"CurrAmmon":"5","ResidueAmmo":"60"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-14,"Y":97},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0011","Weight":100,"Attr":{"CurrAmmon":"20","ResidueAmmo":"300"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":9,"Y":-7},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0011","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-41,"Y":61},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0016","Weight":100,"Attr":{"CurrAmmon":"5","ResidueAmmo":"60"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":73,"Y":-19},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0005","Weight":100,"Attr":{"CurrAmmon":"10","ResidueAmmo":"40"},"Altitude":8,"VerticalSpeed":5.551115E-14}]}]]}] \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs index 0fb400d..5f82093 100644 --- a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs +++ b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs @@ -73,6 +73,8 @@ //InitSubLine(); _brushData2 = new BrushImageData(ExcelConfig.LiquidMaterial_Map["0001"]); + + WeaponPack.SetCapacity(20); } private void DebugSet() diff --git a/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs b/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs index 3009e94..9da7214 100644 --- a/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs @@ -62,7 +62,7 @@ //按下地图按键 if (InputManager.Map && !_isMagnifyMap && !_pressMapFlag) //展开小地图 { - if (UiManager.GetUiInstanceCount(UiManager.UiNames.PauseMenu) == 0) + if (UiManager.GetUiInstanceCount(UiManager.UiNames.PauseMenu) == 0 && !InputManager.Roulette) { ExpandMap(); } diff --git a/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponRoulette.cs b/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponRoulette.cs index a078918..55700e6 100644 --- a/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponRoulette.cs +++ b/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponRoulette.cs @@ -206,6 +206,81 @@ } /// + /// 类型: , 路径: WeaponRoulette.Control.ColorRect.Label + /// + public class Label : UiNode + { + public Label(WeaponRoulettePanel uiPanel, Godot.Label node) : base(uiPanel, node) { } + public override Label Clone() => new (UiPanel, (Godot.Label)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: WeaponRoulette.Control.ColorRect.Label2 + /// + public class Label2 : UiNode + { + public Label2(WeaponRoulettePanel uiPanel, Godot.Label node) : base(uiPanel, node) { } + public override Label2 Clone() => new (UiPanel, (Godot.Label)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: WeaponRoulette.Control.ColorRect.PageLabel + /// + public class PageLabel : UiNode + { + public PageLabel(WeaponRoulettePanel uiPanel, Godot.Label node) : base(uiPanel, node) { } + public override PageLabel Clone() => new (UiPanel, (Godot.Label)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: WeaponRoulette.Control.ColorRect + /// + public class ColorRect : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: WeaponRoulette.Control.Label + /// + public Label L_Label + { + get + { + if (_L_Label == null) _L_Label = new Label(UiPanel, Instance.GetNode("Label")); + return _L_Label; + } + } + private Label _L_Label; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: WeaponRoulette.Control.Label2 + /// + public Label2 L_Label2 + { + get + { + if (_L_Label2 == null) _L_Label2 = new Label2(UiPanel, Instance.GetNode("Label2")); + return _L_Label2; + } + } + private Label2 _L_Label2; + + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: WeaponRoulette.Control.PageLabel + /// + public PageLabel L_PageLabel + { + get + { + if (_L_PageLabel == null) _L_PageLabel = new PageLabel(UiPanel, Instance.GetNode("PageLabel")); + return _L_PageLabel; + } + } + private PageLabel _L_PageLabel; + + public ColorRect(WeaponRoulettePanel uiPanel, Godot.ColorRect node) : base(uiPanel, node) { } + public override ColorRect Clone() => new (UiPanel, (Godot.ColorRect)Instance.Duplicate()); + } + + /// /// 类型: , 路径: WeaponRoulette.Control /// public class Control : UiNode @@ -223,6 +298,19 @@ } private RouletteBg _L_RouletteBg; + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: WeaponRoulette.ColorRect + /// + public ColorRect L_ColorRect + { + get + { + if (_L_ColorRect == null) _L_ColorRect = new ColorRect(UiPanel, Instance.GetNode("ColorRect")); + return _L_ColorRect; + } + } + private ColorRect _L_ColorRect; + public Control(WeaponRoulettePanel uiPanel, Godot.Control node) : base(uiPanel, node) { } public override Control Clone() => new (UiPanel, (Godot.Control)Instance.Duplicate()); } @@ -295,6 +383,26 @@ public RouletteBg S_RouletteBg => L_Control.L_RouletteBg; /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: WeaponRoulette.Control.ColorRect.Label + /// + public Label S_Label => L_Control.L_ColorRect.L_Label; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: WeaponRoulette.Control.ColorRect.Label2 + /// + public Label2 S_Label2 => L_Control.L_ColorRect.L_Label2; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: WeaponRoulette.Control.ColorRect.PageLabel + /// + public PageLabel S_PageLabel => L_Control.L_ColorRect.L_PageLabel; + + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: WeaponRoulette.Control.ColorRect + /// + public ColorRect S_ColorRect => L_Control.L_ColorRect; + + /// /// 场景中唯一名称的节点, 节点类型: , 节点路径: WeaponRoulette.MouseArea.CollisionShape2D /// public CollisionShape2D S_CollisionShape2D => L_MouseArea.L_CollisionShape2D; diff --git a/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponRoulettePanel.cs b/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponRoulettePanel.cs index c2edf03..4fdbdaa 100644 --- a/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponRoulettePanel.cs +++ b/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponRoulettePanel.cs @@ -24,10 +24,14 @@ //所有武器插槽 private List _slotNodes = new List(); - + //当前页索引 + private int _pageIndex = 0; + //最大页数 + private int _maxPageIndex = 0; + public override void OnCreateUi() { - S_RouletteBg.Instance.Visible = false; + L_Control.Instance.Visible = false; S_Bg.Instance.Visible = false; //创建武器插槽 @@ -64,7 +68,7 @@ //按下地图按键 if (InputManager.Roulette && !_isMagnifyRoulette) //打开轮盘 { - if (UiManager.GetUiInstanceCount(UiManager.UiNames.PauseMenu) == 0) + if (UiManager.GetUiInstanceCount(UiManager.UiNames.PauseMenu) == 0 && !InputManager.Map) { ExpandRoulette(); } @@ -78,6 +82,32 @@ if (InputManager.Roulette) { S_MouseArea.Instance.GlobalPosition = GetGlobalMousePosition(); + + if (_maxPageIndex > 0) + { + if (InputManager.ExchangeWeapon) //上一页 + { + _pageIndex--; + if (_pageIndex < 0) + { + _pageIndex = _maxPageIndex; + } + + RefreshPageLabel(); + RefreshWeapon(); + } + else if (InputManager.Interactive) //下一页 + { + _pageIndex++; + if (_pageIndex > _maxPageIndex) + { + _pageIndex = 0; + } + + RefreshPageLabel(); + RefreshWeapon(); + } + } } else { @@ -85,21 +115,25 @@ } } + //打开轮盘 private void ExpandRoulette() { World.Current.Pause = true; _pressRouletteFlag = true; _isMagnifyRoulette = true; - S_RouletteBg.Instance.Visible = true; + L_Control.Instance.Visible = true; S_Bg.Instance.Visible = true; SetEnableSectorCollision(true); + RefreshSlotPage(); + RefreshPageLabel(); RefreshWeapon(); } + //关闭轮盘 private void ShrinkRoulette() { - S_RouletteBg.Instance.Visible = false; + L_Control.Instance.Visible = false; S_Bg.Instance.Visible = false; _isMagnifyRoulette = false; @@ -122,12 +156,47 @@ weaponSlotNode.L_SlotAreaNode.Instance.Monitorable = enable; } } + + //刷新页码文本 + private void RefreshPageLabel() + { + S_PageLabel.Instance.Text = $"{_pageIndex + 1}/{_maxPageIndex + 1}"; + } + + //刷新页码 + private void RefreshSlotPage() + { + var current = Player.Current; + if (current == null) + { + return; + } + + var weapons = current.WeaponPack.ItemSlot; + //判断是否显示上一页下一页提示 + var lastIndex = 0; + for (var i = weapons.Length - 1; i >= 0; i--) + { + if (weapons[i] != null) + { + lastIndex = i; + break; + } + } + _maxPageIndex = Mathf.CeilToInt((lastIndex + 1f) / SlotCount) - 1; + S_ColorRect.Instance.Visible = _maxPageIndex > 0; + + if (_pageIndex > _maxPageIndex) + { + _pageIndex = _maxPageIndex; + } + } //更新显示的武器 private void RefreshWeapon() { var current = Player.Current; - if (current == null) + if (current == null) //没有玩家对象,这是异常情况 { foreach (var slotNode in _slotNodes) { @@ -142,9 +211,10 @@ { var slotNode = _slotNodes[i]; slotNode.L_Control.Instance.Visible = true; - if (weapons.Length > i) + var weaponIndex = i + _pageIndex * SlotCount; + if (weapons.Length > weaponIndex) { - var weapon = weapons[i]; + var weapon = weapons[weaponIndex]; if (weapon != null) { slotNode.L_Control.Instance.Visible = true;