From e181aec8b1cfd1b630cbcdb3dc4f450db9ea8cf1 Mon Sep 17 00:00:00 2001 From: GL <2365963573@qq.com> Date: Sat, 28 Dec 2024 14:30:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=BB=E5=87=BB=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Role/Attack.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Role/Attack.cs b/Role/Attack.cs index 0d6f6a3..57c57c5 100644 --- a/Role/Attack.cs +++ b/Role/Attack.cs @@ -38,6 +38,7 @@ public class Attack : MonoBehaviour [Header("攻击范围图片")] public SpriteRenderer attackRangeSprite; [Header("攻击持续时间")] public float AttackStayTime;// [Header("攻击目标")] public GameObject Target; + [Header("攻击范围显示脚本")] public CharacterClick characterClick; public bool isAttack = true; public bool flag = false; [HideInInspector] public float timer = 0; @@ -353,16 +354,15 @@ private void GenerateBullet(float angle, Vector2 startPos, Vector2 changePos)// { // 设置碰撞体的半径 attackCollider.radius = role.AttackRange; - - - // 获取攻击范围图片的原始直径 (SpriteRenderer的bounds.size.x) - float spriteDiameter = attackRangeSprite.bounds.size.x; + + + // 计算缩放因子,使得图片的直径与碰撞体的直径匹配 - float scaleFactor = role.AttackRange * 2f / spriteDiameter; // * 2f 因为 radius 是半径,图片的尺寸通常是直径 + characterClick.OrSizeX = role.AttackRange * 2f / characterClick.OrSizeX; // * 2f 因为 radius 是半径,图片的尺寸通常是直径 + - // 设置图片的缩放 - attackRangeSprite.transform.localScale = new Vector3(scaleFactor, scaleFactor, 1f); + } else if(attackColliderBox) {