| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import { _decorator, Component, Node, ProgressBar, Tween, tween } from 'cc';
- import { UI_Dialog } from '../UI_Dialog';
- import { aa, UIController, UIElement } from 'db://assets/scripts/aa';
- import { rootMgr } from '../../../scene/RootMgr';
- import { Update } from 'db://assets/scripts/uitl/baseData/BaseData/DailyUpdates';
- import { ItemKey, ItemService } from '../../../data/Item/ItemService';
- import { Notify } from '../../../scene/GameConfing';
- const { ccclass, property } = _decorator;
- @UIController({ bundleName: 'dialog', path: 'needCoin/needCoin' })
- export class UI_NeedCoin extends UI_Dialog {
- @UIElement(Node)
- adBtn: Node
- // @UIElement(Node)
- // goMainBtn: Node
- @UIElement(ProgressBar)
- progressBar: ProgressBar
- @UIElement(Node)
- yuan: Node
- start(): void {
- this.adBtn.on(Node.EventType.TOUCH_END, this.addCoin, this)
- // this.goMainBtn.on(Node.EventType.TOUCH_END, this.goMain, this)
- this.reflash()
- }
- reflash(my?: number) {
- let rewardCoinTimes = rootMgr.dataControl.getCompent(Update).getDaly('rewardCoinTimes')
- if (my) {
- rewardCoinTimes = my
- }
- // 金币领取的刷新
- let process = rewardCoinTimes
- this.yuan.children.forEach((it, index) => {
- it.active = index < process
- })
- this.progressBar.progress = process / 3
- }
- async addCoin() {
- let updata = rootMgr.dataControl.getCompent(Update)
- let rewardCoinTimes = updata.getDaly('rewardCoinTimes')
- let boolean = await aa.sdk.playRewardAd('金币不足'+rewardCoinTimes)
- if (boolean) {
- this.reflash()
- let updata = rootMgr.dataControl.getCompent(Update)
- let rewardCoinTimes = updata.getDaly('rewardCoinTimes')
- let reward = rewardCoin[rewardCoinTimes % rewardCoin.length]
- updata.setDaly('rewardCoinTimes', (rewardCoinTimes + 1) % rewardCoin.length)
- // 播放动画
- rootMgr.dataControl.getCompent(ItemService).getRewarded(reward.key, reward.v)
- rootMgr.game.evt.emit('save')
- Notify("金币获取成功")
- // let start = Math.min(rewardCoinTimes, rewardCoin.length) / rewardCoin.length
- let end = Math.min(rewardCoinTimes + 1, rewardCoin.length)
- Tween.stopAllByTarget(this.progressBar)
- tween(this.progressBar).to(.2, { progress: end / rewardCoin.length }).call(() => {
- this.reflash(end)
- }).start()
- }
- }
- goMain() {
- }
- }
- export const rewardCoin = [{ v: 800, key: ItemKey.coin }, { v: 1600, key: ItemKey.coin }, { v: 2500, key: ItemKey.coin }]
|