| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- /** 点击信息流奖励界面 */
- import { MONEY_TYPE } from "../datas/CommonData";
- import MoreGameData from "../datas/MoreGameData";
- import Main from "../Main";
- import AdM from "../manager/AdM";
- import GameM, { AUDIO_TYPE } from "../manager/GameM";
- import NativeAdAwardData from "../manager/NativeAdAwardData";
- import UiM, { PANEL_NAME } from "../manager/UiM";
- import CarSpace from "../prefabs/CarSpace";
- import Sciencen_M from "../utils/Sciencen_M";
- import EffectNode from "./EffectNode";
- import Gift from "./Gift";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class NativeADAwardNode extends cc.Component {
- @property(cc.Label)
- labAward: cc.Label = null;
- @property(cc.Label)
- labGetAward: cc.Label = null;
- @property(cc.Node)
- btnGetAward: cc.Node = null;
- @property(cc.Node)
- btnGetNo: cc.Node = null;
- @property(cc.Node)
- labDesNode: cc.Node = null;
- @property(cc.Node)
- hand: cc.Node = null;
- @property(cc.Label)
- labDes: cc.Label = null;
- @property(cc.Node)
- btnNo: cc.Node = null;
- @property(cc.Sprite)
- btnBanner: cc.Sprite = null;
- //1 工厂过热冷却 2 热气球奖励 3 车位上领取金币
- type = 1
- num = ''
- carSp = null
- //信息流位
- streamData = null
- start() {
- }
- onDisable() {
- NativeAdAwardData.Instance.openNativeState = false
- // AdM.destroyNative()
- }
- /** 初始化
- * @param type 1 工厂过热冷却 2 热气球奖励 3 车位上领取金币
- */
- init(type, num = '', carSp = null) {
- NativeAdAwardData.Instance.openNativeState = true
- // AdM.showNative(2)
- this.streamData = MoreGameData.Instance.getRandomSteam()
- if (this.streamData) {
- cc.loader.load(this.streamData.stream, (err, res) => {
- if (err) {
- console.log('err:', err);
- return;
- }
- if (this.btnBanner) {
- let tex: cc.Texture2D = res as cc.Texture2D;
- this.btnBanner.spriteFrame = new cc.SpriteFrame(tex);
- this.btnBanner.node.active = true
- }
- })
- }
- this.type = type
- this.num = num
- this.carSp = carSp
- let awardStr = ''
- let getAwardStr = ''
- switch (this.type) {
- case 1:
- awardStr = '冷却时间减半'
- getAwardStr = '领取奖励'
- break
- case 2:
- awardStr = '立即更换热气球奖励'
- getAwardStr = '换一个奖励'
- break
- case 3:
- awardStr = `${NativeAdAwardData.Instance.nativeAwardTimes}倍领取奖励`
- getAwardStr = `${NativeAdAwardData.Instance.nativeAwardTimes}倍领取`
- break
- }
- this.labAward.string = awardStr
- this.labGetAward.string = getAwardStr
- this.btnGetAward.active = false
- this.btnGetNo.active = true
- }
- cool = false
- /** 点击推荐banner */
- clickBanner() {
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- if (this.cool) {
- return
- }
- this.cool = true
- this.scheduleOnce(() => {
- this.cool = false
- }, 3)
- MoreGameData.Instance.createNewTask(this.streamData)
- NativeAdAwardData.Instance.hasClickNative = true
- this.setCanGet()
- }
- /** 设置可领取 */
- setCanGet() {
- this.btnGetAward.active = true
- this.btnGetNo.active = false
- this.hand.scaleY = -1
- this.labDes.string = '请点击领取'
- this.btnNo.active = false
- }
- /** 点击领取奖励 */
- clickGetAward() {
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- if (NativeAdAwardData.Instance.hasClickNative) {
- NativeAdAwardData.Instance.hasClickNative = false
- GameM.globalStorage.setStorage('nativeAdAwardGet' + this.type, 2)
- let successTip = ''
- switch (this.type) {
- // case 1:
- // if (GameM.commonData.roleData.shutDownCoolTime > 0) {
- // GameM.commonData.roleData.shutDownCoolTime = Math.floor(GameM.commonData.roleData.shutDownCoolTime * 0.5)
- // }
- // let gift = UiM.Instance.giftNode.getComponent(Gift)
- // gift.init(MONEY_TYPE.facCool, '0')
- // UiM.Instance.giftNode.active = true
- // successTip = '时间减半成功'
- // break
- case 2:
- UiM.Instance.hallNode.getComponent(Main).ranNewAirShip()
- successTip = '更换奖励成功'
- break
- case 3:
- let gold = Sciencen_M.instance.accMul(this.num, NativeAdAwardData.Instance.nativeAwardTimes.toString())
- GameM.commonData.updateGold(gold)
- GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
- EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
- let s = this.carSp.getComponent(CarSpace)
- s.changeType(0)
- GameM.commonData.updateBagCarData(s.index.toString(), 0)
- this.scheduleOnce(() => {
- UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece()
- }, 0.1)
- successTip = `${NativeAdAwardData.Instance.nativeAwardTimes}倍领取成功`
- break
- }
- // AdM.onSendEvent('NativeAdAwardGet' + this.type, `信息流变现领取${this.type}`, 'NativeAdAwardGet')
- UiM.Instance.offPanel(PANEL_NAME.NativeAdAwardNode)
- EffectNode.instance.PlayTip(successTip)
- }
- else {
- // EffectNode.instance.PlayTip('点击上方广告后可领取奖励')
- }
- }
- clickGetAwardNo() {
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- cc.tween(this.labDesNode).to(0.15, { scale: 1.3 }).to(0.15, { scale: 1 }).start()
- }
- /** 点击关闭 */
- clickClose() {
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- UiM.Instance.offPanel(PANEL_NAME.NativeAdAwardNode)
- switch (this.type) {
- case 1:
- break
- case 2:
- UiM.Instance.hallNode.getComponent(Main).resumeAirShip()
- break
- case 3:
- GameM.commonData.updateGold(this.num)
- GameM.audioM.playEffect(AUDIO_TYPE.getGold, false)
- EffectNode.instance.PlayCoinAnim(0, 20, cc.v2(0, -300));
- let s = this.carSp.getComponent(CarSpace)
- s.changeType(0)
- GameM.commonData.updateBagCarData(s.index.toString(), 0)
- this.scheduleOnce(() => {
- UiM.Instance.hallNode.getComponent(Main).checkGiftByQucece()
- }, 0.1)
- break
- }
- }
- }
|