DahalBullet.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System;
  2. using System.Collections;
  3. using UnityEngine;
  4. public class DahalBullet : BaseBehaviour
  5. {
  6. private float deltaTime
  7. {
  8. get
  9. {
  10. return Time.time - this.startTime;
  11. }
  12. }
  13. private bool isOnGround
  14. {
  15. get
  16. {
  17. RaycastHit2D hit = Physics2D.Raycast(base.transform.position, -Vector2.up, 0.36f, LayerManager.GroundMask);
  18. return hit;
  19. }
  20. }
  21. private void Awake()
  22. {
  23. this._rigidbody2D = base.GetComponent<Rigidbody2D>();
  24. }
  25. private void OnEnable()
  26. {
  27. this.player = R.Player.Transform;
  28. this.isUseExplosion = false;
  29. this.startTime = Time.time;
  30. base.StartCoroutine(this.Rise());
  31. }
  32. private IEnumerator Rise()
  33. {
  34. float angle = 90f - this.riseAngle;
  35. this.riseSpeedVector2 = new Vector2(Mathf.Cos(angle * 0.0174532924f), Mathf.Sin(angle * 0.0174532924f)) * this.riseSpeed;
  36. while (this.riseTime > this.deltaTime)
  37. {
  38. yield return new WaitForFixedUpdate();
  39. base.transform.localRotation = Quaternion.Euler(new Vector3(0f, 0f, angle));
  40. this._rigidbody2D.velocity = this.riseSpeedVector2;
  41. }
  42. this._rigidbody2D.velocity = Vector2.zero;
  43. yield break;
  44. }
  45. [SerializeField]
  46. public float angularSpeed;
  47. [SerializeField]
  48. public float speed;
  49. [SerializeField]
  50. public float riseTime;
  51. [SerializeField]
  52. public float riseSpeed;
  53. [SerializeField]
  54. public float riseAngle;
  55. [SerializeField]
  56. public float riseAcceleration;
  57. private Transform player;
  58. private Vector2 riseSpeedVector2;
  59. private bool isUseExplosion;
  60. private float startTime;
  61. private Rigidbody2D _rigidbody2D;
  62. }