UserInformationTheme.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. var {UserInformationType, UserInformationRelateOptType, GameNotificationKey, UserIntimacyType} = require('../utils/GameEnum');
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. titleNode: cc.Node,
  6. titleRichText: cc.RichText,
  7. homeButton: cc.Button,
  8. //抢夺、赎身相关操作按钮
  9. relationButtonNode: cc.Node,
  10. relationRichText: cc.RichText,
  11. //安抚按钮
  12. interactionButtonNode: cc.Node,
  13. //命令、反抗按钮
  14. orderButtonNode: cc.Node,
  15. //培养按钮
  16. trainButtonNode: cc.Node,
  17. //抢夺、赎身、签约成功提示
  18. successNode: cc.Node,
  19. successTipsNode: cc.Node,
  20. //背包按钮节点
  21. packButtonNode: cc.Node,
  22. //亲密度显示
  23. intimacyNode: cc.Node,
  24. intimacyFullNode: cc.Node,
  25. intimacyLeftNode: cc.Node,
  26. intimacyRightNode: cc.Node,
  27. intimacyLabel: cc.Label,
  28. //插卡按钮节点
  29. equipCardNode: cc.Node,
  30. equipCardSprite1: cc.Sprite,
  31. equipCardSprite2: cc.Sprite,
  32. equipCardSprite3: cc.Sprite,
  33. equipCardArray: [cc.SpriteFrame],
  34. },
  35. // LIFE-CYCLE CALLBACKS:
  36. onLoad () {
  37. this.titleSprite = this.titleNode.getComponent(cc.Sprite);
  38. this.successNode.on('touchstart',this.clossSuccessNode,this);
  39. this.intimacyNode.on('touchend', this.showIntimacyStatus, this);
  40. },
  41. start () {
  42. },
  43. init() {
  44. },
  45. onDisable() {
  46. this.hideAllFunctionNode();
  47. this.refreshNoCards();
  48. },
  49. // update (dt) {},
  50. changeTheme(infoRole, hasBoss) {
  51. this.infoRole = infoRole;
  52. this.hasBoss = hasBoss;
  53. switch (this.infoRole) {
  54. case UserInformationType.Mine:
  55. this.refreshThemeOfMine();
  56. break;
  57. case UserInformationType.Boss:
  58. this.refreshThemeOfBoss();
  59. break;
  60. case UserInformationType.MyArtist:
  61. this.refreshThemeOfMyArtist();
  62. break;
  63. case UserInformationType.OtherArtist:
  64. this.refreshThemeOfOtherArtist();
  65. break;
  66. case UserInformationType.ArtistFree:
  67. this.refreshThemeOfArtistFree();
  68. break;
  69. }
  70. },
  71. //隐藏所有功能按钮和节点
  72. hideAllFunctionNode() {
  73. this.intimacyNode.active = false;
  74. this.homeButton.node.active = false;
  75. this.relationButtonNode.active = false;
  76. this.interactionButtonNode.active = false;
  77. this.orderButtonNode.active = false;
  78. this.trainButtonNode.active = false;
  79. this.packButtonNode.active = false;
  80. this.equipCardNode.active = false;
  81. },
  82. refreshThemeOfMine () {
  83. this.titleRichText.string = "<outline color=#690802 width=3><b>我的信息</b></outline>";
  84. this.hideAllFunctionNode();
  85. this.packButtonNode.active = true;
  86. },
  87. refreshThemeOfBoss () {
  88. this.titleRichText.string = "<outline color=#690802 width=3><b>我的老板</b></outline>";
  89. this.relationRichText.string = "<outline color=#2a7019 width=2><b>赎身</b></outline>";
  90. cc.loader.loadRes('userInformation/userinformation_play_button', cc.SpriteFrame, (err, spriteFrame) => {
  91. this.interactionButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  92. });
  93. cc.loader.loadRes('userInformation/userinformation_revolt_button', cc.SpriteFrame, (err, spriteFrame) => {
  94. this.orderButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  95. });
  96. this.hideAllFunctionNode();
  97. this.intimacyNode.active = true;
  98. this.homeButton.node.active = true;
  99. this.interactionButtonNode.active = true;
  100. this.orderButtonNode.active = true;
  101. },
  102. refreshThemeOfMyArtist () {
  103. this.titleRichText.string = "<outline color=#690802 width=3><b>我的艺人</b></outline>";
  104. this.relationRichText.string = "<outline color=#2a7019 width=2><b>解雇</b></outline>";
  105. cc.loader.loadRes('userInformation/userinformation_pacify_button', cc.SpriteFrame, (err, spriteFrame) => {
  106. this.interactionButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  107. });
  108. cc.loader.loadRes('userInformation/userinformation_order_button', cc.SpriteFrame, (err, spriteFrame) => {
  109. this.orderButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  110. });
  111. this.hideAllFunctionNode();
  112. this.intimacyNode.active = true;
  113. this.homeButton.node.active = true;
  114. this.interactionButtonNode.active = true;
  115. this.orderButtonNode.active = true;
  116. this.trainButtonNode.active = true;
  117. },
  118. refreshThemeOfOtherArtist () {
  119. this.titleRichText.string = "<outline color=#690802 width=3><b>他人艺人</b></outline>";
  120. this.relationRichText.string = "<outline color=#2a7019 width=2><b>抢夺</b></outline>";
  121. cc.loader.loadRes('userInformation/userinformation_interact_button', cc.SpriteFrame, (err, spriteFrame) => {
  122. this.interactionButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  123. });
  124. this.hideAllFunctionNode();
  125. this.intimacyNode.active = true;
  126. this.homeButton.node.active = true;
  127. this.interactionButtonNode.active = true;
  128. },
  129. refreshThemeOfArtistFree () {
  130. this.titleRichText.string = "<outline color=#690802 width=3><b>自由身</b></outline>";
  131. this.relationRichText.string = "<outline color=#2a7019 width=2><b>签约</b></outline>";
  132. cc.loader.loadRes('userInformation/userinformation_interact_button', cc.SpriteFrame, (err, spriteFrame) => {
  133. this.interactionButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  134. });
  135. this.hideAllFunctionNode();
  136. this.intimacyNode.active = true;
  137. this.homeButton.node.active = true;
  138. this.interactionButtonNode.active = true;
  139. },
  140. hideAllIntimacyNode() {
  141. this.intimacyFullNode.active = false;
  142. this.intimacyLeftNode.active = false;
  143. this.intimacyRightNode.active = false;
  144. },
  145. configIntimacyData(interactionInfo) {
  146. this.hideAllIntimacyNode();
  147. switch (interactionInfo.heart) {
  148. case UserIntimacyType.Empty:
  149. break;
  150. case UserIntimacyType.Full:
  151. this.intimacyFullNode.active = true;
  152. break;
  153. case UserIntimacyType.Left:
  154. this.intimacyLeftNode.active = true;
  155. break;
  156. case UserIntimacyType.Right:
  157. this.intimacyRightNode.active = true;
  158. break;
  159. }
  160. this.intimacyLabel.string = "亲密度:"+ interactionInfo.intimacy +"/100";
  161. },
  162. clossSuccessNode() {
  163. this.successNode.active = false;
  164. },
  165. showChangeRelationSuccess(spriteFrameString) {
  166. this.successNode.active = true;
  167. GameEvent.fire(GameNotificationKey.PlaySuccessAnimation);
  168. cc.loader.loadRes(spriteFrameString, cc.SpriteFrame, (err, spriteFrame) => {
  169. this.successTipsNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  170. this.successTipsNode.active = true;
  171. });
  172. },
  173. showIntimacyStatus() {
  174. GameEvent.fire(GameNotificationKey.ShowInteraction);
  175. },
  176. //抢夺赎身操作按钮刷新
  177. refreshRelationNode() {
  178. switch (this.infoRole) {
  179. case UserInformationType.Mine:
  180. this.relationButtonNode.active = false;
  181. break;
  182. default:
  183. this.relationButtonNode.active = true;
  184. break;
  185. }
  186. },
  187. //插卡节点数据显示
  188. configCardsData(list) {
  189. switch (this.infoRole) {
  190. case UserInformationType.Mine:
  191. if (this.hasBoss == false) {
  192. this.equipCardNode.active = true;
  193. } else {
  194. this.equipCardNode.active = false;
  195. return;
  196. }
  197. break;
  198. case UserInformationType.MyArtist:
  199. this.equipCardNode.active = true;
  200. break;
  201. default:
  202. this.equipCardNode.active = false;
  203. return;
  204. }
  205. this.list = list;
  206. if (list != undefined && list.length > 0) {
  207. this.refreshNoCards();
  208. let count = list.length;
  209. if (count == 1) {
  210. this.equipCardSprite1.spriteFrame = this.equipCardArray[1];
  211. this.equipCardSprite2.spriteFrame = this.equipCardArray[0];
  212. this.equipCardSprite3.spriteFrame = this.equipCardArray[0];
  213. } else if (count == 2) {
  214. this.equipCardSprite1.spriteFrame = this.equipCardArray[1];
  215. this.equipCardSprite2.spriteFrame = this.equipCardArray[1];
  216. this.equipCardSprite3.spriteFrame = this.equipCardArray[0];
  217. } else if (count >= 3) {
  218. this.equipCardSprite1.spriteFrame = this.equipCardArray[1];
  219. this.equipCardSprite2.spriteFrame = this.equipCardArray[1];
  220. this.equipCardSprite3.spriteFrame = this.equipCardArray[1];
  221. }
  222. } else {
  223. this.refreshNoCards();
  224. }
  225. },
  226. refreshNoCards() {
  227. this.equipCardSprite1.spriteFrame = this.equipCardArray[0];
  228. this.equipCardSprite2.spriteFrame = this.equipCardArray[0];
  229. this.equipCardSprite3.spriteFrame = this.equipCardArray[0];
  230. },
  231. });