GiantBullet.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using GameWorld;
  3. using LitJson;
  4. using UnityEngine;
  5. public class GiantBullet : BaseBehaviour
  6. {
  7. private bool isOnGround
  8. {
  9. get
  10. {
  11. RaycastHit2D hit = Physics2D.Raycast(base.transform.position, -Vector2.up, 0.36f, LayerManager.GroundMask);
  12. return hit;
  13. }
  14. }
  15. private void Start()
  16. {
  17. this.euler = base.transform.rotation.eulerAngles;
  18. this._rigidbody2D = base.GetComponent<Rigidbody2D>();
  19. }
  20. private void Update()
  21. {
  22. this.euler = base.transform.rotation.eulerAngles;
  23. this._rigidbody2D.velocity = new Vector2(-Mathf.Sin(this.euler.z * 0.0174532924f), Mathf.Cos(this.euler.z * 0.0174532924f));
  24. if (this.isOnGround)
  25. {
  26. if (!this.isUseExplosion)
  27. {
  28. this.isUseExplosion = true;
  29. }
  30. EffectController.TerminateEffect(base.gameObject);
  31. }
  32. }
  33. public void OnTriggerEnter2D(Collider2D collision)
  34. {
  35. if (collision.name == "PlayerHurtBox")
  36. {
  37. PlayerHurtAtkEventArgs args = new PlayerHurtAtkEventArgs(collision.transform.parent.gameObject, base.gameObject, this.attacker.gameObject, this.damage, Incrementor.GetNextId(), this.atkData, false);
  38. EventManager.PostEvent<Transform, PlayerHurtAtkEventArgs>("PlayerHurtAtk", base.transform, args);
  39. }
  40. }
  41. [SerializeField]
  42. private string data;
  43. [SerializeField]
  44. private JsonData atkData;
  45. public int damage;
  46. private Vector3 euler;
  47. public Transform attacker;
  48. private bool isUseExplosion;
  49. private Rigidbody2D _rigidbody2D;
  50. }