123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- import DataMgr from "../../data/DataMgr";
- import { EAdType } from "../../data/Define";
- import ui_skillItem from "../../fgui/res/game/ui_skillItem";
- import { xGame } from "../../xGame";
- import UIAddProp from "../UIAddProp";
- import { UIGame } from "../UIGame";
- import UIGameEnd from "../UIGameEnd";
- import UIMain from "../UIMain";
- import UIMatching from "../UIMatching";
- import UISkill from "../UISkill";
- import GlobalManager from "../../utils/GlobalManager";
- import JSBridgeUtils from "../../utils/JSBridgeUtils";
- export default class SkillDisplay {
- public ui: ui_skillItem;
- //
- public starX: number = 0;
- public starY: number = 0;
- public data: skillData;
- public index: number = 0;
- constructor(ui: ui_skillItem, data: skillData, uiIndex) {
- this.ui = ui;
- this.data = data;
- this.index = uiIndex;
- this.initSelf();
- console.log('zh:SkillDisplay constructor this.skillData=', data)
- }
- initSelf() {
- this.ui.normalBtn.onClick(this, this.clickAddLevel);
- this.ui.nameTxt.text = this.data.name;
- this.ui.describeTxt.text = this.data.describe;
- this.ui.skillImg.url = xGame.common.getGameIconUrl(this.data.icon);
- //
- this.ui.startBtn.onClick(this, this.startGame);
- //
- this.updateSelf();
- // this.checkFinger();
- }
- // checkFinger() {
- // let showFinger = DataMgr.getShowFinger();
- // if (showFinger) {
- // this.ui.fingerNode.visible = false;
- // }
- // else {
- // this.ui.fingerNode.visible = true;
- // }
- // }
- updateSelf() {
- this.checkTry();
- let level = DataMgr.getBigSkillByIndex(this.index);
- //若满级就不能再提示等级了
- this.ui.c1.selectedIndex = level >= xGame.common.maxSkillLevel ? 1 : 0;
- }
- checkTry() {
- let index = this.index;
- let level = DataMgr.getBigSkillByIndex(index);
- if (level == null) {
- DataMgr.setBigSkill(index, 1, false);
- level = 1;
- }
- this.ui.levelTxt.text = "LV." + level;
- //
- if (this.index == DataMgr.gameData.trySkill && Laya.timer.currTimer < DataMgr.gameData.tryTime)
- this.ui.tryNode.visible = true;
- else
- this.ui.tryNode.visible = false;
- }
- clickAddLevel() {
- xGame.soundMgr.playSound(xGame.common.btnClickStr);
- Moyu.sendDataEvent("UpSkill", { id: this.data.index });
- console.log('zh:qjff_AD_for_skilldisplay_clickAddLevel')
- // GlobalManager.instance.registerMethod('xxxxx',this.xxxxx);
- // JSBridgeUtils.instance.showRewardAd('xxxxx');
- //需要传递参数
- //Laya.LocalStorage.setItem('temp_qjff_AD_for_uiGameEnd_level', level+'');
- // if (JSBridgeUtils.instance.showRewardAd('qjff_AD_for_skilldisplay_clickAddLevel')) {
- // } else {
- // console.log('zh:AD 失败,直接发放奖励')
- // this.qjff_AD_for_skilldisplay_clickAddLevel();
- // }
- if (JSBridgeUtils.instance.showInternAd('qjff_AD_for_skilldisplay_clickAddLevel')) {
- this.qjff_AD_for_skilldisplay_clickAddLevel();
- } else {
- console.log('zh:AD 失败,直接发放奖励')
- this.qjff_AD_for_skilldisplay_clickAddLevel();
- }
- // //看视频升级
- // Moyu.showVideoAd(() => {
- // DataMgr.setBigSkill(this.data.index, 1);
- // this.updateSelf();
- // xGame.common.upSkillLevel = true;
- // }, EAdType.upSkill)
- }
- public qjff_AD_for_skilldisplay_clickAddLevel() {
- DataMgr.setBigSkill(this.data.index, 1);
- this.updateSelf();
- xGame.common.upSkillLevel = true;
- }
- startGame() {
- //如果是关公刀法就提示返回
- if (this.data.index == 3) {
- alert('Coming soon!')
- return;
- }
- xGame.soundMgr.playSound(xGame.common.btnClickStr);
- let needCoin = xGame.common.bigMoveNeedCoin;
- xGame.common.passAwardCoin = 2000;
- let guide = DataMgr.getSkillGuide();
- console.log('zh:startGame guide=' + guide)
- xGame.common.temSelfLevel = 0;
- if (guide == 0) {
- needCoin = 0;
- xGame.common.temSelfLevel = 100;
- }
- if (DataMgr.coinEnough(needCoin)) {
- DataMgr.setCoin(-needCoin);
- xGame.common.curPlayerSkillType = this.index;
- if (guide == 0) xGame.common.curPlayerSkillType = 0;
- //开始大招模式游戏
- xGame.uiMgr.Show(UIGame);
- xGame.uiMgr.Hide(UIMain);
- xGame.uiMgr.Show(UIMatching, () => {
- xGame.common.gameUI.ui.alpha = 1;
- xGame.common.gameUI.startGame();
- xGame.uiMgr.Hide(UISkill);
- });
- }
- else {
- xGame.uiMgr.Show(UIAddProp, 0);
- Moyu.sendDataEvent("AddCoinVideo");
- }
- }
- }
- interface skillData {
- name: string;
- icon: string;
- describe: string;
- index: number;
- }
|