SkillDisplay.ts 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. import DataMgr from "../../data/DataMgr";
  2. import { EAdType } from "../../data/Define";
  3. import ui_skillItem from "../../fgui/res/game/ui_skillItem";
  4. import { xGame } from "../../xGame";
  5. import UIAddProp from "../UIAddProp";
  6. import { UIGame } from "../UIGame";
  7. import UIGameEnd from "../UIGameEnd";
  8. import UIMain from "../UIMain";
  9. import UIMatching from "../UIMatching";
  10. import UISkill from "../UISkill";
  11. import GlobalManager from "../../utils/GlobalManager";
  12. import JSBridgeUtils from "../../utils/JSBridgeUtils";
  13. export default class SkillDisplay {
  14. public ui: ui_skillItem;
  15. //
  16. public starX: number = 0;
  17. public starY: number = 0;
  18. public data: skillData;
  19. public index: number = 0;
  20. constructor(ui: ui_skillItem, data: skillData, uiIndex) {
  21. this.ui = ui;
  22. this.data = data;
  23. this.index = uiIndex;
  24. this.initSelf();
  25. console.log('zh:SkillDisplay constructor this.skillData=', data)
  26. }
  27. initSelf() {
  28. this.ui.normalBtn.onClick(this, this.clickAddLevel);
  29. this.ui.nameTxt.text = this.data.name;
  30. this.ui.describeTxt.text = this.data.describe;
  31. this.ui.skillImg.url = xGame.common.getGameIconUrl(this.data.icon);
  32. //
  33. this.ui.startBtn.onClick(this, this.startGame);
  34. //
  35. this.updateSelf();
  36. // this.checkFinger();
  37. }
  38. // checkFinger() {
  39. // let showFinger = DataMgr.getShowFinger();
  40. // if (showFinger) {
  41. // this.ui.fingerNode.visible = false;
  42. // }
  43. // else {
  44. // this.ui.fingerNode.visible = true;
  45. // }
  46. // }
  47. updateSelf() {
  48. this.checkTry();
  49. let level = DataMgr.getBigSkillByIndex(this.index);
  50. //若满级就不能再提示等级了
  51. this.ui.c1.selectedIndex = level >= xGame.common.maxSkillLevel ? 1 : 0;
  52. }
  53. checkTry() {
  54. let index = this.index;
  55. let level = DataMgr.getBigSkillByIndex(index);
  56. if (level == null) {
  57. DataMgr.setBigSkill(index, 1, false);
  58. level = 1;
  59. }
  60. this.ui.levelTxt.text = "LV." + level;
  61. //
  62. if (this.index == DataMgr.gameData.trySkill && Laya.timer.currTimer < DataMgr.gameData.tryTime)
  63. this.ui.tryNode.visible = true;
  64. else
  65. this.ui.tryNode.visible = false;
  66. }
  67. clickAddLevel() {
  68. xGame.soundMgr.playSound(xGame.common.btnClickStr);
  69. Moyu.sendDataEvent("UpSkill", { id: this.data.index });
  70. console.log('zh:qjff_AD_for_skilldisplay_clickAddLevel')
  71. // GlobalManager.instance.registerMethod('xxxxx',this.xxxxx);
  72. // JSBridgeUtils.instance.showRewardAd('xxxxx');
  73. //需要传递参数
  74. //Laya.LocalStorage.setItem('temp_qjff_AD_for_uiGameEnd_level', level+'');
  75. // if (JSBridgeUtils.instance.showRewardAd('qjff_AD_for_skilldisplay_clickAddLevel')) {
  76. // } else {
  77. // console.log('zh:AD 失败,直接发放奖励')
  78. // this.qjff_AD_for_skilldisplay_clickAddLevel();
  79. // }
  80. if (JSBridgeUtils.instance.showInternAd('qjff_AD_for_skilldisplay_clickAddLevel')) {
  81. this.qjff_AD_for_skilldisplay_clickAddLevel();
  82. } else {
  83. console.log('zh:AD 失败,直接发放奖励')
  84. this.qjff_AD_for_skilldisplay_clickAddLevel();
  85. }
  86. // //看视频升级
  87. // Moyu.showVideoAd(() => {
  88. // DataMgr.setBigSkill(this.data.index, 1);
  89. // this.updateSelf();
  90. // xGame.common.upSkillLevel = true;
  91. // }, EAdType.upSkill)
  92. }
  93. public qjff_AD_for_skilldisplay_clickAddLevel() {
  94. DataMgr.setBigSkill(this.data.index, 1);
  95. this.updateSelf();
  96. xGame.common.upSkillLevel = true;
  97. }
  98. startGame() {
  99. //如果是关公刀法就提示返回
  100. if (this.data.index == 3) {
  101. alert('Coming soon!')
  102. return;
  103. }
  104. xGame.soundMgr.playSound(xGame.common.btnClickStr);
  105. let needCoin = xGame.common.bigMoveNeedCoin;
  106. xGame.common.passAwardCoin = 2000;
  107. let guide = DataMgr.getSkillGuide();
  108. console.log('zh:startGame guide=' + guide)
  109. xGame.common.temSelfLevel = 0;
  110. if (guide == 0) {
  111. needCoin = 0;
  112. xGame.common.temSelfLevel = 100;
  113. }
  114. if (DataMgr.coinEnough(needCoin)) {
  115. DataMgr.setCoin(-needCoin);
  116. xGame.common.curPlayerSkillType = this.index;
  117. if (guide == 0) xGame.common.curPlayerSkillType = 0;
  118. //开始大招模式游戏
  119. xGame.uiMgr.Show(UIGame);
  120. xGame.uiMgr.Hide(UIMain);
  121. xGame.uiMgr.Show(UIMatching, () => {
  122. xGame.common.gameUI.ui.alpha = 1;
  123. xGame.common.gameUI.startGame();
  124. xGame.uiMgr.Hide(UISkill);
  125. });
  126. }
  127. else {
  128. xGame.uiMgr.Show(UIAddProp, 0);
  129. Moyu.sendDataEvent("AddCoinVideo");
  130. }
  131. }
  132. }
  133. interface skillData {
  134. name: string;
  135. icon: string;
  136. describe: string;
  137. index: number;
  138. }