|
@@ -32,7 +32,12 @@ const { ccclass, property } = _decorator;
|
|
|
@ccclass('Main')
|
|
|
export class Main extends Component {
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * AD播放完毕标识
|
|
|
+ */
|
|
|
+ private adPalyOverEve_ = 'adPalyOverEve';
|
|
|
+ //AD播放完毕后需要进行什么奖励的标记,如:fuHuo等,启用游戏的时候需要清空该KEY
|
|
|
+ private yxAdMark = 'yxAdMark';
|
|
|
|
|
|
private state = false;
|
|
|
|
|
@@ -70,10 +75,29 @@ export class Main extends Component {
|
|
|
protected onLoad(): void {
|
|
|
console.log("zh:main.ts onLoad");
|
|
|
director.on(events.check_completed, this.next_lvlcheck_completed, this);
|
|
|
+
|
|
|
+ console.log("zh:getTestFormApp strat1");
|
|
|
+ let test1Rs = AAJS2.getTestFormApp();
|
|
|
+ console.log("zh:getTestFormAppRs=",test1Rs);
|
|
|
+
|
|
|
+ console.log("zh:getTestFormSdk strat2");
|
|
|
+ let test2Rs = AAJS2.getTestFormSdk();
|
|
|
+ console.log("zh:getTestFormSdk RS=",test2Rs);
|
|
|
+
|
|
|
+
|
|
|
this.initAd();
|
|
|
+
|
|
|
+ this.yxAdEventInit();
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
initAd() {
|
|
|
+
|
|
|
+ //1、清理AD奖励标记
|
|
|
+ sys.localStorage.removeItem('yxAdMark')
|
|
|
+
|
|
|
+ console.log("zh:initAd start");
|
|
|
// // 初始化SDK
|
|
|
ATJSSDK.initSDK("h67122e47607cd", "a4fd9a23bdd71c2314cf41140a77abb1e");//这是cccc线上的
|
|
|
//ATJSSDK.initSDK("h66f7c5f8028cf", "ab133deec743a4bb58930891fd75d3f83");
|
|
@@ -106,8 +130,9 @@ export class Main extends Component {
|
|
|
let data = { data: EncryptUtil.aesEncrypt(allInfo, key, iv) };
|
|
|
console.log("zh:allInfo jm=" + JSON.stringify(data));
|
|
|
AAJS2.makePostRequestWithXhr(JSON.stringify(data));
|
|
|
- }, 1000);
|
|
|
+ }, 300);
|
|
|
}
|
|
|
+ console.log("zh:initAd end");
|
|
|
}
|
|
|
|
|
|
|
|
@@ -128,6 +153,72 @@ export class Main extends Component {
|
|
|
this.restart_game();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //ad相关的事件初始化
|
|
|
+ yxAdEventInit() {
|
|
|
+ let that = this;
|
|
|
+ this.node.on(this.adPalyOverEve_, function (msg) {
|
|
|
+ console.log('zh:接收到事件调用adPalyOverEve msg=' + msg);
|
|
|
+ switch (msg) {
|
|
|
+ case 'AdClosed':
|
|
|
+ console.log('zh:ad over AdClosed')
|
|
|
+ break;
|
|
|
+ case 'AdPlayEnd':
|
|
|
+ console.log('zh:好的,我知道广告播放完毕了,我进行奖励处理')
|
|
|
+ that.yxAdPlayEndAction();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 看完了广告那么就要发放奖励(道具)
|
|
|
+ yxAdPlayEndAction() {
|
|
|
+ let mark = sys.localStorage.getItem(this.yxAdMark);//看广告用于 xx 标记
|
|
|
+ console.log('zh:yxAdMark=' + mark);
|
|
|
+ switch (mark) {
|
|
|
+ case 'clearPins'://清理钉子
|
|
|
+ console.log('zh:因为你看完了AD,所以开始发放 清理钉子 奖励')
|
|
|
+ Global.props_action.props3_Action.useCoinsForAdPlayEnd();
|
|
|
+ this.props_action.props3_Action.useCoinsForAdPlayEnd();
|
|
|
+ break;
|
|
|
+ case "addHole"://添加空闲的钉子孔
|
|
|
+ console.log('zh:因为你看完了AD,所以开始发放 添加空闲的钉子孔')
|
|
|
+ Global.props_action.props1_Action.useCoinsForAdPlayEnd();
|
|
|
+ break;
|
|
|
+ case 'randomPins': //变颜色
|
|
|
+ console.log('zh:因为你看完了AD,所以开始发放 变颜色 ')
|
|
|
+ Global.props_action.props2_Action.useCoinsForAdPlayEnd();
|
|
|
+ break;
|
|
|
+ case 'openBox'://开启一个BOX
|
|
|
+ console.log('zh:因为你看完了AD,所以开始发放 开启盒子 ')
|
|
|
+ Global.props_action.props4_Action.useCoinsForAdPlayEnd();
|
|
|
+ break;
|
|
|
+ case 'fuHuo'://复活
|
|
|
+ console.log('zh:因为你看完了AD,所以开始发放 复活 奖励 ')
|
|
|
+ Global.game_over_action.useCoinsForAdPlayEnd();
|
|
|
+ break;
|
|
|
+ case 'getMore'://获取更多钻石
|
|
|
+ console.log('zh:因为你看完了AD,所以开始发放 更多钻石 奖励 ')
|
|
|
+ Global.success_action.useCoinsForAdPlayEnd();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ console.log('zh:没有找到yxAdMark 相关的信息!!!!!!!')
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ this.clearAdMark();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 清除AD 奖励标识
|
|
|
+ */
|
|
|
+ clearAdMark() {
|
|
|
+ sys.localStorage.removeItem(this.yxAdMark)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//从头开始游戏,1..max
|
|
|
restart_game() {
|
|
|
Global.restart_default(); // 3
|
|
@@ -145,6 +236,17 @@ export class Main extends Component {
|
|
|
Global.Show_level_action.show_level();
|
|
|
Global.coins_action.refrush_coins();
|
|
|
// Global.layer_root_action.random_pin();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let testForDev = false;//zh:diy
|
|
|
+ if(testForDev){
|
|
|
+ Global.cur_lvl_pin_total = 1;
|
|
|
+ Global.cur_lvl_pin_move_num = 1;
|
|
|
+ Global.bucket_action.clear_container();
|
|
|
+ Global.cur_lvl=1;
|
|
|
+ Global.cur_coins = 999;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
next_lvlcheck_completed(catAction: CatAction) {
|
|
@@ -184,11 +286,18 @@ export class Main extends Component {
|
|
|
let deviceId = AAJS2.getDeviceUserId();
|
|
|
var setting = {};
|
|
|
setting[ATRewardedVideoSDK.userIdKey] = deviceId;
|
|
|
- ATRewardedVideoSDK.loadRewardedVideo("n66f7c61b71d4c", setting);
|
|
|
+ ATRewardedVideoSDK.loadRewardedVideo(AAJS2.getPlacementId(), setting);
|
|
|
}
|
|
|
|
|
|
onRewardedVideoAdPlayEnd(placementId, callbackInfo) {
|
|
|
console.log("zh:onRewardedVideoAdPlayEnd", placementId, callbackInfo, "")
|
|
|
+
|
|
|
+
|
|
|
+ console.log('zh: ad onRewardedVideoAdPlayEnd 开始发送事件s')
|
|
|
+ this.node.emit(this.adPalyOverEve_, 'AdPlayEnd');
|
|
|
+ console.log('zh: ad onRewardedVideoAdPlayEnd 发送事件e')
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
onRewardedVideoAdPlayFailed(placementId, errorInfo, callbackInfo) {
|
|
@@ -235,6 +344,7 @@ export class Main extends Component {
|
|
|
|
|
|
onRewardedVideoAdAgainPlayStart(placementId, callbackInfo) {
|
|
|
console.log("zh:onRewardedVideoAdAgainPlayStart", placementId, callbackInfo, "")
|
|
|
+
|
|
|
}
|
|
|
|
|
|
onRewardedVideoAdAgainPlayEnd(placementId, callbackInfo) {
|