DahalAnimTransformProxy.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using UnityEngine;
  3. namespace SceneStory
  4. {
  5. public class DahalAnimTransformProxy : BaseBehaviour
  6. {
  7. private void OnEnable()
  8. {
  9. }
  10. private void Update()
  11. {
  12. if (this.dac == null)
  13. {
  14. this.SetBoss();
  15. return;
  16. }
  17. if (this.refreshPos)
  18. {
  19. this.dac.transform.position = base.transform.position;
  20. }
  21. if (this.refreshOffset)
  22. {
  23. Vector3 position = this.dac.transform.position + (this.offset - this.lastOffset);
  24. this.lastOffset = this.offset;
  25. this.dac.transform.position = position;
  26. }
  27. if (this.rigid == null)
  28. {
  29. return;
  30. }
  31. if (this.isKinematic != this.rigid.isKinematic)
  32. {
  33. this.rigid.isKinematic = this.isKinematic;
  34. }
  35. }
  36. public void SetBoss()
  37. {
  38. GameObject boss = R.Enemy.Boss;
  39. if (boss == null)
  40. {
  41. return;
  42. }
  43. this.dac = boss.GetComponent<DahalAction>();
  44. this.rigid = boss.GetComponent<Rigidbody2D>();
  45. }
  46. private DahalAction dac;
  47. private Rigidbody2D rigid;
  48. public bool refreshPos;
  49. public Vector3 offset = Vector3.zero;
  50. public bool refreshOffset;
  51. [Header("当有重力的时候要打开")]
  52. public bool isKinematic;
  53. private Vector3 lastOffset = Vector3.zero;
  54. }
  55. }