UnityCommon/Role/Bullet.cs

392 lines
13 KiB
C#
Raw Permalink Normal View History

2024-12-05 16:25:46 +08:00
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UIElements;
2024-12-24 10:30:02 +08:00
using System.Linq;
2024-12-05 16:25:46 +08:00
public enum BulletType
{
Bullet,
2024-12-12 17:06:08 +08:00
Lightning,
2025-01-06 14:03:59 +08:00
Spraying, //ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
XuLi //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-12-05 16:25:46 +08:00
}
2024-12-20 16:28:28 +08:00
public enum BulletAttributes
{
Not,
Gold,//<2F><>ľˮ<C4BE><CBAE><EFBFBD><EFBFBD>
Wood,
Water,
Fire,
Earth
}
2024-12-05 16:25:46 +08:00
public enum BulletMoveType
{/// <summary>
/// <20>ӵ<EFBFBD><D3B5>ƶ<EFBFBD><C6B6><EFBFBD>ʽ:<3A><><EFBFBD>Ե<EFBFBD>,
/// </summary>
PeerToPeer,
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>
/// </summary>
2024-12-12 17:06:08 +08:00
PointToDirection,
Scope
2024-12-05 16:25:46 +08:00
}
2024-12-11 16:51:55 +08:00
2024-12-05 16:25:46 +08:00
public class BulletData
{
[Header("<22>ӵ<EFBFBD><D3B5><EFBFBD>͸<EFBFBD><CDB8><EFBFBD><EFBFBD>")] public int NumberOfBulletPenetrations = 1;
/// <summary>
/// <20>ӵ<EFBFBD>ɢ<EFBFBD><C9A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
[Header("<22>ӵ<EFBFBD>ɢ<EFBFBD><C9A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")] public int BulletScattering = 1;
[Header("<22>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")] public int BulletBurstTimes = 1;
[Header("<22>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")] public float BulletBurstInterval ;
[Header("<22>ӵ<EFBFBD><D3B5><EFBFBD>͸˥<CDB8><CBA5>")] public float BulletPenetrationAttenuation = 0.2f;
2024-12-11 16:51:55 +08:00
[Header("<22>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>")] public float BulletSpeed = 5f;
2024-12-05 16:25:46 +08:00
[Header("<22>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ")] public float BulletAttackCooldown = 1f;
2024-12-11 16:51:55 +08:00
[Header("<22>ӵ<EFBFBD><D3B5>˺<EFBFBD>")] public float attack = 10;
2024-12-20 16:28:28 +08:00
2024-12-05 16:25:46 +08:00
public BulletData()
{
}
public BulletData(int numberOfBulletPenetrations, int bulletScattering, int bulletBurstTimes, float bulletBurstInterval, float bulletPenetrationAttenuation, float bulletSpeed, float bulletAttackCooldown)
{
NumberOfBulletPenetrations = numberOfBulletPenetrations;
BulletScattering = bulletScattering;
BulletBurstTimes = bulletBurstTimes;
BulletBurstInterval = bulletBurstInterval;
BulletPenetrationAttenuation = bulletPenetrationAttenuation;
BulletSpeed = bulletSpeed;
BulletAttackCooldown = bulletAttackCooldown;
}
public override string ToString()
{
return
$"{nameof(NumberOfBulletPenetrations)}: {NumberOfBulletPenetrations}, {nameof(BulletScattering)}: {BulletScattering}, {nameof(BulletBurstTimes)}: {BulletBurstTimes}, {nameof(BulletBurstInterval)}: {BulletBurstInterval}, {nameof(BulletPenetrationAttenuation)}: {BulletPenetrationAttenuation}, {nameof(BulletSpeed)}: {BulletSpeed}, {nameof(BulletAttackCooldown)}: {BulletAttackCooldown}";
}
}
public class Bullet : MonoBehaviour
{
[Header("<22>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>")] public Role role;
[Header("<22>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>Χ<E4B7B6><CEA7><EFBFBD><EFBFBD>")] public Attack attackObj;
2024-12-12 17:06:08 +08:00
[Header("<22>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD>")] public BulletType myBulletType;
2024-12-20 16:28:28 +08:00
[Header("<22>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD>")] public BulletAttributes bulletAttributes;
2024-12-12 17:06:08 +08:00
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")] public BulletMoveType bulletMoveType;
[Header("<22>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD>")] public BulletData bulletData = new BulletData();
2025-01-03 18:02:54 +08:00
[Header("<22><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><><C4AC><EFBFBD><EFBFBD>10f")] public float BulletDeadTimer = 10f;
2024-12-20 16:28:28 +08:00
[Header("<22>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD>")] public Animator animator;
2025-01-03 18:02:54 +08:00
[Header("<22>ӵ<EFBFBD><D3B5>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>")] public bool IsMove = true;
2025-01-06 16:15:06 +08:00
[Header("<22>ӵ<EFBFBD><D3B5><EFBFBD>ײ<EFBFBD><D7B2>")] public CircleCollider2D Collider2D;
2025-01-03 18:02:54 +08:00
[Header("<22>ӵ<EFBFBD><D3B5><EFBFBD>ЧԤ<D0A7><D4A4><EFBFBD><EFBFBD>")] public List<GameObject> effectPres = new List<GameObject>();
2025-01-09 10:35:40 +08:00
public float timer = 0;
2024-12-25 15:51:45 +08:00
[Header("<22>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")] public int NumberOfBulletAttacks = 1;
2024-12-27 18:13:16 +08:00
[Header("<22><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>")] public GameObject Target;
2025-01-03 18:02:54 +08:00
[Header("<22>ӵ<EFBFBD><D3B5>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>")] public bool noLockEnemy=false;
[Header("<22>ӵ<EFBFBD><D3B5>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")] public bool Cansplit = false;
[Header("<22><><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD>")] public GameObject smallBulletPrefab;
2025-01-06 16:15:06 +08:00
[Header("<22>ӵ<EFBFBD><D3B5>Ƿ<EFBFBD><C7B7>ᱬը")] public bool CanBoom = false;
2024-12-05 16:25:46 +08:00
private void Update()
{
switch (this.bulletMoveType)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>ƶ<EFBFBD>
case BulletMoveType.PeerToPeer:
2024-12-20 16:28:28 +08:00
if (IsMove)
2024-12-12 17:06:08 +08:00
{
2024-12-27 18:13:16 +08:00
2025-01-03 18:02:54 +08:00
if (Target != null&&Target.activeSelf==true&&!noLockEnemy)
2024-12-27 18:13:16 +08:00
{
this.gameObject.transform.position = Vector3.MoveTowards(this.gameObject.transform.position, Target.transform.position, Time.deltaTime * bulletData.BulletSpeed);
}
else
{
this.gameObject.transform.Translate(Vector3.up * Time.deltaTime * bulletData.BulletSpeed);
}
2024-12-20 16:28:28 +08:00
timer += Time.deltaTime;
if (timer > BulletDeadTimer)
{
attackObj.bulltes.Remove(this.gameObject);
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD>ѳɹ<D1B3><C9B9>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + attackObj.bulltes.Count);
Destroy(this.gameObject);
}
2024-12-12 17:06:08 +08:00
}
2024-12-20 16:28:28 +08:00
2024-12-05 16:25:46 +08:00
break;
case BulletMoveType.PointToDirection:
break;
2024-12-12 17:06:08 +08:00
case BulletMoveType.Scope:
break;
2024-12-05 16:25:46 +08:00
}
2024-12-11 16:51:55 +08:00
2024-12-12 17:06:08 +08:00
2024-12-11 16:51:55 +08:00
2024-12-05 16:25:46 +08:00
}
2024-12-11 16:51:55 +08:00
2024-12-05 16:25:46 +08:00
private void OnTriggerEnter2D(Collider2D collision)
{
2024-12-25 16:47:54 +08:00
Role Crole = collision.gameObject.GetComponent<Role>();
if (Crole)
2024-12-25 15:51:45 +08:00
{
2024-12-25 16:47:54 +08:00
if (Crole.camp != role.camp)
2024-12-05 16:25:46 +08:00
{
2024-12-25 16:47:54 +08:00
if (NumberOfBulletAttacks < 0)
2024-12-05 16:25:46 +08:00
{
2024-12-25 16:47:54 +08:00
return;
}
else
{
2024-12-25 17:00:36 +08:00
if (this.myBulletType== BulletType.Spraying)
2024-12-25 15:51:45 +08:00
{
2024-12-25 17:00:36 +08:00
NumberOfBulletAttacks += 1;
2024-12-25 15:51:45 +08:00
}
2024-12-20 16:28:28 +08:00
2024-12-25 17:00:36 +08:00
NumberOfBulletAttacks -= 1;
2024-12-20 16:28:28 +08:00
2024-12-25 17:00:36 +08:00
foreach (var buff in role.storageBuff)
{
if (!Crole.PlayerBuff.Contains(buff))
{
Crole.PlayerBuff.Add(buff);
}
}
2024-12-25 15:51:45 +08:00
2024-12-25 17:00:36 +08:00
Crole.ApplyBuffs();
2024-12-20 16:28:28 +08:00
2024-12-26 11:19:45 +08:00
// Debug.Log(this.role.gameObject.name + "<22><><EFBFBD>й<EFBFBD><D0B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
2024-12-25 17:00:36 +08:00
int direction = 0;
if (collision.transform.position.x > transform.position.x) //<2F>ӵ<EFBFBD><D3B5>򵽵<EFBFBD><F2B5BDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>ұ<EFBFBD>
2024-12-25 15:51:45 +08:00
{
2024-12-25 17:00:36 +08:00
direction = 1;
2024-12-25 16:47:54 +08:00
}
2025-01-06 16:15:06 +08:00
if (!CanBoom)//<2F>ж<EFBFBD><D0B6>ӵ<EFBFBD><D3B5>Ƿ<EFBFBD><C7B7>ᱬը
2024-12-25 16:47:54 +08:00
{
2025-01-06 16:15:06 +08:00
Crole.bloodLoss(new object[] { Crole, role.DamageCreate(Crole.GetComponent<Role>()), attackObj.damageTyp, role }, direction);
attackObj.bulltes.Remove(this.gameObject);
if (myBulletType != BulletType.Spraying)
{
2024-12-24 14:56:21 +08:00
2024-12-25 15:51:45 +08:00
2025-01-06 16:15:06 +08:00
if (animator == null)
{
SplitBullet();
attackObj.bulltes.Remove(this.gameObject);
Destroy(this.gameObject);
}
else
{
IsMove = false; //ֹͣ<CDA3>ƶ<EFBFBD>
Collider2D.enabled = false; //<2F>ر<EFBFBD><D8B1><EFBFBD>ײ<EFBFBD><D7B2>
transform.position = collision.transform.position;
animator.SetTrigger("Boom");
}
2024-12-25 17:00:36 +08:00
}
2025-01-06 16:15:06 +08:00
}
else
{
if (animator!=null)
2024-12-25 17:00:36 +08:00
{
IsMove = false; //ֹͣ<CDA3>ƶ<EFBFBD>
Collider2D.enabled = false; //<2F>ر<EFBFBD><D8B1><EFBFBD>ײ<EFBFBD><D7B2>
transform.position = collision.transform.position;
animator.SetTrigger("Boom");
}
}
2025-01-06 16:15:06 +08:00
2024-12-25 15:51:45 +08:00
2024-12-25 17:00:36 +08:00
if (bulletAttributes == BulletAttributes.Not) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-12-25 16:47:54 +08:00
{
Crole.FlashRedEffect();
2024-12-25 17:00:36 +08:00
2024-12-20 16:28:28 +08:00
}
2024-12-25 16:47:54 +08:00
2024-12-25 17:00:36 +08:00
if (bulletAttributes == BulletAttributes.Fire) //<2F><>
{
2024-12-25 15:51:45 +08:00
2024-12-25 17:00:36 +08:00
if (effectPres.Count == 1)
{
GameObject go = Instantiate(effectPres[0], collision.transform);
go.transform.position = new Vector2(collision.transform.position.x,
collision.transform.position.y + 0.2f);
go.GetComponent<Huo>().bullet = this;
Crole.FlashRedEffect();
//Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
}
if (bulletAttributes == BulletAttributes.Water) //ˮ
2024-12-20 21:41:40 +08:00
{
2024-12-25 17:00:36 +08:00
if (effectPres.Count > 1)
{
GameObject go = Instantiate(effectPres[Random.Range(0, effectPres.Count - 1)],
collision.transform);
go.transform.position = new Vector2(collision.transform.position.x,
collision.transform.position.y - 0.2f);
collision.transform.GetComponent<enemy>().SlowDown(0.2f, 3f);
Crole.FlashRedEffect(1, 3f);
}
2024-12-25 15:51:45 +08:00
}
2024-12-20 16:28:28 +08:00
2024-12-25 17:00:36 +08:00
2024-12-18 20:43:54 +08:00
}
2024-12-20 21:41:40 +08:00
}
2024-12-25 15:51:45 +08:00
}
2024-12-18 20:43:54 +08:00
}
private float lastDamageTime = 0f;
private void OnTriggerStay2D(Collider2D collision)
{
Role Crole = collision.gameObject.GetComponent<Role>();
if (Crole)
{
if (Crole.camp != role.camp)
{
int direction = 0;
if (collision.transform.position.x >= transform.position.x)//<2F>ӵ<EFBFBD><D3B5>򵽵<EFBFBD><F2B5BDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>ұ<EFBFBD>
{
direction = 1;
}
if (myBulletType == BulletType.Spraying)
{
if (Time.time - lastDamageTime > 1f) // ÿ<><C3BF><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>Ѫ
{
2024-12-19 19:01:39 +08:00
2024-12-25 21:41:45 +08:00
Crole.bloodLoss(new object[] { Crole, role.DamageCreate( Crole.GetComponent<Role>()), attackObj.damageTyp, role });
2024-12-24 14:56:21 +08:00
Crole.FlashRedEffect();
2024-12-18 20:43:54 +08:00
lastDamageTime = Time.time;
}
2024-12-05 16:25:46 +08:00
}
}
2024-12-18 20:43:54 +08:00
}
2024-12-05 16:25:46 +08:00
}
2024-12-12 23:03:57 +08:00
2024-12-20 16:28:28 +08:00
public void DesBullet()
{
attackObj.bulltes.Remove(this.gameObject);
Destroy(this.gameObject);
}
2024-12-18 20:43:54 +08:00
2024-12-12 23:03:57 +08:00
private void OnTriggerExit2D(Collider2D collision)
{
2024-12-14 23:20:36 +08:00
//Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ");
2024-12-12 23:03:57 +08:00
Role Crole = collision.gameObject.GetComponent<Role>();
if (Crole)
{
if (Crole.camp != role.camp)
{
2024-12-17 17:15:32 +08:00
2024-12-14 23:20:36 +08:00
//Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD>ѳɹ<D1B3><C9B9>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + attackObj.bulltes.Count);
2024-12-17 17:15:32 +08:00
if (myBulletType != BulletType.Spraying)
{
2024-12-20 16:28:28 +08:00
if (animator==null)
{
attackObj.bulltes.Remove(this.gameObject);
Destroy(this.gameObject);
}
2024-12-17 17:15:32 +08:00
}
2024-12-12 23:03:57 +08:00
}
}
}
2025-01-03 18:02:54 +08:00
public void SplitBullet()//<2F>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD>
{
if (Cansplit)
{
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Vector3 currentDirection = transform.forward;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>ӵ<EFBFBD>
for (int i = 0; i < attackObj.splitNum; i++)
{
// <20>ڵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD>
2025-01-03 20:50:25 +08:00
Vector3 randomOffset = new Vector3(Random.Range(-0.2f, 0.2f), Random.Range(-0.2f, 0.2f));
2025-01-03 18:02:54 +08:00
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>С<EFBFBD>ӵ<EFBFBD>
GameObject smallBullet = Instantiate(smallBulletPrefab, transform.position, Quaternion.identity);
smallBullet.GetComponent<SmallBullet>().role = role;
smallBullet.GetComponent<SmallBullet>().attackObj=attackObj;
2025-01-03 20:50:25 +08:00
smallBullet.GetComponent<SmallBullet>().Target = Target;
2025-01-03 18:02:54 +08:00
// ΪС<CEAA>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>÷<EFBFBD><C3B7>з<EFBFBD><D0B7>򣨵<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD> + <20><><EFBFBD><EFBFBD>ƫ<EFBFBD>ƣ<EFBFBD>
smallBullet.transform.up = currentDirection+randomOffset;
// <20><><EFBFBD><EFBFBD>С<EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E7B9A5><EFBFBD><EFBFBD><EFBFBD>ԡ<EFBFBD><D4A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>
}
}
}
2025-01-06 16:15:06 +08:00
public void BulletBoom() // <20>ӵ<EFBFBD><D3B5><EFBFBD>ը
{
// <20><>չ<EFBFBD><D5B9>ײ<EFBFBD><D7B2><EFBFBD>Ĵ<EFBFBD>С<EFBFBD><D0A1>ģ<EFBFBD>ⱬը<E2B1AC><D5A8>Χ
float explosionRadius = attackObj.BoomRange; // <20><><EFBFBD>ñ<EFBFBD>ը<EFBFBD>İ뾶<C4B0><EBBEB6>С
// <20><><EFBFBD>ⱬը<E2B1AC><D5A8>Χ<EFBFBD>ڵĵ<DAB5><C4B5><EFBFBD>
Collider2D[] hitEnemies = Physics2D.OverlapCircleAll(transform.position, explosionRadius);
foreach (var enemyCollider in hitEnemies)
{
Role enemyRole = enemyCollider.gameObject.GetComponent<Role>();
if (enemyRole != null && enemyRole.camp != role.camp) // <20><><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD><C7B5>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>Ӫ
{
// <20><><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>Ը<EFBFBD><D4B8><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
float damage = role.DamageCreate(enemyRole);
// <20><>Ѫ<EFBFBD><D1AA><EFBFBD><EFBFBD>
enemyRole.bloodLoss(new object[] { enemyRole, damage, attackObj.damageTyp, role });
enemyRole.FlashRedEffect();
}
}
// <20><><EFBFBD>ٵ<EFBFBD>ǰ<EFBFBD>ӵ<EFBFBD>
attackObj.bulltes.Remove(this.gameObject);
Destroy(this.gameObject);
}
2025-01-09 13:30:13 +08:00
void OnDestroy()
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
if (transform.GetComponent<Renderer>() != null)
{
var material = transform.GetComponent<Renderer>().material;
if (material != null) Destroy(material);
var texture = material.mainTexture;
if (texture != null) Destroy(texture);
}
// ֹͣЭ<D6B9><D0AD>
StopAllCoroutines();
// <20><><EFBFBD><EFBFBD>δʹ<CEB4>õ<EFBFBD><C3B5><EFBFBD>Դ
Resources.UnloadUnusedAssets();
}
2024-12-05 16:25:46 +08:00
}