From 917219c444b77014a41eaf2e6df78c6ac1cafcc1 Mon Sep 17 00:00:00 2001 From: GL <2365963573@qq.com> Date: Mon, 13 Jan 2025 15:06:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=81=E8=99=8E=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Role/Attack.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Role/Attack.cs b/Role/Attack.cs index cc84d7a..82b6288 100644 --- a/Role/Attack.cs +++ b/Role/Attack.cs @@ -236,9 +236,9 @@ public class Attack : MonoBehaviour case 3: // 生成三个子弹:一个不旋转,一个向上旋转30度,一个向下旋转30度 - GenerateBullet(-35f, BulletStartPos.position, new Vector2(0, -0.25f),dir); + GenerateBullet(-35f, BulletStartPos.position, new Vector2(0, -0.25f*dir),dir); GenerateBullet(0f, BulletStartPos.position, new Vector2(0, 0),dir); - GenerateBullet(35f, BulletStartPos.position, new Vector2(0, 0.25f),dir); + GenerateBullet(35f, BulletStartPos.position, new Vector2(0, 0.25f*dir),dir); break; default: @@ -266,7 +266,7 @@ public class Attack : MonoBehaviour if (role.AttackRange / 2 > 1) { float offsetX = 0; - bulletGameObj.transform.localScale = new Vector2(role.AttackRange / 2, role.AttackRange / 3); + bulletGameObj.transform.localScale = new Vector2(role.AttackRange / 2*dir, role.AttackRange / 3); // 计算新的子弹宽度 float newWidth = bulletGameObj.GetComponentInChildren().bounds.size.x; @@ -285,10 +285,10 @@ public class Attack : MonoBehaviour offsetX = (newWidth - originalWidth) / 2; if (offsetX > 0) { - offsetX += 0.15f*dir; + offsetX += 0.15f; } // 调整子弹的位置,确保左边界不变 - bulletGameObj.transform.position = new Vector2(originalPosition.x + offsetX, originalPosition.y); + bulletGameObj.transform.position = new Vector2(originalPosition.x + offsetX*dir, originalPosition.y); } // 添加位置微调