import { _decorator, Component, instantiate, Label, Node, tween, UITransform, Vec3 } from 'cc'; import { Global } from './Global'; import { Clips } from './Enums'; import { AudioMgr } from './AudioMgr'; import { BasePage } from './BasePage'; import { AdManger } from './ad/AdManger'; import { Tools } from './Tools'; import { PoolMgr } from './PoolMagr'; const { ccclass, property } = _decorator; @ccclass('SuccessAction') export class SuccessAction extends BasePage { @property({type:Label}) level_label:Label = null; @property({type:Label}) coins_label:Label = null; @property({type:Node}) coins_img:Node = null; @property({type:Node}) get_coins_btn:Node = null; start() { super.start(); } update(deltaTime: number) { } //show menu plant open(){ super.open(); if(this.get_coins_btn){ this.get_coins_btn.active = true; } AudioMgr.ins.playSound(Clips.complete_2); this.level_label.string = "Level "+ Global.cur_lvl+" "; this.coins_label.string = ""+ Global.cur_coins+" "; this.coins_label.node.scale = new Vec3(3,3,0); tween(this.coins_label.node) .to(0.5, { scale: new Vec3(1, 1,0) } ,Global.our_easing) .start(); } btn_next(){ AudioMgr.ins.playSound(Clips.btn_1); if(this.get_coins_btn){ this.get_coins_btn.active = false; } this.close(); AdManger.show_interstial(); // Global.reset_level_default(); Global.main_action.next_lvl(); } private play_add_gift_tween(num:number,world_pos:Vec3,callBack:Function){ let prefab = PoolMgr.ins.getPrefab("coin"); let temp = 0; for(let i =0;i{ temp++; this.coins_label.string = ""+ (Global.cur_coins+temp); AudioMgr.ins.playSound(Clips.coins); if(temp>=num){ if(callBack){ callBack(); callBack = null; } this.coins_label.string = ""+ Global.cur_coins; } }) .removeSelf() .start(); } } get_one_bag_coins(){ if(this.get_coins_btn){ this.get_coins_btn.active = false; }else{ return; } AudioMgr.ins.playSound(Clips.btn_1); AdManger.show_video((data) => { if (data == 1) { console.log("get_one_bag_coins 获取奖励成功"); let num = Math.ceil(Tools.random_between(15,46)); // console.log(" random data num :",num); this.play_add_gift_tween(num,this.get_coins_btn.getWorldPosition(),()=>{ Global.coins_action.put_coins(num,this.coins_img.getWorldPosition(),false); }); } else { Global.tips_action.show("Gain reward failure");//获取奖励失败 // this.close(); // Global.main_action.next_lvl(); } }) } }