死亡计数修改

This commit is contained in:
GL 2024-12-27 22:58:44 +08:00
parent 0d58228599
commit c04f3f2ed9
3 changed files with 37 additions and 37 deletions

View File

@ -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("修改图片宽度");
}

View File

@ -81,10 +81,15 @@ public class Fun : Base
}
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;

View File

@ -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
/// </summary>
public List<Action<Role>> PlayerBuff=new List<Action<Role>>();
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
/// </summary>
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
/// </summary>
public void ResetAllStatus()
{
IsDead = false;
// ÖØÖÃѪÁ¿
Hp = 100f;