diff --git a/DungeonShooting_Art/bullet/Split/bullet1.png b/DungeonShooting_Art/bullet/Split/bullet1.png new file mode 100644 index 0000000..0144740 --- /dev/null +++ b/DungeonShooting_Art/bullet/Split/bullet1.png Binary files differ diff --git a/DungeonShooting_Art/gun/Split/gun1.png b/DungeonShooting_Art/gun/Split/gun1.png new file mode 100644 index 0000000..8e71be2 --- /dev/null +++ b/DungeonShooting_Art/gun/Split/gun1.png Binary files differ diff --git a/DungeonShooting_Art/gun/Split/knife1.png b/DungeonShooting_Art/gun/Split/knife1.png new file mode 100644 index 0000000..2c98750 --- /dev/null +++ b/DungeonShooting_Art/gun/Split/knife1.png Binary files differ diff --git a/DungeonShooting_Godot/src/effect/ThrowNode.cs b/DungeonShooting_Godot/src/effect/ThrowNode.cs index 882a718..3dcec01 100644 --- a/DungeonShooting_Godot/src/effect/ThrowNode.cs +++ b/DungeonShooting_Godot/src/effect/ThrowNode.cs @@ -1,4 +1,3 @@ -using System; using Godot; /// @@ -9,7 +8,6 @@ /// /// 是否已经结束 /// - /// public bool IsOver { get; protected set; } = true; /// /// 物体大小 @@ -22,7 +20,6 @@ /// /// 移动方向, 0 - 360 /// - /// public float Direction { get; protected set; } /// /// x速度, 也就是水平速度 @@ -31,12 +28,10 @@ /// /// y轴速度, 也就是竖直速度 /// - /// public float YSpeed { get; protected set; } /// /// 初始x轴组队 /// - /// public float StartXSpeed { get; protected set; } /// /// 初始y轴速度 @@ -53,7 +48,6 @@ /// /// 碰撞组件 /// - /// public CollisionShape2D CollisionShape { get; protected set; } /// /// 绘制阴影的精灵 @@ -64,6 +58,11 @@ private bool inversionX = false; + public ThrowNode() + { + Name = "ThrowNode"; + } + public override void _Ready() { //只与墙壁碰撞 @@ -71,6 +70,7 @@ CollisionLayer = 0; //创建碰撞器 CollisionShape = new CollisionShape2D(); + CollisionShape.Name = "Collision"; var shape = new RectangleShape2D(); shape.Extents = Size * 0.5f; CollisionShape.Shape = shape; @@ -112,6 +112,10 @@ AddChild(mount); mount.Position = new Vector2(0, -startHeight); } + if (GetParentOrNull() == null) + { + RoomManager.Current.SortRoot.AddChild(this); + } } /// @@ -136,6 +140,7 @@ { //阴影 ShadowSprite = new Sprite(); + ShadowSprite.Name = "Shadow"; ShadowSprite.ZIndex = -5; ShadowSprite.Material = ResourceManager.ShadowMaterial; AddChild(ShadowSprite); @@ -157,6 +162,24 @@ } } + public Node2D StopThrow() + { + var mount = Mount; + var parent = GetParentOrNull(); + if (parent != null && mount != null) + { + var gp = mount.GlobalPosition; + var gr = mount.GlobalRotation; + Mount = null; + RemoveChild(mount); + parent.AddChild(mount); + mount.GlobalPosition = gp; + mount.GlobalRotation = gr; + } + QueueFree(); + return mount; + } + /// /// 达到最高点时调用 /// @@ -166,11 +189,12 @@ } /// - /// 结束的调用 + /// /// 结束的调用 /// protected virtual void OnOver() { - + GetParent().RemoveChild(this); + RoomManager.Current.ObjectRoot.AddChild(this); } public override void _Process(float delta) diff --git a/DungeonShooting_Godot/src/role/Role.cs b/DungeonShooting_Godot/src/role/Role.cs index d132261..bfd21c2 100644 --- a/DungeonShooting_Godot/src/role/Role.cs +++ b/DungeonShooting_Godot/src/role/Role.cs @@ -164,7 +164,6 @@ var yf = MathUtils.RandRangeInt(60, 120); var rotate = MathUtils.RandRangeInt(-180, 180); temp.InitThrow(new Vector2(20, 20), startPos, startHeight, direction, xf, yf, rotate, gun, gun.GunSprite); - RoomManager.Current.SortRoot.AddChild(temp); } } diff --git a/DungeonShooting_Godot/src/weapon/gun/Gun.cs b/DungeonShooting_Godot/src/weapon/gun/Gun.cs index 70c6304..4267799 100644 --- a/DungeonShooting_Godot/src/weapon/gun/Gun.cs +++ b/DungeonShooting_Godot/src/weapon/gun/Gun.cs @@ -468,10 +468,11 @@ public void Tnteractive(Role master) { - var parent = GetParent(); - if (master.Holster.PickupGun(this) != -1) + var parent = GetParentOrNull(); + if (parent != null) { - parent.QueueFree(); + parent.StopThrow(); + master.Holster.PickupGun(this); } } diff --git a/DungeonShooting_Godot/src/weapon/gun/OrdinaryGun.cs b/DungeonShooting_Godot/src/weapon/gun/OrdinaryGun.cs index 31f869c..f3dc8ea 100644 --- a/DungeonShooting_Godot/src/weapon/gun/OrdinaryGun.cs +++ b/DungeonShooting_Godot/src/weapon/gun/OrdinaryGun.cs @@ -24,7 +24,6 @@ var rotate = MathUtils.RandRangeInt(-720, 720); var sprite = Attribute.ShellPack.Instance(); temp.InitThrow(new Vector2(5, 10), startPos, startHeight, direction, xf, yf, rotate, sprite, sprite); - RoomManager.Current.SortRoot.AddChild(temp); //创建抖动 MainCamera.Main.ProssesDirectionalShake(Vector2.Right.Rotated(GlobalRotation) * 1.5f); } diff --git a/DungeonShooting_Godot/src/weapon/gun/ThrowGun.cs b/DungeonShooting_Godot/src/weapon/gun/ThrowGun.cs index 1b8b071..e33895d 100644 --- a/DungeonShooting_Godot/src/weapon/gun/ThrowGun.cs +++ b/DungeonShooting_Godot/src/weapon/gun/ThrowGun.cs @@ -25,10 +25,9 @@ { InitThrow(Size, GlobalPosition, 0, Direction, XSpeed * 0.8f, StartYSpeed * 0.5f, RotateSpeed * 0.5f, null); } - else + else //结束 { - GetParent().RemoveChild(this); - RoomManager.Current.ObjectRoot.AddChild(this); + base.OnOver(); } } protected override void OnMaxHeight(float height) diff --git a/DungeonShooting_Godot/src/weapon/shell/ThrowShell.cs b/DungeonShooting_Godot/src/weapon/shell/ThrowShell.cs index 26931b7..4cbb3ce 100644 --- a/DungeonShooting_Godot/src/weapon/shell/ThrowShell.cs +++ b/DungeonShooting_Godot/src/weapon/shell/ThrowShell.cs @@ -21,8 +21,7 @@ } else { - GetParent().RemoveChild(this); - RoomManager.Current.ObjectRoot.AddChild(this); + base.OnOver(); //等待被销毁 AwaitDestroy(); }