Photosphere.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using Sirenix.OdinInspector;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class Photosphere : MonoBehaviour
  6. {
  7. //组件
  8. public ConductController conductController;
  9. [LabelText("有停留时间")]public bool haveStayTime;
  10. [ShowIf("haveStayTime")][LabelText("停留时间")]public float stayTime;
  11. [LabelText("破碎特效")]public GameObject breakEffect;
  12. private float time;
  13. [LabelText("大小差值")] public float offset;
  14. public int hp;
  15. public int id;
  16. public GameObject bulletPrefab;
  17. [Header("反伤率")] public float rate;
  18. private void Update()
  19. {
  20. if (hp <= 0)
  21. {
  22. conductController.photospheres.Remove(this);
  23. Transform trans = PoolManager.Instantiate(breakEffect).transform;
  24. trans.position = transform.position;
  25. conductController.RefreshBarrierScale();
  26. gameObject.SetActive(false);
  27. }
  28. if (haveStayTime)
  29. {
  30. time += Time.deltaTime;
  31. if (time >= stayTime)
  32. {
  33. conductController.photospheres.Remove(this);
  34. conductController.RefreshBarrierScale();
  35. gameObject.SetActive(false);
  36. }
  37. }
  38. }
  39. public void Reflex(BeHitTrigger beHitTrigger,int damage)
  40. {
  41. hp -= damage;
  42. GameObject obj =PoolManager.Instantiate(bulletPrefab);
  43. Vector3 attackDir = (beHitTrigger.owner.beSearchTrigger.transform.position - transform.position).normalized;
  44. //obj.GetComponent<Bullet>().BeShoot(beHitTrigger.owner, transform.position, attackDir, true, true, beHitTrigger.owner);
  45. //obj.GetComponent<MagicBullet>().Reflex(damage,beHitTrigger.owner,transform.position, attackDir,owner);
  46. if (hp <= 0)
  47. {
  48. gameObject.SetActive(false);
  49. }
  50. }
  51. }