diff --git a/DungeonShooting_Godot/src/game/item/weapon/bullet/Bullet.cs b/DungeonShooting_Godot/src/game/item/weapon/bullet/Bullet.cs index deb943b..4c43084 100644 --- a/DungeonShooting_Godot/src/game/item/weapon/bullet/Bullet.cs +++ b/DungeonShooting_Godot/src/game/item/weapon/bullet/Bullet.cs @@ -19,7 +19,7 @@ private float MaxDistance; // 子弹飞行速度 - private float FlySpeed = 1500; + private float FlySpeed = 600; //当前子弹已经飞行的距离 private float CurrFlyDistance = 0; diff --git a/DungeonShooting_Godot/src/game/role/Enemy.cs b/DungeonShooting_Godot/src/game/role/Enemy.cs index 51b25cf..922e7f6 100644 --- a/DungeonShooting_Godot/src/game/role/Enemy.cs +++ b/DungeonShooting_Godot/src/game/role/Enemy.cs @@ -6,4 +6,14 @@ AttackLayer = PhysicsLayer.Wall | PhysicsLayer.Props | PhysicsLayer.Player; Camp = CampEnum.Camp2; } + + public override void _Process(float delta) + { + base._Process(delta); + + if (Holster.ActiveWeapon != null) + { + Holster.ActiveWeapon.Trigger(); + } + } } diff --git a/DungeonShooting_Godot/src/game/role/Player.cs b/DungeonShooting_Godot/src/game/role/Player.cs index 6a24f6e..d1dadc4 100644 --- a/DungeonShooting_Godot/src/game/role/Player.cs +++ b/DungeonShooting_Godot/src/game/role/Player.cs @@ -79,19 +79,22 @@ { base._Process(delta); - Vector2 mousePos = InputManager.GetMousePosition(); //脸的朝向 var gPos = GlobalPosition; - if (mousePos.x > gPos.x && Face == FaceDirection.Left) + if (LookTarget == null) { - Face = FaceDirection.Right; + Vector2 mousePos = InputManager.GetMousePosition(); + if (mousePos.x > gPos.x && Face == FaceDirection.Left) + { + Face = FaceDirection.Right; + } + else if (mousePos.x < gPos.x && Face == FaceDirection.Right) + { + Face = FaceDirection.Left; + } + //枪口跟随鼠标 + MountPoint.SetLookAt(mousePos); } - else if (mousePos.x < gPos.x && Face == FaceDirection.Right) - { - Face = FaceDirection.Left; - } - //枪口跟随鼠标 - MountPoint.SetLookAt(mousePos); if (Input.IsActionJustPressed("exchange")) //切换武器 { diff --git a/DungeonShooting_Godot/src/game/role/Role.cs b/DungeonShooting_Godot/src/game/role/Role.cs index 92c3133..1cdbe2b 100644 --- a/DungeonShooting_Godot/src/game/role/Role.cs +++ b/DungeonShooting_Godot/src/game/role/Role.cs @@ -95,6 +95,11 @@ } } private int _maxHp = 0; + + /// + /// 当前角色所看向的对象, 也就是枪口指向的对象 + /// + public ActivityObject LookTarget { get; set; } //初始缩放 private Vector2 StartScele; @@ -174,6 +179,25 @@ public override void _Process(float delta) { base._Process(delta); + + //看向目标 + if (LookTarget != null) + { + Vector2 pos = LookTarget.GlobalPosition; + //脸的朝向 + var gPos = GlobalPosition; + if (pos.x > gPos.x && Face == FaceDirection.Left) + { + Face = FaceDirection.Right; + } + else if (pos.x < gPos.x && Face == FaceDirection.Right) + { + Face = FaceDirection.Left; + } + //枪口跟随目标 + MountPoint.SetLookAt(pos); + } + //检查可互动的道具 bool findFlag = false; for (int i = 0; i < InteractiveItemList.Count; i++) diff --git a/DungeonShooting_Godot/src/game/room/RoomManager.cs b/DungeonShooting_Godot/src/game/room/RoomManager.cs index 04e874d..e7769d2 100644 --- a/DungeonShooting_Godot/src/game/room/RoomManager.cs +++ b/DungeonShooting_Godot/src/game/room/RoomManager.cs @@ -39,9 +39,9 @@ { //播放bgm SoundManager.PlayeMusic("intro.ogg", this, -17f); - + _enemy.LookTarget = Player; _enemy.PickUpWeapon(WeaponManager.GetGun("1001")); - + WeaponManager.GetGun("1001").PutDown(new Vector2(80, 100)); WeaponManager.GetGun("1001").PutDown(new Vector2(80, 80)); WeaponManager.GetGun("1002").PutDown(new Vector2(80, 120));