JumperPart.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using UnityEngine;
  3. public class JumperPart : BaseBehaviour
  4. {
  5. private bool isOnGround
  6. {
  7. get
  8. {
  9. RaycastHit2D hit = Physics2D.Raycast(base.transform.position, -Vector2.up, 0.5f, LayerManager.GroundMask | LayerManager.ObstacleMask | LayerManager.OneWayGroundMask);
  10. return hit;
  11. }
  12. }
  13. private void Awake()
  14. {
  15. this.anim = base.GetComponent<SkeletonAnimation>();
  16. }
  17. public void Init(bool isGround, Vector2 speed)
  18. {
  19. if (isGround)
  20. {
  21. this.hitGround = true;
  22. this.anim.state.SetAnimation(0, "Die3", false);
  23. R.Effect.Generate(163, null, new Vector3(base.transform.position.x, base.transform.position.y, base.transform.position.z - 0.1f), Vector3.zero, default(Vector3), true);
  24. }
  25. else
  26. {
  27. base.GetComponent<Rigidbody2D>().velocity = speed;
  28. this.anim.state.SetAnimation(0, "DieAir1Fall", true);
  29. }
  30. }
  31. private void Update()
  32. {
  33. if (this.isOnGround && !this.hitGround)
  34. {
  35. this.hitGround = true;
  36. this.anim.state.SetAnimation(0, "DieAir1Die", false);
  37. R.Effect.Generate(163, null, new Vector3(base.transform.position.x, base.transform.position.y, base.transform.position.z - 0.1f), Vector3.zero, default(Vector3), true);
  38. }
  39. }
  40. private void OnDisable()
  41. {
  42. this.hitGround = false;
  43. }
  44. private SkeletonAnimation anim;
  45. private bool hitGround;
  46. }