|
@@ -1,4 +1,4 @@
|
|
|
-import LayerPanel, {UrlInfo} from "../../Common/manage/Layer/LayerPanel";
|
|
|
+import LayerPanel, { UrlInfo } from "../../Common/manage/Layer/LayerPanel";
|
|
|
import Tools from "../../Common/Tools";
|
|
|
import EndView from "./EndView";
|
|
|
import Text from "./logic/common/text";
|
|
@@ -8,7 +8,7 @@ import CacheMgr from "../../Common/manage/CacheMgr";
|
|
|
import AudioMgr from "../../Common/manage/AudioMgr";
|
|
|
import LoadMgr from "../../Common/manage/LoadMgr";
|
|
|
import Constant from "../../Common/Constant";
|
|
|
-import PanelMgr, {Layer} from "../../Common/manage/PanelMgr";
|
|
|
+import PanelMgr, { Layer } from "../../Common/manage/PanelMgr";
|
|
|
import tween = cc.tween;
|
|
|
import ShowConfig from "../../Common/ShowConfig";
|
|
|
import Global from "../../Common/Global";
|
|
@@ -16,7 +16,17 @@ import QgBanner from "../../Common/manage/Api/QgBanner";
|
|
|
import Emit from "../../Common/manage/Emit/Emit";
|
|
|
import EmitData from "../../Common/manage/Emit/EmitData";
|
|
|
|
|
|
-const {ccclass, property} = cc._decorator;
|
|
|
+
|
|
|
+
|
|
|
+import AESUtil from "../../AESUtil"
|
|
|
+import ATSDK from "../../AnyThinkAds/ATJSSDK";
|
|
|
+import ATRewardedVideoSDK from "../../AnyThinkAds/ATRewardedVideoJSSDK";
|
|
|
+import AAJS2 from "../../ATAndroidJS2";
|
|
|
+import GlobalManager from '../../GlobalManager';
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+const { ccclass, property } = cc._decorator;
|
|
|
|
|
|
@ccclass
|
|
|
export default class GameView extends LayerPanel {
|
|
@@ -95,7 +105,7 @@ export default class GameView extends LayerPanel {
|
|
|
private _lineDatas: lineData[] = [null]
|
|
|
private _hintData: lineData = null
|
|
|
private blockPool: cc.NodePool = null
|
|
|
- private nextBlockInfo: nextBlockInfo [] = []
|
|
|
+ private nextBlockInfo: nextBlockInfo[] = []
|
|
|
private touchEndFlag: boolean = false
|
|
|
private hardLevel: number = 1
|
|
|
private score: number = 0
|
|
@@ -269,7 +279,7 @@ export default class GameView extends LayerPanel {
|
|
|
|
|
|
public show(param: any) {
|
|
|
//todo 逻辑
|
|
|
-
|
|
|
+ console.log('zh:GameView show')
|
|
|
ShowConfig.show('gameConfig').then((res) => {
|
|
|
if (Global.config.gameConfig.bannerShow == 1) {
|
|
|
QgBanner.showBanner();
|
|
@@ -279,10 +289,189 @@ export default class GameView extends LayerPanel {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ public onLoad(): void {
|
|
|
+ console.log('zh:gameView.ts onload')
|
|
|
+ this.initAd();
|
|
|
+ this.initAdForPage();
|
|
|
+
|
|
|
+ // for (let i = 0; i < 5; i++) {
|
|
|
+ // // let th = this;
|
|
|
+ // setTimeout(() => {
|
|
|
+ // console.log('zh:gameView.ts 测试测试=' + i)
|
|
|
+ // // th.node.emit('env_playAdEnd', 'Hello,开发发放shop道具吧');
|
|
|
+ // GlobalManager.instance.callMethod('env_playAdEnd');
|
|
|
+ // }, 5000);
|
|
|
+ // }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ initAd() {
|
|
|
+ let adKey = "zh_ad_type"
|
|
|
+ cc.sys.localStorage.setItem(adKey, "");
|
|
|
+
|
|
|
+ if (cc.sys.os != cc.sys.OS_ANDROID) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ let placementId = AAJS2.getPlacementId();
|
|
|
+ let deviceId = AAJS2.getDeviceUserId();
|
|
|
+ var setting = {};
|
|
|
+ setting[ATRewardedVideoSDK.userIdKey] = deviceId;
|
|
|
+ ATRewardedVideoSDK.loadRewardedVideo(placementId, setting);
|
|
|
+ //console.log('zh:bbb222')
|
|
|
+
|
|
|
+ var customPlacementId = "";
|
|
|
+ if (cc.sys.os === cc.sys.OS_IOS) {
|
|
|
+ customPlacementId = placementId;
|
|
|
+ } else if (cc.sys.os === cc.sys.OS_ANDROID) {
|
|
|
+ customPlacementId = placementId;
|
|
|
+ }
|
|
|
+ // 初始化SDK
|
|
|
+ ATSDK.initSDK("h674584cd6f096", "a010d11a5190a026e6b1fe54f86365f18");//正式的,
|
|
|
+ // ATSDK.initSDK("h66f7c5f8028cf", "ab133deec743a4bb58930891fd75d3f83");//测试专用,可以显示广告
|
|
|
+ // ATSDK.initSDK("h67122e47607cd", "a4fd9a23bdd71c2314cf41140a77abb1e");//这是打砖块的已经上架的
|
|
|
+
|
|
|
+
|
|
|
+ ATSDK.setLogDebug(true);//zh:diy
|
|
|
+ var GDPRLevel = ATSDK.getGDPRLevel();
|
|
|
+
|
|
|
+
|
|
|
+ // 针对欧盟地区初始化时做的处理,按需求打开,不在欧盟地区发布的不用使用。
|
|
|
+ ATSDK.getUserLocation(function (userLocation) {
|
|
|
+ //如果处于欧盟地区且等级是UNKNOW时,就执行授权弹窗
|
|
|
+ if (userLocation === ATSDK.kATUserLocationInEU) {
|
|
|
+ if (ATSDK.getGDPRLevel() === ATSDK.UNKNOWN) {
|
|
|
+ ATSDK.showGDPRAuth();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ ATRewardedVideoSDK.setAdListener(this);
|
|
|
+
|
|
|
+ if (cc.sys.os === cc.sys.OS_ANDROID) {
|
|
|
+ setTimeout(() => {
|
|
|
+ var allInfo = AAJS2.allInfo();
|
|
|
+ ATSDK.printLog("zh:allInfo=" + allInfo);
|
|
|
+ let key = "US2%*c3lv8sYkUe(!e-6g$E*RJg)dzn@";
|
|
|
+ let iv = "Jn0.aWsOu$y-Dbqb";
|
|
|
+ let data = { data: AESUtil.AESencrypt(allInfo, key, iv) };
|
|
|
+ ATSDK.printLog("zh:allInfo-jm=" + JSON.stringify(data));
|
|
|
+ console.log('zh:ad_allInfo', data);
|
|
|
+ AAJS2.makePostRequestWithXhr(JSON.stringify(data));
|
|
|
+ }, 200);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ initAdForPage() {
|
|
|
+ if (cc.sys.os === cc.sys.OS_ANDROID) {
|
|
|
+ let deviceId = AAJS2.getDeviceUserId();
|
|
|
+ console.log("zh:checkstatus:", ATRewardedVideoSDK.checkAdStatus(AAJS2.getPlacementId()));
|
|
|
+ var setting = {};
|
|
|
+ setting[ATRewardedVideoSDK.userIdKey] = deviceId;
|
|
|
+ ATRewardedVideoSDK.loadRewardedVideo(AAJS2.getPlacementId(), setting);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //#region "AD 监听start"
|
|
|
+
|
|
|
+
|
|
|
+ onRewardedVideoAdLoaded(placementId) {
|
|
|
+ ATSDK.printLog("zh:AnyThinkRewardedVideoDemo::onRewardedVideoAdLoaded(" + placementId + ")");
|
|
|
+ }
|
|
|
+
|
|
|
+ onRewardedVideoAdFailed(placementId, errorInfo) {
|
|
|
+ ATSDK.printLog("zh:AnyThinkRewardedVideoDemo::onRewardedVideoAdFailed(" + placementId + ", " + errorInfo + ")");
|
|
|
+ }
|
|
|
+
|
|
|
+ onRewardedVideoAdPlayStart(placementId, callbackInfo) {
|
|
|
+ ATSDK.printLog("zh:AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayStart(" + placementId + ", " + callbackInfo + ")");
|
|
|
+ let deviceId = AAJS2.getDeviceUserId();
|
|
|
+ var setting = {};
|
|
|
+ setting[ATRewardedVideoSDK.userIdKey] = deviceId;
|
|
|
+ ATRewardedVideoSDK.loadRewardedVideo(AAJS2.getPlacementId(), setting);
|
|
|
+ }
|
|
|
+
|
|
|
+ onRewardedVideoAdPlayEnd(placementId, callbackInfo) {
|
|
|
+ ATSDK.printLog("zh:AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayEnd(" + placementId + ", " + callbackInfo + ")");
|
|
|
+
|
|
|
+
|
|
|
+ console.log('zh: ad over 开始发送事件11s')
|
|
|
+ //this.node.emit("handleCustomEvent");
|
|
|
+ this.handleCustomEvent()
|
|
|
+ //cc.sys.localStorage.setItem('zh_ad_type', 'getHammer');//获取锤子
|
|
|
+ console.log('zh: ad over 开始发送事件11e')
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ onRewardedVideoAdPlayFailed(placementId, errorInfo, callbackInfo) {
|
|
|
+ ATSDK.printLog("zh:AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayFailed(" + placementId + ", " + errorInfo + ", " + callbackInfo + ")");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ onRewardedVideoAdClosed(placementId, callbackInfo) {
|
|
|
+ ATSDK.printLog("zh:AnyThinkRewardedVideoDemo::onRewardedVideoAdClosed(" + placementId + ", " + callbackInfo + ")");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ onRewardedVideoAdPlayClicked(placementId, callbackInfo) {
|
|
|
+ ATSDK.printLog("zh:AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayClicked(" + placementId + ", " + callbackInfo + ")");
|
|
|
+ }
|
|
|
+
|
|
|
+ onReward(placementId, callbackInfo) {
|
|
|
+ ATSDK.printLog("zh:AnyThinkRewardedVideoDemo::onReward(" + placementId + ", " + callbackInfo + ")");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ //#endregion "AD 监听end"
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * AD播放完毕\close的事件处理
|
|
|
+ */
|
|
|
+ handleCustomEvent() {
|
|
|
+ let that = this;
|
|
|
+ console.log('zh:AD 展示完毕')
|
|
|
+ let adKey = "zh_ad_type"
|
|
|
+ let idx = cc.sys.localStorage.getItem(adKey);//getHammer ,
|
|
|
+ console.log('zh:onAdOverEve idx =' + idx)
|
|
|
+ switch (idx) {
|
|
|
+ case 'getHammer':
|
|
|
+ console.log('zh:开发发放道具:一个锤子!')
|
|
|
+ this.event_adPlayEndForHammer();
|
|
|
+ break;
|
|
|
+ case 'getSprite':
|
|
|
+ ////失败后重新开始
|
|
|
+ console.log('zh:开发发放道具:一个魔鬼精灵!')
|
|
|
+ this.event_adPlayEndForHndle_sprite();
|
|
|
+ //发送事件。。。。todo: 重新开始游戏
|
|
|
+ //this.node.emit('env_playAdEnd', 'Hello,你好');
|
|
|
+
|
|
|
+ // 调用A页面的方法
|
|
|
+ // GlobalManager.instance.callMethod('startGameForFailAD', 'value1', 'value2');
|
|
|
+ // GlobalManager.instance.callMethod('startGameForFailAD');
|
|
|
+
|
|
|
+ break;
|
|
|
+ case 'pubShop':
|
|
|
+ console.log('zh:开始通知下属 发放shop道具!')
|
|
|
+ //that.node.emit('env_playAdEnd', 'Hello,开发发放shop道具吧');
|
|
|
+ GlobalManager.instance.callMethod('env_playAdEnd');
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ console.log('zh:未知的道具类型AD' + idx)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public hide() {
|
|
|
|
|
|
if (Global.config.gameConfig.nativeConfig.type == 2) {
|
|
|
- Emit.instance().emit(EmitData.CLOSE_NATIVE) ;
|
|
|
+ Emit.instance().emit(EmitData.CLOSE_NATIVE);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -325,7 +514,7 @@ export default class GameView extends LayerPanel {
|
|
|
//判断是否需要新手提示
|
|
|
if (!CacheMgr.isNeedHint || gameConfig.hint_data.length == 0) {
|
|
|
let blankNum = Tools.getRandom(gameConfig.bottomBlankMin, gameConfig.bottomBlankMax + 1)
|
|
|
- let blankColumns: number [] = []
|
|
|
+ let blankColumns: number[] = []
|
|
|
while (true) {
|
|
|
let column = Tools.getRandom(1, 9)
|
|
|
let flag = Tools.JudgeValueInArr(column, blankColumns)
|
|
@@ -343,8 +532,8 @@ export default class GameView extends LayerPanel {
|
|
|
}
|
|
|
}
|
|
|
//获取数组中连续的一段
|
|
|
- let allContinueArr: number [] [] = []
|
|
|
- let continueArr: number [] = []
|
|
|
+ let allContinueArr: number[][] = []
|
|
|
+ let continueArr: number[] = []
|
|
|
for (let i = 1; i < 9; i++) {
|
|
|
if (Tools.JudgeValueInArr(i, blankColumns)) {
|
|
|
if (continueArr.length > 0) {
|
|
@@ -374,7 +563,7 @@ export default class GameView extends LayerPanel {
|
|
|
}
|
|
|
|
|
|
//根据一个位置数组定义这一组方块类型
|
|
|
- private definitionBlockType(arr: number []): nextBlockInfo[] {
|
|
|
+ private definitionBlockType(arr: number[]): nextBlockInfo[] {
|
|
|
let blockInfos: nextBlockInfo[] = []
|
|
|
while (true) {
|
|
|
let length = arr.length
|
|
@@ -384,7 +573,7 @@ export default class GameView extends LayerPanel {
|
|
|
if (length >= 4) {
|
|
|
if (Tools.checkPer(gameConfig.grade_of_difficulty_config[this.hardLevel].probability_4)) {
|
|
|
blockInfos.push({
|
|
|
- column: arr [0],
|
|
|
+ column: arr[0],
|
|
|
num: 4,
|
|
|
})
|
|
|
arr.splice(0, 4)
|
|
@@ -445,6 +634,7 @@ export default class GameView extends LayerPanel {
|
|
|
|
|
|
//创建最底层的一套方块
|
|
|
private makeBottomBlock(isStart = false) {
|
|
|
+ console.log('zh:GameView 创建最底层的一套方块')
|
|
|
if (this.nextBlockInfo.length == 0) {
|
|
|
this.readyMakeBottomBlock()
|
|
|
}
|
|
@@ -498,7 +688,7 @@ export default class GameView extends LayerPanel {
|
|
|
n.node.y = -gameConfig.gridSize //如果y = 0 的话,就没有动画做了
|
|
|
let p = new Promise((resolve, reject) => {
|
|
|
cc.tween(n.node)
|
|
|
- .to(gameConfig.upTime, {y: 0}, {easing: 'cubicInOut'})
|
|
|
+ .to(gameConfig.upTime, { y: 0 }, { easing: 'cubicInOut' })
|
|
|
.call(() => {
|
|
|
resolve(true)
|
|
|
})
|
|
@@ -670,7 +860,7 @@ export default class GameView extends LayerPanel {
|
|
|
private downLine(line: number): any[] {
|
|
|
let result = []
|
|
|
let data = this._lineDatas[line]
|
|
|
- let needChange: any [] = []
|
|
|
+ let needChange: any[] = []
|
|
|
for (let i = 0; i < data.blockNodes.length; i++) {
|
|
|
//循环需要下拉行的 所有方块
|
|
|
let blockInfo = data.blockNodes[i]
|
|
@@ -700,9 +890,9 @@ export default class GameView extends LayerPanel {
|
|
|
let p = new Promise((resolve, reject) => {
|
|
|
let n = blockInfo.node
|
|
|
cc.tween(n)
|
|
|
- .to(gameConfig.downTime * 0.6, {y: -gameConfig.gridSize * (toLine - line)}, {easing: 'cubicInOut'})
|
|
|
- .by(gameConfig.downTime * 0.2, {y: 10},)
|
|
|
- .by(gameConfig.downTime * 0.2, {y: -10},)
|
|
|
+ .to(gameConfig.downTime * 0.6, { y: -gameConfig.gridSize * (toLine - line) }, { easing: 'cubicInOut' })
|
|
|
+ .by(gameConfig.downTime * 0.2, { y: 10 },)
|
|
|
+ .by(gameConfig.downTime * 0.2, { y: -10 },)
|
|
|
.union()
|
|
|
.call(() => {
|
|
|
n.parent = this._lineDatas[toLine].line
|
|
@@ -764,8 +954,8 @@ export default class GameView extends LayerPanel {
|
|
|
if (allCover.length >= 8) {
|
|
|
result = new Promise((resolve, reject) => {
|
|
|
cc.tween(this._lineDatas[line].line)
|
|
|
- .by(gameConfig.lineShake / 2, {x: -15},)
|
|
|
- .by(gameConfig.lineShake / 2, {x: 15},)
|
|
|
+ .by(gameConfig.lineShake / 2, { x: -15 },)
|
|
|
+ .by(gameConfig.lineShake / 2, { x: 15 },)
|
|
|
// .by(gameConfig.lineShake / 30, {y: 2.5}, {easing: 'cubicInOut'})
|
|
|
// .by(gameConfig.lineShake / 30, {x: 5}, {easing: 'cubicInOut'})
|
|
|
// .by(gameConfig.lineShake / 30, {y: -5}, {easing: 'cubicInOut'})
|
|
@@ -860,8 +1050,8 @@ export default class GameView extends LayerPanel {
|
|
|
}
|
|
|
|
|
|
update() {
|
|
|
- this._scoreLabel.string = "当前得分:" + this.score
|
|
|
- this._hardLevelLabel.string = "当前难度:" + this.hardLevel.toString()
|
|
|
+ this._scoreLabel.string = "score:" + this.score
|
|
|
+ this._hardLevelLabel.string = "hardLevel:" + this.hardLevel.toString()
|
|
|
|
|
|
if (CacheMgr.setting.hammerNum > 0) {
|
|
|
this._hammer_icon.active = false
|
|
@@ -896,7 +1086,7 @@ export default class GameView extends LayerPanel {
|
|
|
private fail_win() {
|
|
|
AudioMgr.play("fail")
|
|
|
Tools.vibrateLong()
|
|
|
- let result: any [] = []
|
|
|
+ let result: any[] = []
|
|
|
let time: number = 0
|
|
|
for (let i = 1; i <= 10; i++) {
|
|
|
let lineData = this._lineDatas[i]
|
|
@@ -931,14 +1121,14 @@ export default class GameView extends LayerPanel {
|
|
|
}
|
|
|
Promise.all(result).then(() => {
|
|
|
PanelMgr.INS.openPanel({
|
|
|
- panel : EndView,
|
|
|
- layer : Layer.gameLayer,
|
|
|
- param : {
|
|
|
- score : this.score,
|
|
|
- isNewMax : isNewMax
|
|
|
+ panel: EndView,
|
|
|
+ layer: Layer.gameLayer,
|
|
|
+ param: {
|
|
|
+ score: this.score,
|
|
|
+ isNewMax: isNewMax
|
|
|
},
|
|
|
- call : ()=>{
|
|
|
- PanelMgr.INS.closePanel(GameView) ;
|
|
|
+ call: () => {
|
|
|
+ PanelMgr.INS.closePanel(GameView);
|
|
|
}
|
|
|
})
|
|
|
});
|
|
@@ -986,16 +1176,37 @@ export default class GameView extends LayerPanel {
|
|
|
}
|
|
|
|
|
|
private handle_hammer() {
|
|
|
+ console.log('zh: hammer 使用锤子')
|
|
|
+
|
|
|
if (this._hint_hammer.active) {
|
|
|
return;
|
|
|
}
|
|
|
if (CacheMgr.setting.hammerNum <= 0) {
|
|
|
+ console.log('zh: hammer 没有锤子,开始播放视频')
|
|
|
+ if (ATRewardedVideoSDK.hasAdReady(AAJS2.getPlacementId())) {
|
|
|
+ cc.sys.localStorage.setItem('zh_ad_type', 'getHammer');//获取锤子
|
|
|
+ console.log('zh:AD ready for handle_hammer')
|
|
|
+ ATRewardedVideoSDK.showAd(AAJS2.getPlacementId());
|
|
|
+
|
|
|
+ } else {
|
|
|
+ console.log('zh:AD not ready for handle_hammer')
|
|
|
+ this.event_adPlayEndForHammer();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //下面是原始的逻辑,下面的代码精简掉即可
|
|
|
+ if (2 > 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
Tools.handleVideo().then((res) => {
|
|
|
+ console.log('zh: over ...锤子1')
|
|
|
if (!res) {
|
|
|
+ console.log('zh: over ...锤子2')
|
|
|
return;
|
|
|
}
|
|
|
+ console.log('zh: over ...锤子3')
|
|
|
//判断是否存在3个的方块
|
|
|
- let dataBeChui: any [] = []
|
|
|
+ let dataBeChui: any[] = []
|
|
|
for (let i = 1; i <= 10; i++) {
|
|
|
this._lineDatas[i].blockNodes.forEach((value) => {
|
|
|
if (value.num >= 3) {
|
|
@@ -1043,11 +1254,11 @@ export default class GameView extends LayerPanel {
|
|
|
let p = new Promise((resolve, reject) => {
|
|
|
cc.tween(h)
|
|
|
.delay(0.5)
|
|
|
- .to(gameConfig.hammerRotation, {angle: 30}, {easing: 'cubicInOut'})
|
|
|
+ .to(gameConfig.hammerRotation, { angle: 30 }, { easing: 'cubicInOut' })
|
|
|
.call(() => {
|
|
|
cc.tween(oldBlock.node)
|
|
|
- .by(gameConfig.lineShake / 2, {x: -15},)
|
|
|
- .by(gameConfig.lineShake / 2, {x: 15},)
|
|
|
+ .by(gameConfig.lineShake / 2, { x: -15 },)
|
|
|
+ .by(gameConfig.lineShake / 2, { x: 15 },)
|
|
|
.union()
|
|
|
.call(() => {
|
|
|
h.active = false
|
|
@@ -1107,11 +1318,13 @@ export default class GameView extends LayerPanel {
|
|
|
this.downAllLine(10)
|
|
|
}, 0)
|
|
|
})
|
|
|
+
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
+ console.log('zh:我有个锤子,所以直接使用')
|
|
|
//判断是否存在3个的方块
|
|
|
- let dataBeChui: any [] = []
|
|
|
+ let dataBeChui: any[] = []
|
|
|
for (let i = 1; i <= 10; i++) {
|
|
|
this._lineDatas[i].blockNodes.forEach((value) => {
|
|
|
if (value.num >= 3) {
|
|
@@ -1159,11 +1372,11 @@ export default class GameView extends LayerPanel {
|
|
|
let p = new Promise((resolve, reject) => {
|
|
|
cc.tween(h)
|
|
|
.delay(0.5)
|
|
|
- .to(gameConfig.hammerRotation, {angle: 30}, {easing: 'cubicInOut'})
|
|
|
+ .to(gameConfig.hammerRotation, { angle: 30 }, { easing: 'cubicInOut' })
|
|
|
.call(() => {
|
|
|
cc.tween(oldBlock.node)
|
|
|
- .by(gameConfig.lineShake / 2, {x: -15},)
|
|
|
- .by(gameConfig.lineShake / 2, {x: 15},)
|
|
|
+ .by(gameConfig.lineShake / 2, { x: -15 },)
|
|
|
+ .by(gameConfig.lineShake / 2, { x: 15 },)
|
|
|
.union()
|
|
|
.call(() => {
|
|
|
h.active = false
|
|
@@ -1227,12 +1440,47 @@ export default class GameView extends LayerPanel {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 播放广告结束 获得一个锤子,通过事件触发
|
|
|
+ */
|
|
|
+ public event_adPlayEndForHammer() {
|
|
|
+ console.log('zh:锤子 +1')
|
|
|
+ CacheMgr.setting.hammerNum++
|
|
|
+ CacheMgr.setting = CacheMgr.setting
|
|
|
+ this._hammer_sprite.getComponent(cc.Label).string = CacheMgr.setting.hammerNum.toString()
|
|
|
+ console.log('zh: 锤1 +1 end')
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private handle_sprite() {
|
|
|
+ console.log('zh: hammer 魔鬼闪电')
|
|
|
if (this._hint_sprite.active) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (CacheMgr.setting.spriteNum <= 0) {
|
|
|
+ console.log('zh: hammer 魔鬼闪电 数量不足 开始播放视频')
|
|
|
+ if (ATRewardedVideoSDK.hasAdReady(AAJS2.getPlacementId())) {
|
|
|
+ cc.sys.localStorage.setItem('zh_ad_type', 'getSprite');//获取锤子
|
|
|
+ console.log('zh:AD ready for handle_sprite')
|
|
|
+ ATRewardedVideoSDK.showAd(AAJS2.getPlacementId());
|
|
|
+
|
|
|
+ } else {
|
|
|
+ console.log('zh:AD not ready for handle_sprite')
|
|
|
+ this.event_adPlayEndForHndle_sprite();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //下面是原始的逻辑,下面的代码精简掉即可
|
|
|
+ if (2 > 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //下面是原始的逻辑,下面的代码精简掉即可
|
|
|
Tools.handleVideo().then((res) => {
|
|
|
if (!res) {
|
|
|
return;
|
|
@@ -1262,13 +1510,13 @@ export default class GameView extends LayerPanel {
|
|
|
.bezierTo(gameConfig.sprite_move, cc.v2(Tools.getRandom(-500, 500), Tools.getRandom(-500, 500)), cc.v2(Tools.getRandom(-500, 500), Tools.getRandom(-500, 500)), cc.v2(position))
|
|
|
.call(() => {
|
|
|
cc.tween(sprite_node)
|
|
|
- .by(gameConfig.sprite_jump / 2, {y: 20}, {easing: 'cubicInOut'})
|
|
|
- .by(gameConfig.sprite_jump / 2, {y: -20}, {easing: 'cubicInOut'})
|
|
|
+ .by(gameConfig.sprite_jump / 2, { y: 20 }, { easing: 'cubicInOut' })
|
|
|
+ .by(gameConfig.sprite_jump / 2, { y: -20 }, { easing: 'cubicInOut' })
|
|
|
.union()
|
|
|
.call(() => {
|
|
|
cc.tween(value.node)
|
|
|
- .by(gameConfig.lineShake / 2, {x: -15},)
|
|
|
- .by(gameConfig.lineShake / 2, {x: 15},)
|
|
|
+ .by(gameConfig.lineShake / 2, { x: -15 },)
|
|
|
+ .by(gameConfig.lineShake / 2, { x: 15 },)
|
|
|
.union()
|
|
|
.call(() => {
|
|
|
sprite_node.active = false
|
|
@@ -1341,13 +1589,13 @@ export default class GameView extends LayerPanel {
|
|
|
.bezierTo(gameConfig.sprite_move, cc.v2(Tools.getRandom(-500, 500), Tools.getRandom(-500, 500)), cc.v2(Tools.getRandom(-500, 500), Tools.getRandom(-500, 500)), cc.v2(position))
|
|
|
.call(() => {
|
|
|
cc.tween(sprite_node)
|
|
|
- .by(gameConfig.sprite_jump / 2, {y: 20}, {easing: 'cubicInOut'})
|
|
|
- .by(gameConfig.sprite_jump / 2, {y: -20}, {easing: 'cubicInOut'})
|
|
|
+ .by(gameConfig.sprite_jump / 2, { y: 20 }, { easing: 'cubicInOut' })
|
|
|
+ .by(gameConfig.sprite_jump / 2, { y: -20 }, { easing: 'cubicInOut' })
|
|
|
.union()
|
|
|
.call(() => {
|
|
|
cc.tween(value.node)
|
|
|
- .by(gameConfig.lineShake / 2, {x: -15},)
|
|
|
- .by(gameConfig.lineShake / 2, {x: 15},)
|
|
|
+ .by(gameConfig.lineShake / 2, { x: -15 },)
|
|
|
+ .by(gameConfig.lineShake / 2, { x: 15 },)
|
|
|
.union()
|
|
|
.call(() => {
|
|
|
sprite_node.active = false
|
|
@@ -1395,14 +1643,26 @@ export default class GameView extends LayerPanel {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 播放广告结束 获得一个魔鬼闪电,通过事件触发
|
|
|
+ */
|
|
|
+ public event_adPlayEndForHndle_sprite() {
|
|
|
+ CacheMgr.setting.spriteNum++
|
|
|
+ CacheMgr.setting = CacheMgr.setting
|
|
|
+ this._price_sprite.getComponent(cc.Label).string = CacheMgr.setting.spriteNum.toString()
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private handle_menu() {
|
|
|
+ console.log('zh: hammer 菜单')
|
|
|
// this._menuPanel.active = !this._menuPanel.active
|
|
|
if (this._menuPanel.y > this._menu.y) {
|
|
|
if (this._menuPanel.y != this._menu.y + this._menu.height) {
|
|
|
return
|
|
|
}
|
|
|
tween(this._menuPanel)
|
|
|
- .to(gameConfig.menu_box_move, {y: this._menu.y}, {easing: 'cubicInOut'})
|
|
|
+ .to(gameConfig.menu_box_move, { y: this._menu.y }, { easing: 'cubicInOut' })
|
|
|
.call(() => {
|
|
|
|
|
|
this.scheduleOnce(() => {
|
|
@@ -1413,13 +1673,19 @@ export default class GameView extends LayerPanel {
|
|
|
} else {
|
|
|
this._menuPanel.active = true
|
|
|
tween(this._menuPanel)
|
|
|
- .to(gameConfig.menu_box_move, {y: this._menu.y + this._menu.height})
|
|
|
+ .to(gameConfig.menu_box_move, { y: this._menu.y + this._menu.height })
|
|
|
.start()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//重新开始
|
|
|
private handle_restart() {
|
|
|
+ console.log('zh: hammer handle_restart')
|
|
|
for (let i = 1; i <= 10; i++) {
|
|
|
let lineData = this._lineDatas[i]
|
|
|
lineData.blockNodes.forEach((value) => {
|
|
@@ -1436,11 +1702,12 @@ export default class GameView extends LayerPanel {
|
|
|
|
|
|
//返回首页
|
|
|
private handle_return() {
|
|
|
+ console.log('zh: hammer 返回首页')
|
|
|
PanelMgr.INS.openPanel({
|
|
|
- panel : HomeView,
|
|
|
- layer : Layer.gameLayer,
|
|
|
- call : ()=>{
|
|
|
- PanelMgr.INS.closePanel(GameView) ;
|
|
|
+ panel: HomeView,
|
|
|
+ layer: Layer.gameLayer,
|
|
|
+ call: () => {
|
|
|
+ PanelMgr.INS.closePanel(GameView);
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -1454,6 +1721,7 @@ export default class GameView extends LayerPanel {
|
|
|
}
|
|
|
|
|
|
hint_play() {
|
|
|
+ console.log('zh: hint_play')
|
|
|
this._hint_mask.active = true
|
|
|
this._hint_mask.width = this._lineDatas[10].line.width
|
|
|
this._hint_mask.height = this._lineDatas[10].line.height * 2
|
|
@@ -1500,8 +1768,8 @@ export default class GameView extends LayerPanel {
|
|
|
endPosition.y -= gameConfig.gridSize / 2
|
|
|
this._hint_hand.position = startPosition
|
|
|
tween(this._hint_hand)
|
|
|
- .to(gameConfig.hint_hand_move, {position: endPosition})
|
|
|
- .to(0, {position: startPosition})
|
|
|
+ .to(gameConfig.hint_hand_move, { position: endPosition })
|
|
|
+ .to(0, { position: startPosition })
|
|
|
.union()
|
|
|
.repeatForever()
|
|
|
.start()
|
|
@@ -1526,7 +1794,7 @@ export default class GameView extends LayerPanel {
|
|
|
this._hint_mask.active = false
|
|
|
this.scheduleOnce(() => {
|
|
|
tween(this._hint_label)
|
|
|
- .to(1, {opacity: 0})
|
|
|
+ .to(1, { opacity: 0 })
|
|
|
.call(() => {
|
|
|
this._hint_label.active = false
|
|
|
})
|