UserInformationTheme.js 9.5 KB

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