| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import { _decorator, Component, Node } from 'cc';
- import ui_base from '../../../core/ui/ui_base';
- import { ModuleDef } from '../../../scripts/ModuleDef';
- import { GameUILayers } from '../../../core/ui/ui';
- import { Layout_treasure } from './Layout_treasure';
- import { ani_ui, button_sound, GameLink } from '../../game/GameLink';
- import { ch } from '../../../ch/ch';
- import { data_type } from '../../game/Player';
- const { ccclass, property } = _decorator;
- @ccclass('UI_treasure')
- export class UI_treasure extends ui_base {
- constructor() {
- super(ModuleDef.Link, 'ui/treasure/UI_treasure', GameUILayers.HUD, Layout_treasure);
- }
- protected async onCreated() {
- const layout = this.getLayout<Layout_treasure>();
- ani_ui(layout.cloose_btn.node.parent);
- this.onButtonEvent(layout.cloose_btn, (button: any) => {
- button_sound();
- this.close();
- }, this);
- this.onButtonEvent(layout.get_btn, async (button: any) => {
- button_sound();
- //广告链接看完之后执行以下内容
- const ret = await chsdk.playRewardAd('获得道具');
- if (ret) {
- ch.audio.playOneShot('sounds/sfx_add_item');
- GameLink.getInst().player.add_item(2, 1);//刷新
- GameLink.getInst().player.add_item(3, 2);//提示
- GameLink.getInst().player.setDirty();
- GameLink.getInst().player.save();
- //开始倒计时
- GameLink.getInst().player.set_bx_time(300);
- this.close();
- }
- }, this);
- }
- }
|