AngryBulletSelf.cs 833 B

1234567891011121314151617181920212223242526272829
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System;
  5. public class AngryBulletSelf : MonoBehaviour
  6. {
  7. public AngryBullet ab;
  8. private void OnTriggerEnter(Collider other)
  9. {
  10. if (other.gameObject.layer == 8 && Array.IndexOf(ab.ens, other.GetComponentInParent<Enemy>()) == -1)
  11. {
  12. Enemy en = other.GetComponentInParent<Enemy>();
  13. ab.ens[ab.curTimes] = en;
  14. int damage = ab.damage + (int)(ab.realDamage * en.totalHp);
  15. en.BeHit(damage);
  16. ab.curTimes++;
  17. if (ab.curTimes == ab.maxTimes)
  18. {
  19. ab.ChangeState(AngryBullet.BulletState.die);
  20. }
  21. else
  22. {
  23. ab.ChangeState(AngryBullet.BulletState.findTarget);
  24. }
  25. }
  26. }
  27. }