UserPrefab_21201.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. m_UserScore: cc.Label,
  5. m_Ready: cc.Node,
  6. m_Zhuang: cc.Node,
  7. m_LeaveHead: cc.Node,
  8. m_Gang: cc.Label,
  9. m_CurEffect: cc.Node,
  10. m_Ting: cc.Node,
  11. m_Trustee: cc.Node,
  12. m_Score: cc.Label,
  13. m_Flower: cc.Node,
  14. m_FlowerNumber: cc.Label,
  15. m_Flowercard: cc.Node,
  16. m_FlowerLayout: cc.Node,
  17. m_Feng: cc.Label,
  18. m_Flowerbg3: cc.SpriteFrame,
  19. m_playingNode: cc.Node,
  20. },
  21. ctor: function () {
  22. this.m_lScore = 0;
  23. },
  24. start: function () {
  25. },
  26. Init: function (View, Chair) {
  27. this.m_UserCtrl = this.node.getComponent('UserCtrl');
  28. this.m_Hook = View;
  29. this.m_ChairID = Chair;
  30. this.m_Gang.node.active = false;
  31. this.m_Ting.active = false;
  32. this.m_Trustee.active = false;
  33. this.m_Score.node.active = false;
  34. this.node.active = false;
  35. this.m_Flower.active = false;
  36. this.Reset();
  37. },
  38. Reset: function () {
  39. this.m_Ready.active = false;
  40. this.m_LeaveHead.active = false;
  41. this.m_Zhuang.active = false;
  42. this.m_Gang.node.active = false;
  43. this.m_Ting.active = false;
  44. this.m_Trustee.active = false;
  45. this.m_Score.node.active = false;
  46. this.node.active = false; //初始不显示头像
  47. this.m_Flower.active = false;
  48. this.m_Flowercard.active = false;
  49. for (let i = 0; i < this.m_FlowerLayout.childrenCount; i++) {
  50. this.m_FlowerLayout.children[i].active = false;
  51. }
  52. this.m_Feng.string = "";
  53. this.m_playingNode.active = false;
  54. },
  55. SetReady: function (show) {
  56. if (this.m_ChairID == 3) {
  57. this.m_Ready.setPosition(-100, 0);
  58. }
  59. if (this.m_ChairID == 0) {
  60. this.m_Ready.setPosition(-100, 0);
  61. }
  62. this.m_Ready.active = show;
  63. },
  64. SetUserItem: function (pUserItem) {
  65. this.m_dwUserID = pUserItem.GetUserID();
  66. this.m_pUserItem = pUserItem;
  67. this.node.getComponent('UserCtrl').SetUserByID(this.m_dwUserID);
  68. this.node.getComponent('UserCtrl').SetShowFullName(false, 5);
  69. this.SetUserScore(pUserItem.GetUserScore());
  70. },
  71. //初始化花牌
  72. ClearFlower: function (display) {
  73. this.m_Flower.active = display;
  74. this.m_FlowerNumber.string = '×0';
  75. for (let i = 0; i < this.m_FlowerLayout.childrenCount; i++) {
  76. this.m_FlowerLayout.children[i].active = false;
  77. }
  78. },
  79. UserLeave: function (pUserItem) {
  80. if (pUserItem.GetUserID() == this.m_dwUserID) {
  81. this.m_dwUserID = 0;
  82. this.node.getComponent('UserCtrl').SetUserByID(this.m_dwUserID);
  83. this.m_UserScore.string = '';
  84. this.Reset();
  85. }
  86. },
  87. //点击花
  88. OnClickFlower: function () {
  89. let flowercard = this.m_Flower.getChildByName('flowercard');
  90. if (!flowercard.active) {
  91. flowercard.active = true;
  92. setTimeout(() => {
  93. if (flowercard.active) {
  94. flowercard.active = false;
  95. }
  96. }, 2000);
  97. }
  98. },
  99. OnBtClickedUser: function () {
  100. if (this.m_dwUserID == null || this.m_dwUserID == 0) return;
  101. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  102. if (this.m_dwUserID == pGlobalUserData.dwUserID) {
  103. return
  104. }
  105. if (this.m_Hook.m_FaceExCtrl) this.m_Hook.m_FaceExCtrl.SetShowInfo(
  106. this.m_dwUserID,
  107. this.m_ChairID,
  108. this.m_pUserItem.GetUserIP());
  109. //, this.m_Hook.strAddress[this.m_ChairID]);
  110. return;
  111. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  112. // if(this.m_dwUserID == pGlobalUserData.dwUserID){
  113. // return
  114. // }
  115. if (this.m_Hook.m_FaceExCtrl) this.m_Hook.m_FaceExCtrl.SetShowInfo(
  116. this.m_dwUserID,
  117. 'IP:' + this.m_pUserItem.GetUserIP(),
  118. this.m_ChairID,
  119. this.m_Hook.strAddress[this.m_ChairID]);
  120. },
  121. UpdateScore: function (pUserItem) {
  122. if (pUserItem.GetUserID() == this.m_dwUserID) {
  123. this.SetUserScore(pUserItem.GetUserScore());
  124. }
  125. },
  126. SetUserScore: function (Score) {
  127. // 将传入的分数赋值给当前对象的m_lScore属性
  128. this.m_lScore = Score;
  129. // 将分数转换为字符串格式,并设置给m_UserScore节点的string属性,用于显示用户分数
  130. this.m_UserScore.string = Score;
  131. },
  132. SetUserFlower: function (viewID, flower, wFlowercard, displayF, displayC) {
  133. this.m_Flowercard.active = displayC;
  134. this.m_FlowerNumber.string = '×' + flower;
  135. let flowerLayout = this.m_FlowerLayout;
  136. for (let i = 0; i < wFlowercard.length; i++) {
  137. if (wFlowercard[i] > 0) {
  138. flowerLayout.getChildByName('' + wFlowercard[i]).active = true;
  139. }
  140. }
  141. setTimeout(() => {
  142. this.m_Flowercard.active = false;
  143. }, 3000);
  144. },
  145. SetFeng: function (cbQuan, cbFeng,display) {
  146. let directions = ["東", "南", "西", "北"];
  147. let cbQuanStr = directions[cbQuan];
  148. let cbFengStr = directions[cbFeng];
  149. this.m_Feng.string = cbQuanStr + " 風 " + cbFengStr;
  150. if (!display) {
  151. this.m_Feng.string = "";
  152. console.log("显示风位", cbQuan, cbFeng,display,this.m_Feng.string);
  153. }
  154. },
  155. SetShowFenganFlower: function () {
  156. // console.log("关闭显示花牌,风位");
  157. this.m_Flower.active = false;
  158. this.m_Feng.string = "";
  159. },
  160. SetCurrentAction: function (cur) {
  161. this.m_CurEffect.active = cur;
  162. },
  163. OnUserOffLine: function (bShow) {
  164. this.SetLeave(bShow);
  165. },
  166. //基准位置
  167. SetBenchmarkPos: function (nXPos, nYPos) {
  168. this.node.setPosition(nXPos, nYPos);
  169. },
  170. SetBanker: function (bBanker) {
  171. this.m_Zhuang.active = bBanker;
  172. },
  173. //离开状态
  174. SetLeave: function (bLeave) {
  175. this.m_LeaveHead.active = bLeave;
  176. },
  177. SetGang: function (cbDouble) {
  178. if (cbDouble == 0) {
  179. this.m_Gang.node.active = false;
  180. }
  181. else {
  182. this.m_Gang.node.active = true;
  183. if (cbDouble == 255) {
  184. //this.m_Gang.string = '不下嘴';
  185. }
  186. else {
  187. this.m_Gang.string = '飘' + cbDouble;
  188. }
  189. }
  190. },
  191. SetTing: function (bShow) {
  192. this.m_Ting.active = bShow;
  193. },
  194. SetTrustee: function (bShow) {
  195. this.m_Trustee.active = bShow;
  196. },
  197. SetScore: function (viewID, lScore) {
  198. this.SetUserScore(lScore);
  199. return;
  200. // this.m_Score.node.stopAllActions();
  201. this.m_Score.node.active = true;
  202. var Score = lScore;
  203. if (lScore > 0) {
  204. this.m_Score.string = lScore;//'+'+Score2Str(lScore);
  205. //this.m_Score.font = this.m_Font[0];
  206. this.m_Score.node.color = cc.color(0, 255, 0);
  207. }
  208. else {
  209. //this.m_Score.font = this.m_Font[1];
  210. this.m_Score.node.color = cc.color(255, 0, 0);
  211. this.m_Score.string = lScore; //Score2Str(lScore);
  212. }
  213. if (viewID == 1 || viewID == 3 || viewID == 2) {
  214. this.m_Score.node.setPosition(cc.v2(0, 50));
  215. }
  216. else if (viewID == 0) {
  217. this.m_Score.node.setPosition(cc.v2(70, 0));
  218. }
  219. // var sequence = cc.sequence
  220. // (
  221. // cc.moveBy(0.5, cc.v2(0, 50)),
  222. // cc.delayTime(0.5),
  223. // cc.callFunc(function () {
  224. // this.m_Score.node.active = false;
  225. // }, this)
  226. // );
  227. // this.m_Score.node.runAction(sequence);
  228. },
  229. SetFlower: function (viewID, wFlower, wFlowercard, displayF, displayC) {
  230. this.m_Flower.active = displayF;
  231. this.SetUserFlower(viewID, wFlower, wFlowercard, displayF, displayC);
  232. },
  233. SetPlaying(status) {
  234. this.m_playingNode.active = status;
  235. },
  236. });