JudgesPart.cs 1004 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using UnityEngine;
  3. public class JudgesPart : 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 Start()
  14. {
  15. this.flyToFall = true;
  16. this.hitGround = false;
  17. this.spineAnim = base.GetComponent<SkeletonAnimation>();
  18. this.body = base.GetComponent<Rigidbody2D>();
  19. }
  20. private void Update()
  21. {
  22. if (this.flyToFall && this.body.velocity.y <= 0f)
  23. {
  24. this.spineAnim.state.SetAnimation(0, "FlyToFall", false);
  25. this.flyToFall = false;
  26. this.hitGround = true;
  27. }
  28. if (this.hitGround && this.isOnGround)
  29. {
  30. this.spineAnim.state.SetAnimation(0, "FallHitGround", false);
  31. this.hitGround = false;
  32. }
  33. }
  34. private Rigidbody2D body;
  35. private SkeletonAnimation spineAnim;
  36. private bool flyToFall;
  37. private bool hitGround;
  38. }