From c04f3f2ed9571f522b41ec9f27928529d7c9f352 Mon Sep 17 00:00:00 2001 From: GL <2365963573@qq.com> Date: Fri, 27 Dec 2024 22:58:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=BB=E4=BA=A1=E8=AE=A1=E6=95=B0=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Role/Attack.cs | 33 ++++++--------------------------- Role/Fun.cs | 9 +++++++-- Role/Role.cs | 32 ++++++++++++++++++++++++-------- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/Role/Attack.cs b/Role/Attack.cs index c569d13..0d6f6a3 100644 --- a/Role/Attack.cs +++ b/Role/Attack.cs @@ -366,42 +366,21 @@ private void GenerateBullet(float angle, Vector2 startPos, Vector2 changePos)// } else if(attackColliderBox) { - if (attackColliderBox == null || attackRangeSprite == null) - { - Debug.LogError("Attack Collider or Attack Range Sprite is missing!"); - return; // 如果没有找到攻击碰撞体或攻击范围图片,提前返回 - } - Vector2 boxSize = attackColliderBox.size; // 假设攻击范围决定了矩形的长宽比 - boxSize.x = role.AttackRange * 2f; // 设置矩形宽度 - //boxSize.y = role.AttackRange / 3; // 设置矩形高度(如果需要,可以调整比例) + // attackRange * 2 可以增加攻击范围的矩形尺寸,调整比例或常数以适应你的需要 + boxSize.x = role.AttackRange * 2f+2; // 设置矩形宽度 + //boxSize.y = role.AttackRange/3; // 设置矩形高度 // 更新矩形碰撞体的尺寸 attackColliderBox.size = boxSize; - // 确保 attackRangeSprite.bounds.size 不为零 - if (attackRangeSprite.bounds.size.x == 0 || attackRangeSprite.bounds.size.y == 0) - { - Debug.LogError("Attack Range Sprite bounds size is invalid."); - return; - } - // 调整攻击范围图片的缩放,使其与碰撞体的大小一致 - float scaleX = boxSize.x / attackRangeSprite.bounds.size.x * 3 * 0.75f; - float scaleY = boxSize.y / attackRangeSprite.bounds.size.y * 2; - // 确保计算结果不是无效值(如 Infinity 或 NaN) - scaleX = Mathf.Clamp(scaleX, 0.1f, 10f); // 设置合理的范围,防止缩放过大或过小 - scaleY = Mathf.Clamp(scaleY, 0.1f, 10f); - - // 保留两位小数 - scaleX = Mathf.Round(scaleX * 100f) / 100f; - scaleY = Mathf.Round(scaleY * 100f) / 100f; - - // 设置图片的缩放 - attackRangeSprite.transform.localScale = new Vector3(scaleX, scaleY, 1f); + //float originalWidth = attackRangeSprite.bounds.size.x; + //attackRangeSprite.transform.localScale = new Vector3(boxSize.x*1.4f/4, boxSize.y, 1f); + Debug.Log("修改图片宽度"); } diff --git a/Role/Fun.cs b/Role/Fun.cs index 59bfbe4..9c5b84e 100644 --- a/Role/Fun.cs +++ b/Role/Fun.cs @@ -80,11 +80,16 @@ public class Fun : Base finalDamage = 0; } - + + + + targetAudience.Hp -= finalDamage; - if (targetAudience.Hp<=0) + if (targetAudience.Hp<=0&&targetAudience.HaveDieTime==1) { + UserObj.killNum++; + Debug.Log(UserObj.name+"ɱ"+ UserObj.killNum); } targetAudience.HurtDirectin = direction; diff --git a/Role/Role.cs b/Role/Role.cs index 338cc68..aa1b37d 100644 --- a/Role/Role.cs +++ b/Role/Role.cs @@ -82,13 +82,13 @@ public class Role : Fun get => hp; set { - //if (hp<0) - //{ - // return; - //} + float temp = hp; + + hp = value; + // Ѫʾ if (Hpfiil != null) { @@ -188,6 +188,10 @@ public class Role : Fun /// public List> PlayerBuff=new List>(); + + public bool IsDead = false; + public int HaveDieTime = 0; + public virtual async void Start() { @@ -291,9 +295,10 @@ public class Role : Fun if (lsanimationHighlight == dieIndex) { - - SpawnPool.intance.ReturnEnemyToPool(this.gameObject); // յǰ˵ - ResetAllStatus(); + SpawnPool.intance.DeadNumber += 1; + Destroy(gameObject); + // SpawnPool.intance.ReturnEnemyToPool(this.gameObject); // յǰ˵ + // ResetAllStatus(); } if (lsanimationHighlight == hitIndex) @@ -310,11 +315,20 @@ public class Role : Fun /// public virtual void die() { + if (Application.isPlaying) { animationHighlight = dieIndex; Navigation.PauseAnimation(); - //mycollider.enabled = false; + + if (!IsDead) + { + UIContorl.instance.Killnumber++; + //Destroy(gameObject); + + IsDead = true; + } + HaveDieTime++; Debug.Log("die"); } @@ -378,6 +392,8 @@ public class Role : Fun /// public void ResetAllStatus() { + + IsDead = false; // Ѫ Hp = 100f;