ActionCtrl_21201.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. m_action: cc.Node,
  5. m_Niu: cc.Node,
  6. m_Ting: cc.Node,
  7. m_win: cc.Node,
  8. m_lose: cc.Node,
  9. },
  10. ctor: function() {
  11. this.m_bIsInit = false;
  12. this.m_actionAni = null;
  13. this.m_NiuDisplay = null;
  14. this.m_TingDisplay = null;
  15. this.m_winAni = null;
  16. this.m_loseAni = null;
  17. },
  18. onLoad: function () {
  19. this.Init();
  20. },
  21. Init:function() {
  22. if (this.m_bIsInit == true) {
  23. return;
  24. }
  25. this.m_bIsInit = true;
  26. if (this.m_actionAni == null) {
  27. this.m_actionAni = this.m_action.getComponent('SpineAnimationCtrl');
  28. }
  29. if (this.m_NiuDisplay == null) {
  30. this.m_NiuDisplay = this.m_Niu.getComponent('AniPrefab');
  31. this.m_NiuDisplay.Init(this);
  32. }
  33. if (this.m_TingDisplay == null) {
  34. this.m_TingDisplay = this.m_Ting.getComponent('AniPrefab');
  35. this.m_TingDisplay.Init(this);
  36. }
  37. if (this.m_winAni == null) {
  38. this.m_winAni = this.m_win.getComponent('SpineAnimationCtrl');
  39. }
  40. if (this.m_loseAni == null) {
  41. this.m_loseAni = this.m_lose.getComponent('SpineAnimationCtrl');
  42. }
  43. },
  44. SetAction:function(wAction,zimo) {
  45. this.node.active = true;
  46. if(this.m_actionAni == null) {
  47. this.Init();
  48. }
  49. let showIndex = 0
  50. if (wAction & (GameDef.WIK_GANG_FENG | GameDef.WIK_DNJ | GameDef.WIK_CAI_ZFB |
  51. GameDef.WIK_ADD_ZFB | GameDef.WIK_ADD_DNJ | GameDef.WIK_ADD_FENG)) {
  52. showIndex = 1;
  53. } else if (wAction & GameDef.WIK_LISTEN) {
  54. showIndex = 2;
  55. }
  56. let isClose = 0 == (INVALID_CHAIR | wAction);
  57. this.m_action.active = isClose;
  58. this.m_Niu.active = 1 == showIndex;
  59. this.m_Ting.active = 2 == showIndex;
  60. this.m_win.active = isClose;
  61. this.m_lose.active = isClose;
  62. if (wAction & GameDef.WIK_GANG) {
  63. this.m_actionAni.playAnimation('gang', false);
  64. } else if (wAction & (GameDef.WIK_LEFT | GameDef.WIK_CENTER | GameDef.WIK_RIGHT)) {
  65. this.m_actionAni.playAnimation('chi', false);
  66. } else if (wAction & GameDef.WIK_PENG) {
  67. this.m_actionAni.playAnimation('peng', false);
  68. } else if (wAction & GameDef.WIK_FANG_PAO) {
  69. if (zimo & GameDef.CHR_ZI_MO) {
  70. this.m_loseAni.playAnimation();
  71. } else {
  72. this.m_actionAni.playAnimation('fangpao', false);
  73. }
  74. } else if (wAction & GameDef.WIK_CHI_HU) {
  75. if (zimo & GameDef.CHR_ZI_MO) {
  76. this.m_winAni.playAnimation('zimo', false);
  77. } else {
  78. this.m_winAni.playAnimation('hu', false);
  79. }
  80. } else if (wAction & (GameDef.WIK_GANG_FENG | GameDef.WIK_DNJ| GameDef.WIK_CAI_ZFB |
  81. GameDef.WIK_ADD_ZFB | GameDef.WIK_ADD_DNJ | GameDef.WIK_ADD_FENG)) {
  82. this.m_NiuDisplay.PlayAni('Armature', 1);
  83. } else if (wAction & GameDef.WIK_LISTEN) {
  84. this.m_TingDisplay.PlayAni('Armature', 1);
  85. }
  86. },
  87. AniFinish:function() {
  88. this.node.active = false;
  89. },
  90. });