UserIntimacyInfo.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. var { UserIntimacyType } = require('../utils/GameEnum');
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. titleRichText: cc.RichText,
  6. intimacyFullNode: cc.Node,
  7. intimacyLeftNode: cc.Node,
  8. intimacyRightNode: cc.Node,
  9. intimacyLabel: cc.Label,
  10. userLeftNode: cc.Node,
  11. leftNicknameRichText: cc.RichText,
  12. interactionLeftIcon: cc.Sprite,
  13. userRightNode: cc.Node,
  14. rightNicknameRichText: cc.RichText,
  15. interactionRightIcon: cc.Sprite,
  16. //亲密度显示按钮
  17. okButton: cc.Button,
  18. remindButton: cc.Button,
  19. //互动成功
  20. intimacyRichText: cc.RichText,
  21. inviteRichText: cc.RichText,
  22. },
  23. // LIFE-CYCLE CALLBACKS:
  24. // onLoad () {},
  25. start () {
  26. },
  27. init() {
  28. },
  29. hideAllIntimacyNode() {
  30. this.intimacyFullNode.active = false;
  31. this.intimacyLeftNode.active = false;
  32. this.intimacyRightNode.active = false;
  33. if (this.intimacyLabel) {
  34. this.intimacyLabel.node.active = false;
  35. }
  36. },
  37. /**
  38. * 亲密度信息显示
  39. * @param {Object} interactionInfo 亲密度相关
  40. * @param {Boolean} isInfo 是否亲密度显示
  41. * @param {Boolean} isCommon 是否普通的互动
  42. */
  43. configIntimacyInfo(interactionInfo, isInfo, isCommon) {
  44. this.hideAllIntimacyNode();
  45. this.interactionInfo = interactionInfo;
  46. if (isInfo) {
  47. this.configIntimacyInfoShow(isCommon);
  48. } else {
  49. this.configIntimacyInfoShare(isCommon);
  50. }
  51. let leftIcon = (err, spriteFrame) => {
  52. this.interactionLeftIcon.spriteFrame = spriteFrame;
  53. };
  54. let rightIcon = (err, spriteFrame) => {
  55. this.interactionRightIcon.spriteFrame = spriteFrame;
  56. };
  57. switch (interactionInfo.heart) {
  58. case UserIntimacyType.Empty:
  59. cc.loader.loadRes('interaction/interaction_none_icon', cc.SpriteFrame, leftIcon);
  60. cc.loader.loadRes('interaction/interaction_none_icon', cc.SpriteFrame, rightIcon);
  61. break;
  62. case UserIntimacyType.Full:
  63. this.intimacyFullNode.active = true;
  64. cc.loader.loadRes('interaction/interaction_ok_icon', cc.SpriteFrame, leftIcon);
  65. cc.loader.loadRes('interaction/interaction_ok_icon', cc.SpriteFrame, rightIcon);
  66. break;
  67. case UserIntimacyType.Left:
  68. this.intimacyLeftNode.active = true;
  69. cc.loader.loadRes('interaction/interaction_ok_icon', cc.SpriteFrame, leftIcon);
  70. cc.loader.loadRes('interaction/interaction_none_icon', cc.SpriteFrame, rightIcon);
  71. break;
  72. case UserIntimacyType.Right:
  73. this.intimacyRightNode.active = true;
  74. cc.loader.loadRes('interaction/interaction_none_icon', cc.SpriteFrame, leftIcon);
  75. cc.loader.loadRes('interaction/interaction_ok_icon', cc.SpriteFrame, rightIcon);
  76. break;
  77. }
  78. if (interactionInfo.me) {
  79. var genderIcon = 'intimacy_female';
  80. if (interactionInfo.me.gender == 1) {
  81. genderIcon = 'intimacy_male';
  82. }
  83. var nickString = "<img src='" + genderIcon + "' /> " + interactionInfo.me.nick.slice(0,5);
  84. this.leftNicknameRichText.string = nickString;
  85. }
  86. if (interactionInfo.other) {
  87. var genderIcon = 'intimacy_female';
  88. if (interactionInfo.other.gender == 1) {
  89. genderIcon = 'intimacy_male';
  90. }
  91. var nickString = "<img src='" + genderIcon + "' /> " + interactionInfo.other.nick.slice(0,5);
  92. this.rightNicknameRichText.string = nickString;
  93. }
  94. },
  95. configIntimacyInfoShow(isCommon) {
  96. var titleString = "你们今天还没有进行互动~\n一起互动额外增加<color=#E90000> 5 </>点亲密度~";
  97. if (isCommon == true) {
  98. titleString = "你们今天还没有进行互动~";
  99. }
  100. switch (this.interactionInfo.heart) {
  101. case UserIntimacyType.Empty:
  102. this.okButton.node.active = false;
  103. this.remindButton.node.active = true;
  104. break;
  105. case UserIntimacyType.Full:
  106. this.intimacyLabel.node.active = true;
  107. titleString = "你和你的好友都完成了今天的互动\n获得额外的<color=#E90000> 5 </>点亲密度~";
  108. if (isCommon) {
  109. titleString = "你和你的好友都完成了今天的互动";
  110. }
  111. this.okButton.node.active = true;
  112. this.remindButton.node.active = false;
  113. break;
  114. case UserIntimacyType.Left:
  115. titleString = "和你的好友一起互动\n额外增加<color=#E90000> 5 </>点亲密度~";
  116. if (isCommon) {
  117. titleString = "和你的好友一起互动";
  118. }
  119. this.okButton.node.active = false;
  120. this.remindButton.node.active = true;
  121. break;
  122. case UserIntimacyType.Right:
  123. titleString = "和你的好友一起互动\n额外增加<color=#E90000> 5 </>点亲密度~";
  124. if (isCommon) {
  125. titleString = "和你的好友一起互动";
  126. }
  127. this.okButton.node.active = true;
  128. this.remindButton.node.active = false;
  129. break;
  130. }
  131. this.titleRichText.string = titleString;
  132. },
  133. configIntimacyInfoShare(isCommon) {
  134. // var textString = "邀请你的好友一起互动额外增加<color=#E90000> 5 </>点亲密度~";
  135. if (isCommon == true) {
  136. this.intimacyRichText.node.active = false;
  137. // textString = "邀请你的好友一起互动";
  138. } else {
  139. this.intimacyRichText.node.active = true;
  140. }
  141. // this.inviteRichText.string = textString;
  142. },
  143. // update (dt) {},
  144. });