BRTPPlayer.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. var GamePlayer = require("GamePlayer");
  2. var Define = require("Define");
  3. var Global = require("Global");
  4. var UIHelper = require("UIHelper");
  5. import { CServerItem } from 'CServerItem'
  6. import ScenceManager from 'HNScenceManager'
  7. cc.Class({
  8. extends: GamePlayer,
  9. //extends: cc.Component,
  10. properties: {
  11. sprHeadIcon:cc.Sprite, //头像
  12. sprVipIcon:cc.Sprite, // VIP框
  13. btnHead:cc.Button,
  14. sprEmptyHeadIcon:cc.Sprite,
  15. labScore:cc.Label, //分数
  16. labName:cc.Label, //昵称
  17. //sprHostFlag:cc.Sprite, //房主标记
  18. sprOffineFlag:cc.Sprite, //离线标记
  19. //sprZhuangFlag:cc.Sprite, //庄标记
  20. spriteFrame:{ //头像图片
  21. default:null,
  22. type:cc.SpriteFrame
  23. },
  24. iIndex:-1,
  25. _CurGameScene:null,
  26. _myScore:0,
  27. },
  28. // LIFE-CYCLE CALLBACKS:
  29. onLoad: function() {
  30. this._isGameEnd = false;
  31. this.sprVipIcon.sizeMode = cc.Sprite.SizeMode.CUSTOM;
  32. this.sprVipIcon.node.width = 120;
  33. this.sprVipIcon.node.height = 120;
  34. this.sprVipIcon.node.scale = 1;
  35. },
  36. init: function(index) {
  37. },
  38. playerEnter: function() {
  39. this.labName.node.active = true;
  40. this.sprEmptyHeadIcon.node.active = false;
  41. this.sprHeadIcon.node.active = true;
  42. this.btnHead.node.userID = this.getUserID();
  43. this.btnHead.node.gameID = this.getGameID();
  44. this._CurGameScene = ScenceManager.Instance().getGameComponent();
  45. },
  46. playerLeave:function() {
  47. this.node.removeFromParent();
  48. },
  49. upPlayerState: function() {
  50. // this.setReady(this.getUserStatus() == Define.US_READY);
  51. this.setOffline(this.getUserStatus() == Define.US_OFFLINE);
  52. if (this.getUserStatus() == Define.US_OFFLINE) {
  53. //置灰
  54. // this.sprHeadIcon.node.color = cc.Color.GRAY;
  55. }
  56. else {
  57. //复原
  58. this.sprHeadIcon.node.color = cc.Color.WHITE;
  59. }
  60. },
  61. upPlayerInfo: function() {
  62. if (this.getNickName() != "") {
  63. var str = this.getNickName();
  64. this.labName.string = Global.subStr(str, 15);
  65. }
  66. // vip 头像框
  67. let vipID = this.getVIPLevel();
  68. let node = this.sprVipIcon;
  69. Global.print("upPlayerInfo")
  70. if(vipID >= 4 && vipID <= 7) {
  71. // if(this.iIndex == 0) {
  72. node.getComponent(cc.Sprite).spriteFrame = cc.vv.globalUserInfo.getVIPSpriteFrameByFaceID(vipID);
  73. node.active = true;
  74. // }
  75. }else{
  76. node.active = false;
  77. }
  78. if (CServerItem.get().mGameServer.ServerType == 1)
  79. {
  80. this.setScore(this.getUserScore());
  81. }
  82. },
  83. getnickName: function()
  84. {
  85. return this.labName.string
  86. },
  87. upPlayerHead: function() {
  88. if (this.getHeadHttp() != "") {
  89. // 设置头像
  90. this.sprHeadIcon.getComponent("urlSpriteFrame").loadAvatar(this.getHeadHttp(),null, {width:100, height:100});
  91. } else {
  92. this.sprHeadIcon.spriteFrame = this.spriteFrame;
  93. this.sprHeadIcon.node.width = 100;
  94. this.sprHeadIcon.node.height = 100;
  95. }
  96. let vipID = this.getVIPLevel();
  97. let node = this.sprVipIcon;
  98. Global.print("upPlayerHead")
  99. if(vipID >= 4 && vipID <= 7) {
  100. // if(this.iIndex == 0) {
  101. node.getComponent(cc.Sprite).spriteFrame = cc.vv.globalUserInfo.getVIPSpriteFrameByFaceID(vipID);
  102. node.active = true;
  103. // }
  104. }else{
  105. node.active = false;
  106. }
  107. },
  108. getHeadIcon: function(ret) {
  109. if(ret)
  110. {
  111. return this.sprHeadIcon.spriteFrame;
  112. }
  113. if (this.getHeadHttp() != "") {
  114. return this.sprHeadIcon.spriteFrame;
  115. }
  116. return null;
  117. },
  118. setScore: function(score) {
  119. this._myScore = score;
  120. var strScore = this.changeScore(Global.formatString2Score(score));
  121. this.labScore.string = strScore;
  122. },
  123. getScore: function() {
  124. return this._myScore;
  125. },
  126. setHost: function(isHost) {
  127. //this.sprHostFlag.node.active = isHost;
  128. },
  129. setZhuang: function(isZhuang) {
  130. //this.sprZhuangFlag.node.active = isZhuang;
  131. },
  132. isZhuang: function(isZhuang) {
  133. //return this.sprZhuangFlag.node.active;
  134. },
  135. setStatusHu: function(isHu) {
  136. this.node.getChildByName("Status_Hu").active = isHu;
  137. },
  138. // setMa: function(isMa) {
  139. // this.sprMaFlag.node.active = isMa;
  140. // },
  141. setOffline: function(isOffline) {
  142. // this.sprOffineFlag.node.active = isOffline;
  143. },
  144. setReady: function(isReady) {
  145. // this.sprReadyFlag.node.active = isReady;
  146. },
  147. resetSeatPos: function(pos) {
  148. // this.node.getChildByName("PlayerHead").position = pos;
  149. },
  150. playMoveAction: function(pos) {
  151. var moveto = cc.moveTo(1,pos);
  152. this.node.getChildByName("PlayerHead").runAction(moveto);
  153. },
  154. startGameNoTime: function(pos) {
  155. this.node.getChildByName("PlayerHead").setPosition(pos);
  156. },
  157. start () {
  158. },
  159. });