diff --git a/prefab/weapon/Gun.tscn b/prefab/weapon/Gun.tscn
index eec577f..35e9f95 100644
--- a/prefab/weapon/Gun.tscn
+++ b/prefab/weapon/Gun.tscn
@@ -21,11 +21,12 @@
[node name="OriginPoint" type="Position2D" parent="."]
position = Vector2( 0, -1.5 )
-scale = Vector2( 0.8, 0.8 )
+
+[node name="ShellPoint" type="Position2D" parent="."]
+position = Vector2( 1, -3 )
[node name="FirePoint" type="Position2D" parent="."]
position = Vector2( 11, -1.5 )
-scale = Vector2( 0.8, 0.8 )
[node name="Area" type="Area2D" parent="."]
collision_layer = 4
diff --git a/resource/sprite/shell/shellCase.png b/resource/sprite/shell/shellCase.png
index 390aef4..c6db56d 100644
--- a/resource/sprite/shell/shellCase.png
+++ b/resource/sprite/shell/shellCase.png
Binary files differ
diff --git a/src/GameConfig.cs b/src/GameConfig.cs
index 3b94e9d..91ebe06 100644
--- a/src/GameConfig.cs
+++ b/src/GameConfig.cs
@@ -8,5 +8,5 @@
///
/// 重力加速度
///
- public static readonly float G = 200f;
+ public static readonly float G = 250f;
}
\ No newline at end of file
diff --git a/src/weapon/ThrowNode.cs b/src/weapon/ThrowNode.cs
index 718f8ad..bc69dc6 100644
--- a/src/weapon/ThrowNode.cs
+++ b/src/weapon/ThrowNode.cs
@@ -8,21 +8,25 @@
{
public bool IsOver { get; protected set; } = true;
- private Vector2 StartPosition;
- private float Direction;
- private Vector2 Velocity;
- private Node2D Mount;
+ public Vector2 StartPosition { get; protected set; }
+ public float Direction { get; protected set; }
+ public float XForce { get; protected set; }
+ public float YForce { get; protected set; }
+ public float RotateSpeed { get; protected set; }
+ public Node2D Mount { get; protected set; }
- public void InitThrow(Vector2 start, float direction, Vector2 velocity, Node2D mount)
+ public void InitThrow(Vector2 start, float startHeight, float direction, float xForce, float yForce, float rotate, Node2D mount)
{
IsOver = false;
GlobalPosition = StartPosition = start;
Direction = direction;
- Velocity = velocity;
+ XForce = xForce;
+ YForce = -yForce;
+ RotateSpeed = rotate;
Mount = mount;
AddChild(mount);
- mount.Position = Vector2.Zero;
+ mount.Position = new Vector2(0, -startHeight);
}
protected virtual void OnOver()
@@ -34,9 +38,10 @@
{
if (!IsOver)
{
- Position += new Vector2(Velocity.x * delta, 0).Rotated(Direction * Mathf.Pi / 180);
- Mount.Position = new Vector2(0, Mount.Position.y + Velocity.y * delta);
- Velocity.y += GameConfig.G * delta;
+ Position += new Vector2(XForce * delta, 0).Rotated(Direction * Mathf.Pi / 180);
+ Mount.Position = new Vector2(0, Mount.Position.y + YForce * delta);
+ Mount.GlobalRotationDegrees += RotateSpeed * delta;
+ YForce += GameConfig.G * delta;
if (Mount.Position.y >= 0)
{
diff --git a/src/weapon/gun/Gun.cs b/src/weapon/gun/Gun.cs
index 74303f0..52fd2e7 100644
--- a/src/weapon/gun/Gun.cs
+++ b/src/weapon/gun/Gun.cs
@@ -52,6 +52,10 @@
///
public Position2D OriginPoint { get; private set; }
///
+ /// 弹壳抛出的点
+ ///
+ public Position2D ShellPoint { get; private set; }
+ ///
/// 枪的当前散射半径
///
public float CurrScatteringRange { get; private set; } = 0;
@@ -83,6 +87,7 @@
GunSprite = GetNode("GunSprite");
FirePoint = GetNode("FirePoint");
OriginPoint = GetNode("OriginPoint");
+ ShellPoint = GetNode("ShellPoint");
}
public override void _Process(float delta)
diff --git a/src/weapon/gun/OrdinaryGun.cs b/src/weapon/gun/OrdinaryGun.cs
index 352d95b..0aa25c9 100644
--- a/src/weapon/gun/OrdinaryGun.cs
+++ b/src/weapon/gun/OrdinaryGun.cs
@@ -20,7 +20,13 @@
{
//创建一个弹壳
var temp = new ThrowNode();
- temp.InitThrow(GlobalPosition, 30, new Vector2(30, -100), shell.Instance());
+ var startPos = GlobalPosition + new Vector2(0, 5);
+ var startHeight = 16;
+ var direction = GlobalRotationDegrees + MathUtils.RandRangeInt(-30, 30) + 180;
+ var xf = MathUtils.RandRangeInt(20, 60);
+ var yf = MathUtils.RandRangeInt(60, 120);
+ var rotate = MathUtils.RandRangeInt(-720, 720);
+ temp.InitThrow(startPos, startHeight, direction, xf, yf, rotate, shell.Instance());
RoomManager.Current.ItemRoot.AddChild(temp);
}