diff --git a/prefab/Role.tscn b/prefab/Role.tscn index 2c60000..277d619 100644 --- a/prefab/Role.tscn +++ b/prefab/Role.tscn @@ -86,7 +86,7 @@ position = Vector2( 0, -12 ) frames = SubResource( 6 ) animation = "idle" -frame = 1 +frame = 3 playing = true [node name="HitArea" type="Area2D" parent="."] diff --git a/src/role/Player.cs b/src/role/Player.cs index 11cfb09..c1666b1 100644 --- a/src/role/Player.cs +++ b/src/role/Player.cs @@ -31,15 +31,16 @@ var attr = new GunAttribute(); attr.FiringSpeed = 420; attr.StartScatteringRange = 0; - attr.FinalScatteringRange = 10; + attr.FinalScatteringRange = 30; attr.ScatteringRangeAddValue = 5; - attr.ScatteringRangeBackSpeed = 20; + attr.ScatteringRangeBackSpeed = 30; //连发 - attr.ContinuousShoot = true; + attr.ContinuousShoot = false; //扳机检测间隔 attr.TriggerInterval = 1f; //连发数量 - attr.MinContinuousCount = 3; + attr.MinContinuousCount = 2; + attr.MaxContinuousCount = 5; //开火前延时 attr.DelayedTime = 0f; //攻击距离 @@ -47,7 +48,7 @@ attr.MaxDistance = 600; //发射子弹数量 attr.MinFireBulletCount = 1; - attr.MaxFireBulletCount = 1; + attr.MaxFireBulletCount = 3; //抬起角度 attr.UpliftAngle = 10; //枪身长度 diff --git a/src/weapon/gun/Gun.cs b/src/weapon/gun/Gun.cs index 8f224e8..d8d81bb 100644 --- a/src/weapon/gun/Gun.cs +++ b/src/weapon/gun/Gun.cs @@ -71,6 +71,7 @@ private float upTimer = 0; //连发次数 private float continuousCount = 0; + private bool continuousShootFlag = false; //子弹 private PackedScene bulletPacked; @@ -166,19 +167,49 @@ { //是否第一帧按下 var justDown = downTimer == 0; + //是否能发射 + var flag = false; + if (continuousCount <= 0) //不能处于连发状态下 + { + if (Attribute.ContinuousShoot) //自动射击 + { + if (triggerTimer > 0) + { + if (continuousShootFlag) + { + flag = true; + } + } + else + { + flag = true; + if (delayedTime <= 0 && attackTimer <= 0) + { + continuousShootFlag = true; + } + } + } + else //半自动 + { + if (justDown && triggerTimer <= 0) + { + flag = true; + } + } + } - if ((Attribute.ContinuousShoot || (justDown && triggerTimer <= 0)) && continuousCount <= 0) + if (flag) { if (justDown) { //开火前延时 delayedTime = Attribute.DelayedTime; //扳机按下间隔 - triggerTimer += Attribute.TriggerInterval; + triggerTimer = Attribute.TriggerInterval; //连发数量 if (!Attribute.ContinuousShoot) { - continuousCount = Attribute.MinContinuousCount; + continuousCount = MathUtils.RandRangeInt(Attribute.MinContinuousCount, Attribute.MaxContinuousCount); } } if (delayedTime <= 0 && attackTimer <= 0) @@ -195,7 +226,7 @@ /// private void DownTrigger() { - + } /// @@ -203,7 +234,7 @@ /// private void UpTriggern() { - + continuousShootFlag = false; } private void TriggernFire()