UnityCommon/Role/SmallBullet.cs

129 lines
3.2 KiB
C#
Raw Permalink Normal View History

2025-01-03 18:02:54 +08:00
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UIElements;
using System.Linq;
public class SmallBullet : Bullet
{
private void Update()
{
switch (this.bulletMoveType)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>ƶ<EFBFBD>
case BulletMoveType.PeerToPeer:
if (IsMove)
{
2025-01-03 20:50:25 +08:00
this.gameObject.transform.Translate(Vector3.up * Time.deltaTime * bulletData.BulletSpeed*8);
2025-01-03 18:02:54 +08:00
2025-01-09 10:35:40 +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);
}
2025-01-03 18:02:54 +08:00
}
break;
case BulletMoveType.PointToDirection:
break;
case BulletMoveType.Scope:
break;
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
Role Crole = collision.gameObject.GetComponent<Role>();
2025-01-03 20:50:25 +08:00
if (Crole&&Target!= collision.gameObject)
2025-01-03 18:02:54 +08:00
{
if (Crole.camp != role.camp)
{
foreach (var buff in role.storageBuff)
{
if (!Crole.PlayerBuff.Contains(buff))
{
Crole.PlayerBuff.Add(buff);
}
}
Crole.ApplyBuffs();
// Debug.Log(this.role.gameObject.name + "<22><><EFBFBD>й<EFBFBD><D0B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
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;
}
2025-01-03 20:50:25 +08:00
Crole.bloodLoss(new object[] { Crole, attackObj.SplitAttack, attackObj.damageTyp, role }, direction);
Crole.FlashRedEffect();
role.GetComponent<enemy>().HarmNumber += attackObj.SplitAttack;
Debug.Log("<22><><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>˺<EFBFBD>"+ attackObj.SplitAttack);
2025-01-03 18:02:54 +08:00
2025-01-03 20:50:25 +08:00
if (myBulletType != BulletType.Spraying)
2025-01-03 18:02:54 +08:00
{
if (animator == null)
{
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");
}
}
}
}
}
private void OnTriggerStay2D(Collider2D collision)
{
}
private void OnTriggerExit2D(Collider2D collision)
{
}
}