RaioItem.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. var Global = require("Global");
  2. var GameProtocol = require("RaioGameProtocol");
  3. cc.Class({
  4. extends: cc.Component,
  5. editor: {
  6. menu: 'Game/Raio/Item'
  7. },
  8. properties: {
  9. normalBG: cc.Node,
  10. normalAni: sp.Skeleton,
  11. aniNode: cc.Node,
  12. _value: -1,
  13. _lineCount: 0,
  14. _bSpecial: false,
  15. },
  16. setValue (_val, spineData, _bSpe) {
  17. this._value = _val;
  18. this._bSpecial = _bSpe;
  19. this.normalAni.skeletonData = spineData;
  20. this._bNewOppr = false;
  21. this.node.scale = 1;
  22. if(this._bSpecial) {
  23. this.node.scale = 1.1;
  24. }
  25. this.showRolling();
  26. },
  27. getValue() {
  28. return this._value;
  29. },
  30. resetCount() {
  31. this._lineCount = 0;
  32. this.showNormal();
  33. },
  34. addCount() {
  35. this._lineCount++;
  36. },
  37. setCount(_val) {
  38. this._lineCount = _val;
  39. },
  40. getCount() {
  41. return this._lineCount;
  42. },
  43. showRolling() {
  44. this.normalBG.stopAllActions();
  45. this.aniNode.active = false;
  46. this.normalAni.clearTracks();
  47. this.normalAni.setAnimation(0, 'a0', false);
  48. },
  49. showNormal() {
  50. if(this._bSpecial) {return;}
  51. this.normalBG.stopAllActions();
  52. this.aniNode.active = false;
  53. this.normalAni.clearTracks();
  54. this.normalAni.setAnimation(0, 'a1', true);
  55. },
  56. resetShow() {
  57. this.node.opacity = 255;
  58. // this.showNormal();
  59. },
  60. resetCashShow() {
  61. if(!this._bSpecial) {
  62. this.showNormal();
  63. return;
  64. }
  65. this._bNewOppr = false;
  66. this.aniNode.active = false;
  67. this.normalBG.stopAllActions();
  68. this.normalAni.clearTracks();
  69. this.normalAni.setAnimation(0, "a1", true);
  70. },
  71. //cash中级动画
  72. showLightAni(bPrizes) {
  73. if(!this._bSpecial) {
  74. this.showNormal();
  75. return;
  76. }
  77. this._bNewOppr = true;
  78. this.aniNode.active = false;
  79. this.normalBG.stopAllActions();
  80. this.normalAni.clearTracks();
  81. this.normalAni.setAnimation(0, "a2", false);
  82. // if(!bPrizes)
  83. // this.normalAni.addAnimation(0, "a0", true);
  84. },
  85. showNewPrizes(bPrizes) {
  86. if(!this._bSpecial) {return;}
  87. if(this._bNewOppr) {
  88. Global.print("showNewPrizes")
  89. this._bNewOppr = false;
  90. this.aniNode.active = false;
  91. this.normalBG.stopAllActions();
  92. this.normalAni.clearTracks();
  93. if(bPrizes) {
  94. this.normalAni.setAnimation(0, "a3", false);
  95. this.normalAni.addAnimation(0, "a1", true);
  96. }else{
  97. this.normalAni.setAnimation(0, "a1", true);
  98. }
  99. // this.normalAni.setAnimation(0, "a3", false);
  100. // this.normalAni.addAnimation(0, "a1", true);
  101. }
  102. },
  103. showEndPrizes() {
  104. if(!this._bSpecial) {return;}
  105. this.aniNode.active = true;
  106. let ani = this.aniNode.getComponent(sp.Skeleton);
  107. ani.clearTracks();
  108. ani.setAnimation(0, 'a3', false);
  109. this.normalBG.stopAllActions();
  110. this.normalAni.clearTracks();
  111. this.normalAni.setAnimation(0, "a3", false);
  112. this.normalAni.addAnimation(0, "a4", true);
  113. },
  114. goCashPrizes(bShow) {
  115. if(bShow) {
  116. this.node.opacity = 255;
  117. }else{
  118. this.node.opacity = 85;
  119. }
  120. },
  121. showNotPrizes() {
  122. this.node.opacity = 85;
  123. if(this._bSpecial) {
  124. this.normalAni.clearTracks();
  125. this.normalAni.setAnimation(0, "a4", false);
  126. }
  127. },
  128. showPrizes() {
  129. if(this._lineCount <= 0) {
  130. this.showNotPrizes();
  131. return;
  132. }
  133. this.node.opacity = 255;
  134. this.aniNode.active = false;
  135. this.normalBG.stopAllActions();
  136. this.normalAni.clearTracks();
  137. this.normalAni.setAnimation(0, "a2", false);
  138. this.normalAni.addAnimation(0, "a1", true);
  139. },
  140. playEffect(effName, needStop = false) {
  141. if(needStop)
  142. cc.vv.audioMgr.stopAllEffects();
  143. cc.vv.audioMgr.playSFX(effName);
  144. },
  145. // update (dt) {},
  146. });