123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import { _decorator, Button, Component, Node } from 'cc';
- import ui_base from '../../../core/ui/ui_base';
- import { ModuleDef } from '../../../Scripts/ModuleDef';
- import { GameUILayers, gui } from '../../../core/ui/ui';
- import { Layout_Life } from './Layout_Life';
- import { Hall } from '../../hall/Hall';
- import ch_audio from '../../../ch/audio/audio';
- import { UI_Hall } from '../UI_Hall/UI_Hall';
- import { ani_ui } from '../UI_Main/UI_Main';
- const { ccclass, property } = _decorator;
- @ccclass('UI_Life')
- export class UI_Life extends ui_base {
- constructor() {
- super(ModuleDef.GAME, 'ui/UI_Life/Life', GameUILayers.HUD, Layout_Life);
- }
- protected onCreated() {
- const layout= this.getLayout<Layout_Life>();
- ani_ui(layout.Close_Btn.node.parent);
- this.onButtonEvent(layout.Close_Btn, () => {
- gui.close(UI_Life);
- });
- this.onButtonEvent(layout.Free_Get_Btn, async() => {
- ch_audio.getInstance().pause();
- let res=await chsdk.playRewardAd('获得体力');
- if(res){
- Hall.getInstance().player.set_life(Hall.getInstance().player.get_life()+1);
- gui.get(UI_Hall).set_Life(Hall.getInstance().player.get_life());
- ch_audio.getInstance().resume();
- }
- });
- this.onButtonEvent(layout.No_Btn, async() => {
- gui.close(UI_Life);
- });
- }
- }
|