UISkill.ts 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. import DataMgr from "../data/DataMgr";
  2. import UIBase from "../fgui/core/UIBase";
  3. import ui_skillItem from "../fgui/res/game/ui_skillItem";
  4. import ui_UISkill from "../fgui/res/game/ui_UISkill";
  5. import { xGame } from "../xGame";
  6. import MoneyNode from "./item/MoneyNode";
  7. import SkillDisplay from "./item/SkillDisplay";
  8. import { UIGame } from "./UIGame";
  9. import UIMain from "./UIMain";
  10. import UIMatching from "./UIMatching";
  11. export default class UISkill extends UIBase {
  12. public ui: ui_UISkill;
  13. public skillData = [];
  14. public moneyNode: MoneyNode;
  15. public constructor() {
  16. super();
  17. }
  18. protected onConstructor(): void {
  19. this.ui = ui_UISkill.createInstance();
  20. this.contentPane = this.ui;
  21. this.isEject = false;
  22. //
  23. this.moneyNode = new MoneyNode(this.ui.moneyNode);
  24. //
  25. this.initSkillData();
  26. console.log('zh:aaaaaa1111111111')
  27. this.addUIClick(this.ui.closeNode.closeBtn, this.returnUIMain);
  28. this.ui.skillNode.skillList.itemRenderer = Laya.Handler.create(this, this.updateSkillItem, null, false);
  29. console.log('zh:aaaaaa22222222')
  30. //
  31. this.displayList = [];
  32. //this.ui.skillNode.skillList.numItems = 4; OLD
  33. this.ui.skillNode.skillList.numItems = 3;
  34. //
  35. this.addUIClick(this.ui, this.interuptSecretary);
  36. this.addUIClick(this.ui.guideNode.guideBtn, this.enterGuideLevel);
  37. this.ui.talkNode.visible = false;
  38. if (Moyu.isKs)
  39. this.ui.closeNode.closeBtn.x += 100;
  40. }
  41. public show(): void {
  42. super.show();
  43. this.playSecretaryIdle();
  44. this.moneyNode.ui.c1.selectedIndex = 1;
  45. //
  46. Laya.timer.clearAll(this);
  47. xGame.soundMgr.playSound("s_start");
  48. xGame.common.showGirlTalkPop(13, this.ui.talkNode, this.ui.talkNode.womanTxt);
  49. //
  50. let guide = DataMgr.getSkillGuide();
  51. this.ui.guideNode.visible = guide == 0;
  52. let item = this.getSkillItemByUIIndex(0);
  53. if (guide == 0) {
  54. item.ui.c1.selectedIndex = 1;
  55. }
  56. else {
  57. item.ui.c1.selectedIndex = 0;
  58. }
  59. this.ui.guideNode.guideBtn.visible = guide == 0;
  60. //
  61. for (let index = 0; index < this.displayList.length; index++) {
  62. this.displayList[index].checkTry();
  63. }
  64. }
  65. getSkillItemByUIIndex(cur) {
  66. for (let index = 0; index < this.displayList.length; index++) {
  67. if (this.displayList[index].index == cur) {
  68. return this.displayList[index];
  69. }
  70. }
  71. }
  72. enterGuideLevel() {
  73. let item = this.getSkillItemByUIIndex(0);
  74. item.startGame();
  75. if (DataMgr.getNewUser()) Moyu.sendDataEvent("gameStart1");
  76. }
  77. initSkillData() {
  78. // let nameList = ["从天而降", "横扫千军", "冰冻杆法"];
  79. // let iconList = ["gf_jn1", "gf_jn2", "gf_jn4"];
  80. // let describeList = [
  81. // "跳杆击球后,球高高跃起,砸在桌面上,直接打进额外1颗球",
  82. // "普通击球后,球杆向随机方向—扫,将杆子范围内1颗可击打球扫入球袋",
  83. // "我方击球后,在场地上将随机1颗球冻结,敌方无法击打冰冻球,且其他球碰到冰冻球会弹开"
  84. // ];
  85. this.skillData = [];
  86. let nameList = xGame.common.skillNameList;
  87. let iconList = xGame.common.skillIconList;
  88. let describeList = [
  89. "A strike from the sky, like a meteor tearing through the heavens—delivering a thunderous blow! ",
  90. "A break shot surging like a raging tide—powerful, explosive, and straight into the pocket!",//击球后球高高跃起召唤神龙,利用神龙之力令额外1颗球移动起来产生撞击
  91. "The power of frost descends—freezing the flow and taking full control of the game!"
  92. ];
  93. console.log('zh:initSkillData 111111111')
  94. //
  95. let data: any;
  96. for (let index = 0; index < nameList.length; index++) {
  97. data = {};
  98. data.name = nameList[index];
  99. data.icon = iconList[index];
  100. data.describe = describeList[index];
  101. data.index = index;
  102. this.skillData.push(data);
  103. }
  104. }
  105. displayList: SkillDisplay[];
  106. private updateSkillItem(index: number, target: ui_skillItem) {
  107. if (this.displayList[index] == null) {
  108. let uiIndex;
  109. switch (index) {
  110. case 0:
  111. uiIndex = 1;
  112. break;
  113. case 1:
  114. uiIndex = 0;
  115. break;
  116. case 2:
  117. uiIndex = 2;
  118. break;
  119. case 3:
  120. uiIndex = 3;
  121. break;
  122. default:
  123. break;
  124. }
  125. let temp = new SkillDisplay(target, this.skillData[uiIndex], uiIndex);
  126. this.displayList.push(temp);
  127. }
  128. }
  129. playSecretaryIdle() {
  130. let parent = this.ui.secretary.displayObject;
  131. parent.destroyChildren();
  132. let xx = this.ui.secretary.width / 2
  133. let yy = this.ui.secretary.height;
  134. let scale = xGame.common.getSecretaryScale();
  135. let data = { x: xx, y: yy, scaleX: scale, scaleY: scale };
  136. // xGame.common.secretary.play(data, 1, true, parent);
  137. xGame.common.secretary.play(data, 0, true, parent);
  138. }
  139. returnUIMain() {
  140. this.hide();
  141. xGame.common.stopGirlPop(this.ui.talkNode)
  142. //
  143. xGame.uiMgr.Show(UIMain);
  144. }
  145. interuptSecretary() {
  146. Laya.timer.clearAll(this);
  147. this.playSecretaryRandomSound();
  148. }
  149. //主界面和技能选择界面45-60秒未操作随机播放秘书音效
  150. playSecretaryRandomSound() {
  151. if (this.isHide) return;
  152. let time = xGame.common.randomNum(45000, 60000);
  153. Laya.timer.once(time, this, () => {
  154. if (this.isHide) return;
  155. let index = xGame.common.randomNum(4, 7);
  156. xGame.soundMgr.playSound("s_main0" + index);
  157. //
  158. let words = 1;
  159. switch (index) {
  160. case 4:
  161. words = 5;
  162. break;
  163. case 5:
  164. words = 3;
  165. break;
  166. case 6:
  167. words = 6;
  168. break;
  169. case 7:
  170. words = 7;
  171. break;
  172. default:
  173. break;
  174. }
  175. xGame.common.showGirlTalkPop(words, this.ui.talkNode, this.ui.talkNode.womanTxt);
  176. //
  177. this.playSecretaryRandomSound();
  178. })
  179. }
  180. }
  181. UISkill.uiName = "UISkill";