This commit is contained in:
wulongxiao 2025-01-13 16:23:25 +08:00
commit 3477d8e07e

View File

@ -236,9 +236,9 @@ public class Attack : MonoBehaviour
case 3: case 3:
// 生成三个子弹一个不旋转一个向上旋转30度一个向下旋转30度 // 生成三个子弹一个不旋转一个向上旋转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(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; break;
default: default:
@ -266,7 +266,7 @@ public class Attack : MonoBehaviour
if (role.AttackRange / 2 > 1) if (role.AttackRange / 2 > 1)
{ {
float offsetX = 0; 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<SpriteRenderer>().bounds.size.x; float newWidth = bulletGameObj.GetComponentInChildren<SpriteRenderer>().bounds.size.x;
@ -285,10 +285,10 @@ public class Attack : MonoBehaviour
offsetX = (newWidth - originalWidth) / 2; offsetX = (newWidth - originalWidth) / 2;
if (offsetX > 0) 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);
} }
// 添加位置微调 // 添加位置微调