UserInformationTheme.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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. this.setEventListener();
  41. },
  42. setEventListener() {
  43. // GameEvent.on(GameNotificationKey.RefreshInsertCardsInfo, this, (cardInfo,isInsert) => {
  44. // this.refreshCardsInfo(cardInfo,isInsert);
  45. // });
  46. },
  47. start () {
  48. },
  49. init() {
  50. },
  51. onDisable() {
  52. this.hideAllFunctionNode();
  53. this.refreshNoCards();
  54. this.equipCardNode.enabled = false;
  55. },
  56. // update (dt) {},
  57. changeTheme(infoTheme, hasBoss) {
  58. this.infoTheme = infoTheme;
  59. this.hasBoss = hasBoss;
  60. switch (this.infoTheme) {
  61. case UserInformationType.Mine:
  62. this.refreshThemeOfMine();
  63. break;
  64. case UserInformationType.Boss:
  65. this.refreshThemeOfBoss();
  66. break;
  67. case UserInformationType.MyArtist:
  68. this.refreshThemeOfMyArtist();
  69. break;
  70. case UserInformationType.OtherArtist:
  71. this.refreshThemeOfOtherArtist();
  72. break;
  73. case UserInformationType.ArtistFree:
  74. this.refreshThemeOfArtistFree();
  75. break;
  76. }
  77. },
  78. //隐藏所有功能按钮和节点
  79. hideAllFunctionNode() {
  80. this.intimacyNode.active = false;
  81. this.homeButton.node.active = false;
  82. this.relationButtonNode.active = false;
  83. this.interactionButtonNode.active = false;
  84. this.orderButtonNode.active = false;
  85. this.trainButtonNode.active = false;
  86. this.packButtonNode.active = false;
  87. this.equipCardNode.active = false;
  88. },
  89. refreshThemeOfMine () {
  90. this.titleRichText.string = "<outline color=#690802 width=3><b>我的信息</b></outline>";
  91. this.hideAllFunctionNode();
  92. this.packButtonNode.active = true;
  93. },
  94. refreshThemeOfBoss () {
  95. this.titleRichText.string = "<outline color=#690802 width=3><b>我的老板</b></outline>";
  96. this.relationRichText.string = "<outline color=#2a7019 width=2><b>赎身</b></outline>";
  97. cc.loader.loadRes('userInformation/userinformation_play_button', cc.SpriteFrame, (err, spriteFrame) => {
  98. this.interactionButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  99. });
  100. cc.loader.loadRes('userInformation/userinformation_revolt_button', cc.SpriteFrame, (err, spriteFrame) => {
  101. this.orderButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  102. });
  103. this.hideAllFunctionNode();
  104. this.intimacyNode.active = true;
  105. this.homeButton.node.active = true;
  106. this.interactionButtonNode.active = true;
  107. this.orderButtonNode.active = true;
  108. },
  109. refreshThemeOfMyArtist () {
  110. this.titleRichText.string = "<outline color=#690802 width=3><b>我的艺人</b></outline>";
  111. this.relationRichText.string = "<outline color=#2a7019 width=2><b>解雇</b></outline>";
  112. cc.loader.loadRes('userInformation/userinformation_pacify_button', cc.SpriteFrame, (err, spriteFrame) => {
  113. this.interactionButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  114. });
  115. cc.loader.loadRes('userInformation/userinformation_order_button', cc.SpriteFrame, (err, spriteFrame) => {
  116. this.orderButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  117. });
  118. this.hideAllFunctionNode();
  119. this.intimacyNode.active = true;
  120. this.homeButton.node.active = true;
  121. this.interactionButtonNode.active = true;
  122. this.orderButtonNode.active = true;
  123. this.trainButtonNode.active = true;
  124. },
  125. refreshThemeOfOtherArtist () {
  126. this.titleRichText.string = "<outline color=#690802 width=3><b>他人艺人</b></outline>";
  127. this.relationRichText.string = "<outline color=#2a7019 width=2><b>抢夺</b></outline>";
  128. cc.loader.loadRes('userInformation/userinformation_interact_button', cc.SpriteFrame, (err, spriteFrame) => {
  129. this.interactionButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  130. });
  131. this.hideAllFunctionNode();
  132. this.intimacyNode.active = true;
  133. this.homeButton.node.active = true;
  134. this.interactionButtonNode.active = true;
  135. },
  136. refreshThemeOfArtistFree () {
  137. this.titleRichText.string = "<outline color=#690802 width=3><b>自由身</b></outline>";
  138. this.relationRichText.string = "<outline color=#2a7019 width=2><b>签约</b></outline>";
  139. cc.loader.loadRes('userInformation/userinformation_interact_button', cc.SpriteFrame, (err, spriteFrame) => {
  140. this.interactionButtonNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  141. });
  142. this.hideAllFunctionNode();
  143. this.intimacyNode.active = true;
  144. this.homeButton.node.active = true;
  145. this.interactionButtonNode.active = true;
  146. },
  147. hideAllIntimacyNode() {
  148. this.intimacyFullNode.active = false;
  149. this.intimacyLeftNode.active = false;
  150. this.intimacyRightNode.active = false;
  151. },
  152. configIntimacyData(interactionInfo) {
  153. this.hideAllIntimacyNode();
  154. switch (interactionInfo.heart) {
  155. case UserIntimacyType.Empty:
  156. break;
  157. case UserIntimacyType.Full:
  158. this.intimacyFullNode.active = true;
  159. break;
  160. case UserIntimacyType.Left:
  161. this.intimacyLeftNode.active = true;
  162. break;
  163. case UserIntimacyType.Right:
  164. this.intimacyRightNode.active = true;
  165. break;
  166. }
  167. this.intimacyLabel.string = "亲密度:"+ interactionInfo.intimacy +"/100";
  168. },
  169. clossSuccessNode() {
  170. this.successNode.active = false;
  171. },
  172. showChangeRelationSuccess(spriteFrameString) {
  173. this.successNode.active = true;
  174. GameEvent.fire(GameNotificationKey.PlaySuccessAnimation);
  175. cc.loader.loadRes(spriteFrameString, cc.SpriteFrame, (err, spriteFrame) => {
  176. this.successTipsNode.getComponent(cc.Sprite).spriteFrame = spriteFrame;
  177. this.successTipsNode.active = true;
  178. });
  179. },
  180. showIntimacyStatus() {
  181. GameEvent.fire(GameNotificationKey.ShowInteraction);
  182. },
  183. //抢夺赎身操作按钮刷新
  184. refreshRelationNode() {
  185. switch (this.infoTheme) {
  186. case UserInformationType.Mine:
  187. this.relationButtonNode.active = false;
  188. break;
  189. default:
  190. this.relationButtonNode.active = true;
  191. break;
  192. }
  193. },
  194. //插卡节点数据显示
  195. configCardsData(list) {
  196. switch (this.infoTheme) {
  197. case UserInformationType.Mine:
  198. if (this.hasBoss == false) {
  199. this.equipCardNode.active = true;
  200. } else {
  201. this.equipCardNode.active = false;
  202. return;
  203. }
  204. break;
  205. case UserInformationType.MyArtist:
  206. this.equipCardNode.active = true;
  207. break;
  208. default:
  209. this.equipCardNode.active = false;
  210. return;
  211. }
  212. this.list = list;
  213. this.equipCardNode.enabled = true;
  214. if (list != undefined && list.length > 0) {
  215. this.refreshNoCards();
  216. let count = list.length;
  217. if (count == 1) {
  218. this.equipCardSprite1.spriteFrame = this.equipCardArray[1];
  219. this.equipCardSprite2.spriteFrame = this.equipCardArray[0];
  220. this.equipCardSprite3.spriteFrame = this.equipCardArray[0];
  221. } else if (count == 2) {
  222. this.equipCardSprite1.spriteFrame = this.equipCardArray[1];
  223. this.equipCardSprite2.spriteFrame = this.equipCardArray[1];
  224. this.equipCardSprite3.spriteFrame = this.equipCardArray[0];
  225. } else if (count >= 3) {
  226. this.equipCardSprite1.spriteFrame = this.equipCardArray[1];
  227. this.equipCardSprite2.spriteFrame = this.equipCardArray[1];
  228. this.equipCardSprite3.spriteFrame = this.equipCardArray[1];
  229. }
  230. } else {
  231. this.refreshNoCards();
  232. }
  233. },
  234. refreshNoCards() {
  235. this.equipCardSprite1.spriteFrame = this.equipCardArray[0];
  236. this.equipCardSprite2.spriteFrame = this.equipCardArray[0];
  237. this.equipCardSprite3.spriteFrame = this.equipCardArray[0];
  238. },
  239. });