diff --git a/DungeonShooting_Godot/prefab/item/Item0004.tscn b/DungeonShooting_Godot/prefab/item/Item0004.tscn index 6c17f45..caf9619 100644 --- a/DungeonShooting_Godot/prefab/item/Item0004.tscn +++ b/DungeonShooting_Godot/prefab/item/Item0004.tscn @@ -68,5 +68,5 @@ metadata/collsionShape2D1 = false [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] -position = Vector2(-28, -12) +position = Vector2(-29, 14) polygon = PackedVector2Array(-12, -14, 48, -14, 48, 51, 69, 51, 69, 55, -12, 55) diff --git a/DungeonShooting_Godot/scene/Hall.tscn b/DungeonShooting_Godot/scene/Hall.tscn index 263a5ac..fbd74e8 100644 --- a/DungeonShooting_Godot/scene/Hall.tscn +++ b/DungeonShooting_Godot/scene/Hall.tscn @@ -225,6 +225,7 @@ DefaultLayer = 1 ShadowZIndex = 0 VerticalMotion = false +CollisionVisible = false [node name="Sprite2D" type="Sprite2D" parent="ItemRoot/Item0004" index="1"] position = Vector2(71, -37) diff --git a/DungeonShooting_Godot/src/framework/map/AffiliationArea.cs b/DungeonShooting_Godot/src/framework/map/AffiliationArea.cs index 1b59d19..10f775d 100644 --- a/DungeonShooting_Godot/src/framework/map/AffiliationArea.cs +++ b/DungeonShooting_Godot/src/framework/map/AffiliationArea.cs @@ -88,7 +88,7 @@ if (_includeItems.Add(activityObject)) { //如果是玩家 - if (activityObject == Player.Current) + if (activityObject == RoomInfo.World.Player) { CallDeferred(nameof(OnPlayerInsertRoom)); } @@ -287,7 +287,7 @@ { if (IsFirstEnterFlag) { - Player.Current.OnFirstEnterRoom(RoomInfo); + RoomInfo.World.Player.OnFirstEnterRoom(RoomInfo); EventManager.EmitEvent(EventEnum.OnPlayerFirstEnterRoom, RoomInfo); } EventManager.EmitEvent(EventEnum.OnPlayerEnterRoom, RoomInfo); diff --git a/DungeonShooting_Godot/src/framework/map/fog/AisleFogArea.cs b/DungeonShooting_Godot/src/framework/map/fog/AisleFogArea.cs index 308968e..884da79 100644 --- a/DungeonShooting_Godot/src/framework/map/fog/AisleFogArea.cs +++ b/DungeonShooting_Godot/src/framework/map/fog/AisleFogArea.cs @@ -63,7 +63,7 @@ private void OnBodyEntered(Node2D body) { - if (body == Player.Current) + if (body == RoomDoorInfo.RoomInfo.World.Player) { //注意需要延时调用 CallDeferred(nameof(InsertPlayer)); diff --git a/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs b/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs index 0d0e3b2..740846d 100644 --- a/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs +++ b/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs @@ -20,6 +20,11 @@ RoomType = type; RoomSplit = roomSplit; } + + /// + /// 所在世界对象 + /// + public World World; /// /// 房间 id diff --git a/DungeonShooting_Godot/src/game/World.cs b/DungeonShooting_Godot/src/game/World.cs index 23d5b30..34add95 100644 --- a/DungeonShooting_Godot/src/game/World.cs +++ b/DungeonShooting_Godot/src/game/World.cs @@ -12,7 +12,12 @@ /// /// 当前的游戏世界对象 /// - public static World Current => GameApplication.Instance?.DungeonManager?.CurrWorld; + public static World Current => GameApplication.Instance.DungeonManager.CurrWorld; + + /// + /// 当前操作的玩家 + /// + public Player Player { get; private set; } /// /// //对象根节点 @@ -120,6 +125,17 @@ } /// + /// 设置当前操作的玩家对象 + /// + public void SetCurrentPlayer(Player player) + { + Player = player; + //设置相机和鼠标跟随玩家 + GameCamera.Main.SetFollowTarget(player); + GameApplication.Instance.Cursor.SetMountRole(player); + } + + /// /// 通知其他敌人发现目标了 /// /// 发送通知的角色 diff --git a/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs b/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs index abd503c..ebfb3f2 100644 --- a/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs +++ b/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs @@ -103,7 +103,7 @@ LineSprite.Scale = new Vector2(0, width * _pixelScale); //如果子弹会对玩家造成伤害, 则显示成红色 - if (Player.Current.CollisionWithMask(attackLayer)) + if (BulletData.World.Player.CollisionWithMask(attackLayer)) { LineSprite.Modulate = new Color(2.5f, 0.5f, 0.5f); } diff --git a/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs b/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs index d75c0b0..5ce3d20 100644 --- a/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs +++ b/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs @@ -120,7 +120,7 @@ MoveController.AddForce(new Vector2(data.FlySpeed, 0).Rotated(Rotation)); //如果子弹会对玩家造成伤害, 则显示红色描边 - if (Player.Current != null && Player.Current.CollisionWithMask(attackLayer)) + if (World.Player != null && World.Player.CollisionWithMask(attackLayer)) { if (!IsEnemyBullet) { diff --git a/DungeonShooting_Godot/src/game/activity/currency/Gold.cs b/DungeonShooting_Godot/src/game/activity/currency/Gold.cs index 991d072..edc0514 100644 --- a/DungeonShooting_Godot/src/game/activity/currency/Gold.cs +++ b/DungeonShooting_Godot/src/game/activity/currency/Gold.cs @@ -28,7 +28,7 @@ protected override void OnThrowOver() { - var current = Player.Current; + var current = World.Player; if (current != null) { this.CallDelay(0.3f, () => diff --git a/DungeonShooting_Godot/src/game/activity/role/Role.cs b/DungeonShooting_Godot/src/game/activity/role/Role.cs index 4fbde5a..850cba3 100644 --- a/DungeonShooting_Godot/src/game/activity/role/Role.cs +++ b/DungeonShooting_Godot/src/game/activity/role/Role.cs @@ -1013,7 +1013,7 @@ /// public bool IsPlayer() { - return this == Player.Current; + return this == World.Player; } /// @@ -1021,11 +1021,11 @@ /// public bool IsEnemyWithPlayer() { - if (Player.Current == null) + if (World.Player == null) { return false; } - return CollisionWithMask(Player.Current.EnemyLayer); + return CollisionWithMask(World.Player.EnemyLayer); } /// diff --git a/DungeonShooting_Godot/src/game/activity/role/ai/AiRole.cs b/DungeonShooting_Godot/src/game/activity/role/ai/AiRole.cs index 8a0738c..4eced81 100644 --- a/DungeonShooting_Godot/src/game/activity/role/ai/AiRole.cs +++ b/DungeonShooting_Godot/src/game/activity/role/ai/AiRole.cs @@ -100,7 +100,15 @@ //NavigationAgent2D.VelocityComputed += OnVelocityComputed; } - /// + /// + /// 获取攻击的目标对象, 该函数不能返回 null + /// + public virtual Role GetAttackTarget() + { + return World.Player; + } + + /// /// 返回地上的武器是否有可以拾取的, 也包含没有被其他敌人标记的武器 /// public bool CheckUsableWeaponInUnclaimed() diff --git a/DungeonShooting_Godot/src/game/activity/role/ai/state/AiFindAmmoState.cs b/DungeonShooting_Godot/src/game/activity/role/ai/state/AiFindAmmoState.cs index 2ebc81e..75f9e30 100644 --- a/DungeonShooting_Godot/src/game/activity/role/ai/state/AiFindAmmoState.cs +++ b/DungeonShooting_Godot/src/game/activity/role/ai/state/AiFindAmmoState.cs @@ -75,14 +75,14 @@ if (Master.LookTarget == null) //没有目标 { //临时处理 - var player = Player.Current; - var playerPos = player.GetCenterPosition(); - if (Master.IsInViewRange(playerPos) && !Master.TestViewRayCast(playerPos)) //发现玩家 + var attackTarget = Master.GetAttackTarget(); + var targetPos = attackTarget.GetCenterPosition(); + if (Master.IsInViewRange(targetPos) && !Master.TestViewRayCast(targetPos)) //发现玩家 { //关闭射线检测 Master.TestViewRayCastOver(); //发现玩家 - Master.LookTarget = player; + Master.LookTarget = attackTarget; //进入惊讶状态, 然后再进入通知状态 ChangeState(AIStateEnum.AiAstonished, AIStateEnum.AiFindAmmo, TargetWeapon); return; diff --git a/DungeonShooting_Godot/src/game/activity/role/ai/state/AiLeaveForState.cs b/DungeonShooting_Godot/src/game/activity/role/ai/state/AiLeaveForState.cs index f539df1..2352bd1 100644 --- a/DungeonShooting_Godot/src/game/activity/role/ai/state/AiLeaveForState.cs +++ b/DungeonShooting_Godot/src/game/activity/role/ai/state/AiLeaveForState.cs @@ -102,16 +102,17 @@ Master.DoIdle(); } - var playerPos = Player.Current.GetCenterPosition(); + var attackTarget = Master.GetAttackTarget(); + var targetPos = attackTarget.GetCenterPosition(); //检测玩家是否在视野内, 如果在, 则切换到 AiTargetInView 状态 - if (Master.IsInTailAfterViewRange(playerPos)) + if (Master.IsInTailAfterViewRange(targetPos)) { - if (!Master.TestViewRayCast(playerPos)) //看到玩家 + if (!Master.TestViewRayCast(targetPos)) //看到玩家 { //关闭射线检测 Master.TestViewRayCastOver(); //切换成发现目标状态 - Master.LookTarget = Player.Current; + Master.LookTarget = attackTarget; ChangeState(AIStateEnum.AiAstonished, AIStateEnum.AiFollowUp); return; } diff --git a/DungeonShooting_Godot/src/game/activity/role/ai/state/AiNormalState.cs b/DungeonShooting_Godot/src/game/activity/role/ai/state/AiNormalState.cs index 6bcb86d..c526575 100644 --- a/DungeonShooting_Godot/src/game/activity/role/ai/state/AiNormalState.cs +++ b/DungeonShooting_Godot/src/game/activity/role/ai/state/AiNormalState.cs @@ -46,17 +46,17 @@ public override void Process(float delta) { - //检测玩家 - var player = Player.Current; + //获取攻击目标 + var attackTarget = Master.GetAttackTarget(); //玩家中心点坐标 - var playerPos = player.GetCenterPosition(); + var targetPos = attackTarget.GetCenterPosition(); - if (Master.IsInViewRange(playerPos) && !Master.TestViewRayCast(playerPos)) //发现玩家 + if (Master.IsInViewRange(targetPos) && !Master.TestViewRayCast(targetPos)) //发现目标 { //关闭射线检测 Master.TestViewRayCastOver(); //发现玩家 - Master.LookTarget = player; + Master.LookTarget = attackTarget; //判断是否进入通知状态 if (Master.World.Enemy_InstanceList.FindIndex(enemy => enemy != Master && !enemy.IsDie && enemy.AffiliationArea == Master.AffiliationArea && diff --git a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs index 9834eac..342d205 100644 --- a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs +++ b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs @@ -15,11 +15,6 @@ public event Action OnFirstEnterRoomEvent; /// - /// 获取当前操作的角色 - /// - public static Player Current { get; private set; } - - /// /// 玩家身上的状态机控制器 /// public StateController StateController { get; private set; } @@ -36,17 +31,6 @@ private BrushImageData _brushData2; - /// - /// 设置当前操作的玩家对象 - /// - public static void SetCurrentPlayer(Player player) - { - Current = player; - //设置相机和鼠标跟随玩家 - GameCamera.Main.SetFollowTarget(player); - GameApplication.Instance.Cursor.SetMountRole(player); - } - public override void OnInit() { base.OnInit(); diff --git a/DungeonShooting_Godot/src/game/activity/weapon/gun/Gun.cs b/DungeonShooting_Godot/src/game/activity/weapon/gun/Gun.cs index a5fb906..4efb5d2 100644 --- a/DungeonShooting_Godot/src/game/activity/weapon/gun/Gun.cs +++ b/DungeonShooting_Godot/src/game/activity/weapon/gun/Gun.cs @@ -8,7 +8,7 @@ { protected override void OnFire() { - if (Master == Player.Current) + if (Master == World.Player) { //创建抖动 GameCamera.Main.DirectionalShake(Vector2.Right.Rotated(GlobalRotation) * Attribute.CameraShake); diff --git a/DungeonShooting_Godot/src/game/activity/weapon/knife/Knife.cs b/DungeonShooting_Godot/src/game/activity/weapon/knife/Knife.cs index 63ada44..11c2d30 100644 --- a/DungeonShooting_Godot/src/game/activity/weapon/knife/Knife.cs +++ b/DungeonShooting_Godot/src/game/activity/weapon/knife/Knife.cs @@ -94,7 +94,7 @@ } - if (Master == Player.Current) + if (Master == World.Player) { var r = Master.MountPoint.RotationDegrees; //创建屏幕抖动 diff --git a/DungeonShooting_Godot/src/game/data/BulletData.cs b/DungeonShooting_Godot/src/game/data/BulletData.cs index a53fc26..db40f73 100644 --- a/DungeonShooting_Godot/src/game/data/BulletData.cs +++ b/DungeonShooting_Godot/src/game/data/BulletData.cs @@ -8,6 +8,11 @@ public class BulletData : IClone { /// + /// 数据所在世界对象 + /// + public World World; + + /// /// 发射该子弹的武器, 可能为null /// public Weapon Weapon; @@ -77,9 +82,14 @@ /// public float Rotation; + public BulletData(World world) + { + World = world; + } + public BulletData Clone() { - return new BulletData + return new BulletData(World) { Weapon = Weapon, BulletBase = BulletBase, diff --git a/DungeonShooting_Godot/src/game/manager/FireManager.cs b/DungeonShooting_Godot/src/game/manager/FireManager.cs index 375765e..c7b436b 100644 --- a/DungeonShooting_Godot/src/game/manager/FireManager.cs +++ b/DungeonShooting_Godot/src/game/manager/FireManager.cs @@ -172,7 +172,7 @@ private static BulletData CreateSolidBulletData(Weapon weapon, float fireRotation, ExcelConfig.BulletBase bullet) { - var data = new BulletData() + var data = new BulletData(weapon.World) { Weapon = weapon, BulletBase = bullet, @@ -216,7 +216,7 @@ private static BulletData CreateSolidBulletData(Role role, float fireRotation, ExcelConfig.BulletBase bullet) { - var data = new BulletData() + var data = new BulletData(role.World) { Weapon = null, BulletBase = bullet, @@ -261,7 +261,7 @@ private static BulletData CreateLaserData(Weapon weapon, float fireRotation, ExcelConfig.BulletBase bullet) { - var data = new BulletData() + var data = new BulletData(weapon.World) { Weapon = weapon, BulletBase = bullet, diff --git a/DungeonShooting_Godot/src/game/room/DungeonManager.cs b/DungeonShooting_Godot/src/game/room/DungeonManager.cs index cc681d4..ab52b27 100644 --- a/DungeonShooting_Godot/src/game/room/DungeonManager.cs +++ b/DungeonShooting_Godot/src/game/room/DungeonManager.cs @@ -16,12 +16,12 @@ /// /// 当前玩家所在的房间 /// - public RoomInfo ActiveRoomInfo => Player.Current?.AffiliationArea?.RoomInfo; + public RoomInfo ActiveRoomInfo => CurrWorld.Player?.AffiliationArea?.RoomInfo; /// /// 当前玩家所在的区域 /// - public AffiliationArea ActiveAffiliationArea => Player.Current?.AffiliationArea; + public AffiliationArea ActiveAffiliationArea => CurrWorld.Player?.AffiliationArea; /// /// 是否在地牢里 @@ -277,6 +277,7 @@ //创建房间数据 var roomInfo = new RoomInfo(0, DungeonRoomType.None, null); + roomInfo.World = CurrWorld; roomInfo.Size = hall.BgSprite.Texture.GetSize().AsVector2I() / GameConfig.TileCellSize + new Vector2I(10, 10); roomInfo.Position = hall.BgSprite.Position.AsVector2I() - new Vector2I(5, 5) * GameConfig.TileCellSize; hall.RoomInfo = roomInfo; @@ -316,7 +317,7 @@ yield return 0; //创建玩家 - var player = Player.Current; + var player = CurrWorld.Player; if (player == null) { player = ActivityObject.Create(ActivityObject.Ids.Id_role0001); @@ -325,7 +326,7 @@ player.World = CurrWorld; player.Position = hall.BirthMark.Position; player.PutDown(RoomLayerEnum.YSortLayer); - Player.SetCurrentPlayer(player); + CurrWorld.SetCurrentPlayer(player); affiliation.InsertItem(player); player.WeaponPack.PickupItem(ActivityObject.Create(ActivityObject.Ids.Id_weapon0001)); yield return 0; @@ -359,11 +360,11 @@ yield return 0; if (!keepPlayer) { - Player.SetCurrentPlayer(null); + CurrWorld.SetCurrentPlayer(null); } else { - var player = Player.Current; + var player = CurrWorld.Player; player.AffiliationArea?.RemoveItem(player); player.GetParent().RemoveChild(player); player.World = null; @@ -452,6 +453,11 @@ //创建世界场景 var dungeon = (Dungeon)CreateNewWorld(_dungeonGenerator.Random, ResourcePath.scene_Dungeon_tscn); dungeon.InitLayer(); + //初始化房间 World 字段 + foreach (var roomInfo in _dungeonGenerator.RoomInfos) + { + roomInfo.World = dungeon; + } yield return 0; var group = GameApplication.Instance.RoomConfig[CurrConfig.GroupName]; var tileSetSplit = GameApplication.Instance.TileSetConfig[group.TileSet]; @@ -483,7 +489,7 @@ var playerBirthMark = StartRoomInfo.RoomPreinstall.GetSpecialMark(SpecialMarkType.BirthPoint); //创建玩家 - var player = Player.Current; + var player = CurrWorld.Player; if (player == null) { player = ActivityObject.Create(ActivityObject.Ids.Id_role0001); @@ -496,7 +502,7 @@ player.World = CurrWorld; player.PutDown(RoomLayerEnum.YSortLayer); - Player.SetCurrentPlayer(player); + CurrWorld.SetCurrentPlayer(player); StartRoomInfo.AffiliationArea.InsertItem(player); yield return 0; player.Collision.Disabled = false; @@ -530,11 +536,11 @@ yield return 0; if (!keepPlayer) { - Player.SetCurrentPlayer(null); + CurrWorld.SetCurrentPlayer(null); } else { - var player = Player.Current; + var player = CurrWorld.Player; player.AffiliationArea?.RemoveItem(player); player.GetParent().RemoveChild(player); player.World = null; @@ -851,7 +857,7 @@ //如果关门了, 那么房间外的敌人就会丢失目标 if (room.IsSeclusion) { - var playerAffiliationArea = Player.Current.AffiliationArea; + var playerAffiliationArea = CurrWorld.Player.AffiliationArea; foreach (var enemy in CurrWorld.Enemy_InstanceList) { //不与玩家处于同一个房间 diff --git a/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs b/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs index 9da7214..5ba219f 100644 --- a/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs @@ -141,10 +141,11 @@ _needRefresh.Clear(); } - if (Player.Current != null) + var player = World.Current.Player; + if (player != null) { //更新地图中心点位置 - var playPosition = Player.Current.GetCenterPosition(); + var playPosition = player.GetCenterPosition(); if (!_isMagnifyMap) { S_Root.Instance.Position = CalcRootPosition(playPosition); @@ -155,7 +156,7 @@ S_Mark.Instance.Position = S_DrawContainer.Instance.Size / 2 + _mapOffset; } - var area = Player.Current.AffiliationArea; + var area = player.AffiliationArea; //传送 if (_pressMapFlag && _mouseHoverRoom != null && area != null && !area.RoomInfo.IsSeclusion && @@ -269,7 +270,7 @@ var shaderMaterial = (ShaderMaterial)roomInfo.PreviewSprite.Material; _originOutlineColor = shaderMaterial.GetShaderParameter("outline_color").AsColor(); //玩家所在的房间门是否打开 - var area = Player.Current.AffiliationArea; + var area = World.Current.Player.AffiliationArea; if (area != null) { var isOpen = !area.RoomInfo.IsSeclusion; @@ -411,7 +412,7 @@ _transmissionTween.TweenProperty(roomUI.S_Mask.Instance, "color", new Color(0, 0, 0), 0.3f); _transmissionTween.TweenCallback(Callable.From(() => { - Player.Current.Position = position; + World.Current.Player.Position = position; })); _transmissionTween.TweenInterval(0.2f); _transmissionTween.TweenProperty(roomUI.S_Mask.Instance, "color", new Color(0, 0, 0, 0), 0.3f); diff --git a/DungeonShooting_Godot/src/game/ui/roomUI/ActivePropBarHandler.cs b/DungeonShooting_Godot/src/game/ui/roomUI/ActivePropBarHandler.cs index 69a2654..93085d0 100644 --- a/DungeonShooting_Godot/src/game/ui/roomUI/ActivePropBarHandler.cs +++ b/DungeonShooting_Godot/src/game/ui/roomUI/ActivePropBarHandler.cs @@ -38,7 +38,7 @@ public void Process(float delta) { - var prop = Player.Current?.ActivePropsPack.ActiveItem; + var prop = World.Current.Player?.ActivePropsPack.ActiveItem; if (prop != null) { SetActivePropCount(prop.Count); diff --git a/DungeonShooting_Godot/src/game/ui/roomUI/InteractiveTipBarHandler.cs b/DungeonShooting_Godot/src/game/ui/roomUI/InteractiveTipBarHandler.cs index 205d689..6f175e9 100644 --- a/DungeonShooting_Godot/src/game/ui/roomUI/InteractiveTipBarHandler.cs +++ b/DungeonShooting_Godot/src/game/ui/roomUI/InteractiveTipBarHandler.cs @@ -63,7 +63,7 @@ else { var result = (CheckInteractiveResult)o; - var interactiveItem = Player.Current.InteractiveItem; + var interactiveItem = World.Current.Player.InteractiveItem; //if (interactiveItem is Weapon) var icon = result.GetIcon(); if (icon != null) diff --git a/DungeonShooting_Godot/src/game/ui/roomUI/LifeBarHandler.cs b/DungeonShooting_Godot/src/game/ui/roomUI/LifeBarHandler.cs index 104c005..00f0fd2 100644 --- a/DungeonShooting_Godot/src/game/ui/roomUI/LifeBarHandler.cs +++ b/DungeonShooting_Godot/src/game/ui/roomUI/LifeBarHandler.cs @@ -67,7 +67,7 @@ private void HandlerRefreshLife() { - var player = Player.Current; + var player = World.Current.Player; if (player.MaxHp % 2 != 0) { Debug.LogError("玩家血量不是偶数!"); @@ -108,7 +108,7 @@ private void HandlerRefreshGold() { - _bar.L_Gold.L_GoldText.Instance.Text = Player.Current.RoleState.Gold.ToString(); + _bar.L_Gold.L_GoldText.Instance.Text = World.Current.Player.RoleState.Gold.ToString(); } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/ui/roomUI/ReloadBarHandler.cs b/DungeonShooting_Godot/src/game/ui/roomUI/ReloadBarHandler.cs index 93620d1..6415a06 100644 --- a/DungeonShooting_Godot/src/game/ui/roomUI/ReloadBarHandler.cs +++ b/DungeonShooting_Godot/src/game/ui/roomUI/ReloadBarHandler.cs @@ -55,8 +55,8 @@ /// public void OnCameraPositionUpdate(float delta) { - var player = Player.Current; - var activeItem = player.WeaponPack.ActiveItem; + var player = World.Current.Player; + var activeItem = player?.WeaponPack.ActiveItem; if (activeItem != null && activeItem.Reloading && activeItem.Attribute.ShowReloadBar) { ShowBar(player.GlobalPosition, activeItem.ReloadProgress); diff --git a/DungeonShooting_Godot/src/game/ui/roomUI/WeaponBarHandler.cs b/DungeonShooting_Godot/src/game/ui/roomUI/WeaponBarHandler.cs index 0c8a67e..fb93975 100644 --- a/DungeonShooting_Godot/src/game/ui/roomUI/WeaponBarHandler.cs +++ b/DungeonShooting_Godot/src/game/ui/roomUI/WeaponBarHandler.cs @@ -25,7 +25,7 @@ public void Process(float delta) { - var weapon = Player.Current?.WeaponPack.ActiveItem; + var weapon = World.Current.Player?.WeaponPack.ActiveItem; if (weapon != null) { SetWeaponTexture(weapon.GetCurrentTexture()); diff --git a/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponRoulettePanel.cs b/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponRoulettePanel.cs index 1b03c06..65e9fc2 100644 --- a/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponRoulettePanel.cs +++ b/DungeonShooting_Godot/src/game/ui/weaponRoulette/WeaponRoulettePanel.cs @@ -159,7 +159,7 @@ //如果选中了物体 if (ActiveWeapon != null) { - Player.Current.ExchangeWeaponByIndex(ActiveWeapon.PackageIndex); + World.Current.Player.ExchangeWeaponByIndex(ActiveWeapon.PackageIndex); } } @@ -182,7 +182,7 @@ //刷新页码 private void RefreshSlotPage() { - var current = Player.Current; + var current = World.Current.Player; if (current == null) { return; @@ -211,7 +211,7 @@ //更新显示的武器 private void RefreshWeapon() { - var current = Player.Current; + var current = World.Current.Player; if (current == null) //没有玩家对象,这是异常情况 { foreach (var slotNode in _slotNodes)