YotogiOldSkillIconDrag.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System;
  2. using System.Collections;
  3. using UnityEngine;
  4. using wf;
  5. public class YotogiOldSkillIconDrag : UIDragDropItem
  6. {
  7. public void Awake()
  8. {
  9. this.widget_ = base.GetComponent<UIWidget>();
  10. this.box_collider_ = base.GetComponent<BoxCollider>();
  11. this.button_ = base.GetComponent<UIButton>();
  12. }
  13. protected override void StartDragging()
  14. {
  15. if (UICamera.currentKey != KeyCode.Mouse0)
  16. {
  17. return;
  18. }
  19. base.StartDragging();
  20. }
  21. protected override void OnDragDropMove(Vector2 delta)
  22. {
  23. base.OnDragDropMove(delta);
  24. }
  25. protected override void OnDragDropStart()
  26. {
  27. this.back_up_depth_ = this.widget_.depth;
  28. this.backup_pos_ = base.transform.localPosition;
  29. this.widget_.depth = this.back_up_depth_ * 10;
  30. base.OnDragDropStart();
  31. }
  32. protected override void OnDragDropRelease(GameObject surface)
  33. {
  34. base.OnDragDropRelease(surface);
  35. this.widget_.depth = this.back_up_depth_;
  36. YotogiOldSkillIconDrag component = surface.GetComponent<YotogiOldSkillIconDrag>();
  37. if (component != null && surface != base.gameObject)
  38. {
  39. this.button_.PlaySoundClick();
  40. if (this.call_back_ != null)
  41. {
  42. this.call_back_(base.gameObject, surface);
  43. }
  44. this.MoveReset();
  45. component.MoveReset();
  46. }
  47. else
  48. {
  49. this.MoveReset();
  50. }
  51. }
  52. public void MoveReset()
  53. {
  54. this.box_collider_.enabled = false;
  55. Hashtable hashtable = TweenHash.EaseOutQuint(TweenHash.Type.Position, Vector3.zero, 0.3f);
  56. hashtable.Add("oncomplete", "OnMoveReset");
  57. hashtable.Add("oncompletetarget", base.gameObject);
  58. iTween.MoveTo(base.gameObject, hashtable);
  59. }
  60. public void SetOnOnDragChangeCallback(YotogiOldSkillIconDrag.OnDragChangeCallback event_function)
  61. {
  62. this.call_back_ = event_function;
  63. }
  64. public void OnMoveReset()
  65. {
  66. this.box_collider_.enabled = true;
  67. }
  68. private UIWidget widget_;
  69. private int back_up_depth_;
  70. private Vector3 backup_pos_;
  71. private BoxCollider box_collider_;
  72. private UIButton button_;
  73. private YotogiOldSkillIconDrag.OnDragChangeCallback call_back_;
  74. public delegate void OnDragChangeCallback(GameObject my_obj, GameObject target);
  75. }