UserIntimacyInfo.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. switch (interactionInfo.heart) {
  52. case UserIntimacyType.Empty:
  53. cc.loader.loadRes('interaction/interaction_none_icon', cc.SpriteFrame, (err, spriteFrame) => {
  54. this.interactionLeftIcon.spriteFrame = spriteFrame;
  55. });
  56. cc.loader.loadRes('interaction/interaction_none_icon', cc.SpriteFrame, (err, spriteFrame) => {
  57. this.interactionRightIcon.spriteFrame = spriteFrame;
  58. });
  59. break;
  60. case UserIntimacyType.Full:
  61. this.intimacyFullNode.active = true;
  62. cc.loader.loadRes('interaction/interaction_ok_icon', cc.SpriteFrame, (err, spriteFrame) => {
  63. this.interactionLeftIcon.spriteFrame = spriteFrame;
  64. });
  65. cc.loader.loadRes('interaction/interaction_ok_icon', cc.SpriteFrame, (err, spriteFrame) => {
  66. this.interactionRightIcon.spriteFrame = spriteFrame;
  67. });
  68. break;
  69. case UserIntimacyType.Left:
  70. this.intimacyLeftNode.active = true;
  71. cc.loader.loadRes('interaction/interaction_ok_icon', cc.SpriteFrame, (err, spriteFrame) => {
  72. this.interactionLeftIcon.spriteFrame = spriteFrame;
  73. });
  74. cc.loader.loadRes('interaction/interaction_none_icon', cc.SpriteFrame, (err, spriteFrame) => {
  75. this.interactionRightIcon.spriteFrame = spriteFrame;
  76. });
  77. break;
  78. case UserIntimacyType.Right:
  79. this.intimacyRightNode.active = true;
  80. cc.loader.loadRes('interaction/interaction_none_icon', cc.SpriteFrame, (err, spriteFrame) => {
  81. this.interactionLeftIcon.spriteFrame = spriteFrame;
  82. });
  83. cc.loader.loadRes('interaction/interaction_ok_icon', cc.SpriteFrame, (err, spriteFrame) => {
  84. this.interactionRightIcon.spriteFrame = spriteFrame;
  85. });
  86. break;
  87. }
  88. if (interactionInfo.me) {
  89. var genderIcon = 'intimacy_female';
  90. if (interactionInfo.me.gender == 1) {
  91. genderIcon = 'intimacy_male';
  92. }
  93. var nickString = "<img src='" + genderIcon + "' /> " + interactionInfo.me.nick.slice(0,5);
  94. this.leftNicknameRichText.string = nickString;
  95. }
  96. if (interactionInfo.other) {
  97. var genderIcon = 'intimacy_female';
  98. if (interactionInfo.other.gender == 1) {
  99. genderIcon = 'intimacy_male';
  100. }
  101. var nickString = "<img src='" + genderIcon + "' /> " + interactionInfo.other.nick.slice(0,5);
  102. this.rightNicknameRichText.string = nickString;
  103. }
  104. },
  105. configIntimacyInfoShow(isCommon) {
  106. var titleString = "你们今天还没有进行互动~\n一起互动额外增加<color=#E90000> 5 </>点亲密度~";
  107. if (isCommon == true) {
  108. titleString = "你们今天还没有进行互动~";
  109. }
  110. switch (this.interactionInfo.heart) {
  111. case UserIntimacyType.Empty:
  112. this.okButton.node.active = false;
  113. this.remindButton.node.active = true;
  114. break;
  115. case UserIntimacyType.Full:
  116. this.intimacyLabel.node.active = true;
  117. titleString = "你和你的好友都完成了今天的互动\n获得额外的<color=#E90000> 5 </>点亲密度~";
  118. if (isCommon) {
  119. titleString = "你和你的好友都完成了今天的互动";
  120. }
  121. this.okButton.node.active = true;
  122. this.remindButton.node.active = false;
  123. break;
  124. case UserIntimacyType.Left:
  125. titleString = "和你的好友一起互动\n额外增加<color=#E90000> 5 </>点亲密度~";
  126. if (isCommon) {
  127. titleString = "和你的好友一起互动";
  128. }
  129. this.okButton.node.active = false;
  130. this.remindButton.node.active = true;
  131. case UserIntimacyType.Right:
  132. titleString = "和你的好友一起互动\n额外增加<color=#E90000> 5 </>点亲密度~";
  133. if (isCommon) {
  134. titleString = "和你的好友一起互动";
  135. }
  136. this.okButton.node.active = true;
  137. this.remindButton.node.active = false;
  138. break;
  139. }
  140. this.titleRichText.string = titleString;
  141. },
  142. configIntimacyInfoShare(isCommon) {
  143. var textString = "邀请你的好友一起互动额外增加<color=#E90000> 5 </>点亲密度~";
  144. if (isCommon == true) {
  145. this.intimacyRichText.node.active = false;
  146. textString = "邀请你的好友一起互动";
  147. } else {
  148. this.intimacyRichText.node.active = true;
  149. }
  150. // switch (this.interactionInfo.heart) {
  151. // case UserIntimacyType.Empty:
  152. // break;
  153. // case UserIntimacyType.Full:
  154. // titleString = "你和你的好友都完成了今天的互动\n获得额外的<color=#E90000> 5 </>点亲密度~";
  155. // if (isCommon) {
  156. // titleString = "你和你的好友都完成了今天的互动";
  157. // }
  158. // break;
  159. // case UserIntimacyType.Left:
  160. // titleString = "和你的好友一起互动\n额外增加<color=#E90000> 5 </>点亲密度~";
  161. // if (isCommon) {
  162. // titleString = "和你的好友一起互动";
  163. // }
  164. // case UserIntimacyType.Right:
  165. // titleString = "和你的好友一起互动\n额外增加<color=#E90000> 5 </>点亲密度~";
  166. // if (isCommon) {
  167. // titleString = "和你的好友一起互动";
  168. // }
  169. // break;
  170. // }
  171. this.inviteRichText.string = textString;
  172. },
  173. // update (dt) {},
  174. });