import { _decorator, Component, Node, sp, UI } from 'cc'; import { GameUILayers, gui } from 'db://assets/core/ui/ui'; import ui_base from 'db://assets/core/ui/ui_base'; import { ModuleDef } from 'db://assets/Script/ModuleDef'; import { Layout_Revive } from './Layout_Revive'; import { UI_Hall } from '../UI_Hall/UI_Hall'; import { SceneDef } from 'db://assets/Script/SceneDef'; import { ResUtil } from 'db://assets/core/util/ResUtil'; import { UI_Main } from '../main/UI_Main'; import ch_audio from 'db://assets/ch/audio/audio'; import { ani_ui } from '../../game/animation_utils'; import { LvData } from '../../game/LvData/LvData'; import { Block } from '../../game/link/block/Block'; import { BlockLink } from '../../game/link/block/BlockLink'; import { UI_Lose } from '../UI_Lose/UI_Lose'; import { audioManager } from '../../Audio/AudioManager'; const { ccclass, property } = _decorator; @ccclass('UI_Revive') export class UI_Revive extends ui_base { constructor() { super(ModuleDef.GAME, 'ui/UI_Revive/revive', GameUILayers.HUD, Layout_Revive); } protected async onCreated() { ani_ui(this.node); const layout = this.getLayout(); this.onButtonEvent(layout.returnBtn, async (button: any) => { audioManager.playOneShot('sound/click_Btn'); //跳转场景回到主页 await this.close(); gui.show(UI_Lose); }, this); this.onButtonEvent(layout.reviveBtn, async (button: any) => { audioManager.playOneShot('sound/click_Btn'); //TODO: 复活+50s let res = await chsdk.playRewardAd('复活'); if (res) { gui.close(UI_Revive); UI_Main.lt.title.addTime(50); //执行复活移动 const role = UI_Main.lt.role; if (role) { await role.reviveMove(); // 复活移动 } } }, this); const completedBlocks = BlockLink.totalBlocks - BlockLink.remainingBlocks; const progress = completedBlocks / BlockLink.totalBlocks; layout.progressBar.progress = progress; layout.scrussNum.string = Math.floor(progress * 100) + '%'; let role = layout.role.getComponent(sp.Skeleton) let skinId = LvData.instance.rwpf; this.changeSkin(skinId, layout.SkeletonData, role); } public changeSkin(newSkinId: number, SkeletonData, spineSkeleton): void { if (newSkinId - 1 >= 0 && newSkinId - 1 < SkeletonData.length) { spineSkeleton.skeletonData = SkeletonData[newSkinId - 1] spineSkeleton.setAnimation(0, "anim_jiemian", true); } else { console.error("骨骼资源索引l越界") } } }