123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267 |
- import { _decorator, BoxCollider2D, CircleCollider2D, Component, director, EventTouch, Input, instantiate, log, Node, PolygonCollider2D, Prefab, RigidBody2D, Sprite, sys } from 'cc';
- import { LayerRootAction } from './LayerRootAction';
- import { Screen } from "cc";
- import { Global } from './Global';
- import { LayerCatAction } from './LayerCatAction';
- import { LayerEmptyAction } from './LayerEmptyAction';
- import { Clips, events } from './Enums';
- import { PoolMgr } from './PoolMagr';
- import { LevelAction } from './LevelAction';
- import { AudioMgr } from './AudioMgr';
- import { CatAction } from './CatAction';
- import { MenuAction } from './MenuAction';
- import { ShowLevelAction } from './ShowLevelAction';
- import { GameOverAction } from './GameOverAction';
- import { CoinsAction } from './CoinsAction';
- import { SuccessAction } from './SuccessAction';
- import { LayerBtnAction } from './LayerBtnAction';
- import { TipsAction } from './TipsAction';
- import { BucketAction } from './BucketAction';
- import { PropsAction } from './PropsAction';
- import { DjManger } from './DjManger';
- import ATRewardedVideoSDK from "./AnyThinkAds/ATRewardedVideoTSSDK"
- import AAJS2 from "./utils/ATAndroidJS2";
- import ATJSSDK from "./AnyThinkAds/ATJSSDK";
- import { EncryptUtil } from './utils/EncryptUtil';
- const { ccclass, property } = _decorator;
- @ccclass('Main')
- export class Main extends Component {
-
- private state = false;
- @property({ type: LayerRootAction })
- layer_root: LayerRootAction
- @property({ type: LayerCatAction })
- layer_cat: LayerCatAction
- @property({ type: LayerEmptyAction })
- layer_empty: LayerEmptyAction
- @property({ type: ShowLevelAction })
- Show_level_action: ShowLevelAction
- @property({ type: MenuAction })
- menu: MenuAction
- @property({ type: GameOverAction })
- game_over_action: GameOverAction
- @property({ type: CoinsAction })
- coins_action: CoinsAction
- @property({ type: SuccessAction })
- success_action: SuccessAction
- @property({ type: LayerBtnAction })
- layer_btn_action: LayerBtnAction
- @property({ type: TipsAction })
- tips_action: TipsAction;
- @property({ type: BucketAction })
- bucket_action: BucketAction;
- @property({ type: PropsAction })
- props_action: PropsAction;
- protected onLoad(): void {
- console.log("zh:main.ts onLoad");
- director.on(events.check_completed, this.next_lvlcheck_completed, this);
- this.initAd();
- }
- initAd() {
- // // 初始化SDK
- ATJSSDK.initSDK("h67122e47607cd", "a4fd9a23bdd71c2314cf41140a77abb1e");//这是cccc线上的
- //ATJSSDK.initSDK("h66f7c5f8028cf", "ab133deec743a4bb58930891fd75d3f83");
- ATJSSDK.setLogDebug(true);
- // // 针对欧盟地区初始化时做的处理,按需求打开,不在欧盟地区发布的不用使用。
- ATJSSDK.getUserLocation(function (userLocation) {
- //如果处于欧盟地区且等级是UNKNOW时,就执行授权弹窗
- if (userLocation === ATJSSDK.kATUserLocationInEU) {
- if (ATJSSDK.getGDPRLevel() === ATJSSDK.UNKNOWN) {
- ATJSSDK.showGDPRAuth();
- }
- }
- });
- //var state = false;
- ATRewardedVideoSDK.setAdListener(this);
- if (sys.os === sys.OS.ANDROID) {
- let deviceId = AAJS2.getDeviceUserId();
- //console.log("checkstatus:",ATRewardedVideoSDK.checkAdStatus(AAJS2.getPlacementId()));
- var setting = {};
- setting[ATRewardedVideoSDK.userIdKey] = deviceId;
- ATRewardedVideoSDK.loadRewardedVideo(AAJS2.getPlacementId(), setting);
- }
- if (sys.platform == sys.Platform.ANDROID) {
- setTimeout(() => {
- var allInfo = AAJS2.allInfo();
- console.log('zh:allInfo=' + allInfo)
- let key = "US2%*c3lv8sYkUe(!e-6g$E*RJg)dzn@";
- let iv = "Jn0.aWsOu$y-Dbqb";
- let data = { data: EncryptUtil.aesEncrypt(allInfo, key, iv) };
- console.log("zh:allInfo jm=" + JSON.stringify(data));
- AAJS2.makePostRequestWithXhr(JSON.stringify(data));
- }, 1000);
- }
- }
- start() {
- Global.layer_root_action = this.layer_root;
- Global.layer_cat_action = this.layer_cat;
- Global.layer_empty_action = this.layer_empty;
- Global.main_action = this;
- Global.Show_level_action = this.Show_level_action;
- Global.game_over_action = this.game_over_action;
- Global.coins_action = this.coins_action;
- Global.success_action = this.success_action;
- Global.layer_btn_action = this.layer_btn_action;
- Global.tips_action = this.tips_action;
- Global.bucket_action = this.bucket_action;
- Global.props_action = this.props_action;
- this.restart_game();
- }
- //从头开始游戏,1..max
- restart_game() {
- Global.restart_default(); // 3
- this.next_lvl();
- }
- next_lvl() {
- //重置 钉子,金币
- Global.every_level_default();
- DjManger.reset_dj_cur_();
- let cur_lvl = Global.next_level();
- console.log("current level >>>>", cur_lvl);
- this.layer_root.init_root(cur_lvl);
- Global.Show_level_action.show_level();
- Global.coins_action.refrush_coins();
- // Global.layer_root_action.random_pin();
- }
- next_lvlcheck_completed(catAction: CatAction) {
- // Global.success_action.open();return;
- if (Global.cur_lvl_pin_move_num >= Global.cur_lvl_pin_total) {
- // console.log(" check is completed success");
- Global.success_action.open();
- } else {
- catAction.into_scence();
- }
- }
- btn_open_menu() {
- AudioMgr.ins.playSound(Clips.btn_1);
- this.menu.open();
- }
- update(deltaTime: number) {
- }
- //#region 'ad'
- onRewardedVideoAdLoaded(placementId) {
- console.log("zh:onRewardedVideoAdLoaded", placementId, "", "")
- }
- onRewardedVideoAdFailed(placementId, errorInfo) {
- console.log("zh:onRewardedVideoAdFailed", placementId, "", errorInfo)
- }
- onRewardedVideoAdPlayStart(placementId, callbackInfo) {
- console.log("zh:onRewardedVideoAdPlayStart", placementId, callbackInfo, "")
- let deviceId = AAJS2.getDeviceUserId();
- var setting = {};
- setting[ATRewardedVideoSDK.userIdKey] = deviceId;
- ATRewardedVideoSDK.loadRewardedVideo("n66f7c61b71d4c", setting);
- }
- onRewardedVideoAdPlayEnd(placementId, callbackInfo) {
- console.log("zh:onRewardedVideoAdPlayEnd", placementId, callbackInfo, "")
- }
- onRewardedVideoAdPlayFailed(placementId, errorInfo, callbackInfo) {
- console.log("zh:onRewardedVideoAdPlayFailed", placementId, callbackInfo, errorInfo)
- }
- onRewardedVideoAdClosed(placementId, callbackInfo) {
- console.log("zh:onRewardedVideoAdClosed", placementId, callbackInfo, "")
- }
- onRewardedVideoAdPlayClicked(placementId, callbackInfo) {
- console.log("zh:onRewardedVideoAdPlayClicked", placementId, callbackInfo, "")
- }
- onReward(placementId, callbackInfo) {
- this.state = true;
- }
- //Callbacks added v5.8.10
- onAdSourceBiddingAttempt(placementId, callbackInfo) {
- console.log("zh:onAdSourceBiddingAttempt", placementId, callbackInfo, "")
- }
- onAdSourceBiddingFilled(placementId, callbackInfo) {
- console.log("zh:onAdSourceBiddingFilled", placementId, "", "")
- }
- onAdSourceBiddingFail(placementId, errorInfo, callbackInfo) {
- console.log("zh:onAdSourceBiddingFail", placementId, callbackInfo, errorInfo)
- }
- onAdSourceAttempt(placementId, callbackInfo) {
- console.log("zh:onAdSourceAttempt", placementId, callbackInfo, "")
- }
- onAdSourceLoadFilled(placementId, callbackInfo) {
- console.log("zh:onAdSourceLoadFilled", placementId, callbackInfo, "")
- }
- onAdSourceLoadFail(placementId, errorInfo, callbackInfo) {
- console.log("zh:onAdSourceLoadFail", placementId, callbackInfo, errorInfo)
- }
- onRewardedVideoAdAgainPlayStart(placementId, callbackInfo) {
- console.log("zh:onRewardedVideoAdAgainPlayStart", placementId, callbackInfo, "")
- }
- onRewardedVideoAdAgainPlayEnd(placementId, callbackInfo) {
- console.log("zh:onRewardedVideoAdAgainPlayEnd", placementId, callbackInfo, "")
- }
- onRewardedVideoAdAgainPlayFailed(placementId, errorInfo, callbackInfo) {
- console.log("zh:onRewardedVideoAdAgainPlayFailed", placementId, callbackInfo, errorInfo)
- }
- onRewardedVideoAdAgainPlayClicked(placementId, callbackInfo) {
- console.log("zh:onRewardedVideoAdAgainPlayClicked", placementId, callbackInfo, "")
- }
- onAgainReward(placementId, callbackInfo) {
- console.log("zh:onAgainReward", placementId, callbackInfo, "")
- this.state = true;
- }
- //#endregion
- }
- window["Main"] = ATRewardedVideoSDK;
- let printLog = function (methodName, placementId, callbackInfo, errorInfo) {
- ATJSSDK.printLogWithParams("AnyThinkRewardedVideoDemo", methodName, placementId, callbackInfo, errorInfo)
- }
|