Files
18xchat/.svn/pristine/e8/e8c52fa561d5d2bbf4b2ed9433e9b17868df7d6c.svn-base
T
2025-07-17 17:18:21 +08:00

145 lines
4.9 KiB
Plaintext

import { _decorator, Node, Sprite, tween, UIOpacity, UITransform, Vec3, view } from 'cc';
import { GButton } from '../../Main/Common/GButton';
import Utils from '../../Main/Common/Utils';
import { InnerMsgCode } from '../../Main/Config/InnerMsgCode';
import li_BaseView from '../../Main/Common/li_BaseView';
import GameManager from '../../Main/Manager/GameManager';
import ResManager from '../../Main/Manager/ResManager';
import GameRootUI from '../../Main/Common/GameRootUI';
import { ViewManager } from '../../Main/Manager/ViewManager';
import { I_LevelStepData } from '../../Main/Config/CommonConfig';
import AudioManager from '../../Main/Manager/AudioManager';
const { ccclass, property } = _decorator;
//结算界面
@ccclass('Finish_UI')
export class Finish_UI extends li_BaseView {
private _nodeTab: any = {};
private _data: I_LevelStepData = null;
private picDefScale:Vec3; //图片默认缩放
private isPicFull:boolean = false; //图片是否全屏
//----重写父类接口---------------------------------------
onLoadCT() {
this.registerListenner();
Utils.parseNode(this.node, this._nodeTab)
this.picDefScale = (this._nodeTab.cgPic as Node).scale.clone();
GameRootUI.DisableOper(1)
}
openUIDataCT(data: any): void {
this._data = data
}
registerListenner() {
// Utils.addInnerEL(InnerMsgCode.GM_UI_Close, this, this.resiveGMClose)
}
start() {
GButton.BandClick(this._nodeTab.mask, ()=>{
// this.doClose();
ViewManager.I.closeAllView();
Utils.sendInnerMsg(InnerMsgCode.UI_Talk_Back, {})
}, this, 0, null, null, false);
GButton.BandClick(this._nodeTab.cgPic, ()=>{
this.changePicScale();
}, this, 0, null, null, false);
let lvCfg = GameManager.getLevelCfg(GameManager.CurLevelId)
//星级
for (let i = 1; i <= 3; i++) {
let starSpt = this._nodeTab["star" + i].getComponent(Sprite)
let starPath = ""
if(this._data.end_star == 3) {
starPath = "lv_23"
} else if (this._data.end_star < i) {
starPath = "lv_21"
} else {
starPath = "lv_22"
}
ResManager.I.changeBundleSpriteFrame(starSpt, starPath, "Zhujiemian")
}
//成功失败
let iswin = this._data.end_star > 0
let endPath = iswin ? "lv_19" : "lv_20"
let winSpt = this._nodeTab.winSpt.getComponent(Sprite)
ResManager.I.changeBundleSpriteFrame(winSpt, endPath, "Zhujiemian")
if (iswin) {
AudioManager.I.PlayEffect(10003); //胜利音效
} else {
AudioManager.I.PlayEffect(10001); //失败音效
}
//结算显示
let picPath = "" //表情图
let talkStr = "" //对话
if (this._data.end_star == 3) {
picPath = `cg3/${lvCfg.threeStarCG}`
talkStr = lvCfg.threeStarSummary
} else if (this._data.end_star == 2) {
picPath = `cg2/${lvCfg.twoStarCG}`
talkStr = lvCfg.twoStarSummary
} else if (this._data.end_star == 1) {
picPath = `cg1/${lvCfg.oneStarCG}`
talkStr = lvCfg.oneStarSummary
} else {
picPath = `cg0/${lvCfg.failureCG}`
talkStr = lvCfg.failureSummary
}
let cgPic = this._nodeTab.cgPic.getComponent(Sprite)
ResManager.I.changeBundleSpriteFrame(cgPic, picPath, "Raw")
Utils.setString(this._nodeTab.labTalk, talkStr)
}
update(deltaTime: number) {
}
/**肖像放大缩小 */
changePicScale() {
let ttime = 0.3;
GameRootUI.DisableOper(ttime+0.1)
if (this.isPicFull) {
this.isPicFull = false;
tween((this._nodeTab.cgPic as Node))
.to(ttime, { scale: this.picDefScale }, { easing: 'quadOut' })
.start();
let hideNodeOpa:UIOpacity = this._nodeTab.hideNode.getComponent(UIOpacity)
tween(hideNodeOpa)
.delay(ttime*0.7)
.to(ttime*0.3, { opacity: 255 }, { easing: 'quadOut' })
.start();
} else {
this.isPicFull = true;
let s = 1
let windowSize = view.getVisibleSize(); // 获取窗口大小
let picTf:UITransform = this._nodeTab.cgPic.getComponent(UITransform);
if (picTf.height < windowSize.height) {
s = windowSize.height / picTf.height;
}
tween((this._nodeTab.cgPic as Node))
.to(ttime, { scale: new Vec3(s, s, s) }, { easing: 'quadOut' })
.start();
let hideNodeOpa:UIOpacity = this._nodeTab.hideNode.getComponent(UIOpacity)
tween(hideNodeOpa)
.to(ttime*0.3, { opacity: 0 }, { easing: 'quadOut' })
.start();
}
}
}