BattleRoomPlayer.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. var HeadIcon = require("HeadIcon")
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. imageAdd: {
  6. default: null,
  7. type: cc.Sprite,
  8. serializable: true,
  9. },
  10. imageGold: {
  11. default: null,
  12. type: cc.Sprite,
  13. serializable: true,
  14. },
  15. nodeStatusMask: {
  16. default: null,
  17. type: cc.Node,
  18. serializable: true,
  19. },
  20. textGold: {
  21. default: null,
  22. type: cc.Label,
  23. serializable: true,
  24. },
  25. textName: {
  26. default: null,
  27. type: cc.Label,
  28. serializable: true,
  29. },
  30. headIcon: {
  31. default: null,
  32. type: HeadIcon,
  33. serializable: true,
  34. },
  35. },
  36. resetData(data) {
  37. this.data = data;
  38. this.refreshView();
  39. },
  40. refreshView() {
  41. let showNull = this.data == null
  42. this.imageAdd.node.active = showNull;
  43. this.textName.node.active = !showNull;
  44. this.imageGold.node.active = !showNull;
  45. this.textGold.node.active = !showNull;
  46. this.headIcon.node.active = !showNull;
  47. this.nodeStatusMask.active = !showNull;
  48. if (showNull) {
  49. return;
  50. }
  51. this.textName.string = this.data.playerInfo.nickname
  52. this.headIcon.setPlayerInfo(this.data.playerInfo);
  53. },
  54. setPrice(boxsPrice) {
  55. this.textGold.string = G.PlayerUtils.getPrice(boxsPrice);
  56. },
  57. setActive(isShow) {
  58. this.node.active = isShow;
  59. },
  60. });