UserInformationTheme.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. // LIFE-CYCLE CALLBACKS:
  30. onLoad () {
  31. this.titleSprite = this.titleNode.getComponent(cc.Sprite);
  32. this.successNode.on('touchstart',this.clossSuccessNode,this);
  33. this.intimacyNode.on('touchend', this.showIntimacyStatus, this);
  34. },
  35. start () {
  36. },
  37. init(information) {
  38. this.information = information;
  39. },
  40. onDisable() {
  41. this.relationButtonNode.active = false;
  42. this.interactionButtonNode.active = false;
  43. this.orderButtonNode.active = false;
  44. this.homeButton.node.active = false;
  45. this.successNode.active = false;
  46. this.successTipsNode.active = false;
  47. this.packButtonNode.active = false;
  48. this.intimacyNode.active = false;
  49. },
  50. // update (dt) {},
  51. changeTheme(infoTheme) {
  52. this.infoTheme = infoTheme;
  53. switch (this.infoTheme) {
  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. refreshThemeOfMine () {
  72. this.titleRichText.string = "<outline color=#690802 width=3><b>我的信息</b></outline>";
  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 = true;
  80. },
  81. refreshThemeOfBoss () {
  82. this.titleRichText.string = "<outline color=#690802 width=3><b>我的老板</b></outline>";
  83. this.relationRichText.string = "<outline color=#2a7019 width=2><b>赎身</b></outline>";
  84. cc.loader.loadRes('userInformation/userinformation_play_button', cc.SpriteFrame, (err, spriteFrame) => {
  85. this.interactionButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  86. });
  87. cc.loader.loadRes('userInformation/userinformation_revolt_button', cc.SpriteFrame, (err, spriteFrame) => {
  88. this.orderButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  89. });
  90. this.intimacyNode.active = true;
  91. this.homeButton.node.active = true;
  92. this.relationButtonNode.active = true;
  93. this.interactionButtonNode.active = true;
  94. this.orderButtonNode.active = true;
  95. this.trainButtonNode.active = false;
  96. this.packButtonNode.active = false;
  97. },
  98. refreshThemeOfMyArtist () {
  99. this.titleRichText.string = "<outline color=#690802 width=3><b>我的艺人</b></outline>";
  100. this.relationRichText.string = "<outline color=#2a7019 width=2><b>解雇</b></outline>";
  101. cc.loader.loadRes('userInformation/userinformation_pacify_button', cc.SpriteFrame, (err, spriteFrame) => {
  102. this.interactionButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  103. });
  104. cc.loader.loadRes('userInformation/userinformation_order_button', cc.SpriteFrame, (err, spriteFrame) => {
  105. this.orderButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  106. });
  107. this.intimacyNode.active = true;
  108. this.homeButton.node.active = true;
  109. this.relationButtonNode.active = false;
  110. this.interactionButtonNode.active = true;
  111. this.orderButtonNode.active = true;
  112. this.trainButtonNode.active = true;
  113. this.packButtonNode.active = false;
  114. },
  115. refreshThemeOfOtherArtist () {
  116. this.titleRichText.string = "<outline color=#690802 width=3><b>他人艺人</b></outline>";
  117. this.relationRichText.string = "<outline color=#2a7019 width=2><b>抢夺</b></outline>";
  118. cc.loader.loadRes('userInformation/userinformation_interact_button', cc.SpriteFrame, (err, spriteFrame) => {
  119. this.interactionButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  120. });
  121. this.intimacyNode.active = true;
  122. this.homeButton.node.active = true;
  123. this.relationButtonNode.active = true;
  124. this.interactionButtonNode.active = true;
  125. this.orderButtonNode.active = false;
  126. this.trainButtonNode.active = false;
  127. this.packButtonNode.active = false;
  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.intimacyNode.active = true;
  136. this.homeButton.node.active = true;
  137. this.relationButtonNode.active = true;
  138. this.interactionButtonNode.active = true;
  139. this.orderButtonNode.active = false;
  140. this.trainButtonNode.active = false;
  141. this.packButtonNode.active = false;
  142. },
  143. hideAllIntimacyNode() {
  144. this.intimacyFullNode.active = false;
  145. this.intimacyLeftNode.active = false;
  146. this.intimacyRightNode.active = false;
  147. },
  148. configIntimacyData(interactionInfo) {
  149. this.hideAllIntimacyNode();
  150. switch (interactionInfo.heart) {
  151. case UserIntimacyType.Empty:
  152. break;
  153. case UserIntimacyType.Full:
  154. this.intimacyFullNode.active = true;
  155. break;
  156. case UserIntimacyType.Left:
  157. this.intimacyLeftNode.active = true;
  158. break;
  159. case UserIntimacyType.Right:
  160. this.intimacyRightNode.active = true;
  161. break;
  162. }
  163. this.intimacyLabel.string = "亲密度:"+ interactionInfo.intimacy +"/100";
  164. },
  165. clossSuccessNode() {
  166. this.successNode.active = false;
  167. },
  168. showChangeRelationSuccess(spriteFrameString) {
  169. this.successNode.active = true;
  170. Global.GameEvent.fire(GameNotificationKey.PlaySuccessAnimation);
  171. cc.loader.loadRes(spriteFrameString, cc.SpriteFrame, (err, spriteFrame) => {
  172. this.successTipsNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  173. this.successTipsNode.active = true;
  174. });
  175. },
  176. showIntimacyStatus() {
  177. Global.GameEvent.fire(GameNotificationKey.ShowInteraction);
  178. }
  179. });