218 lines
7.1 KiB
Plaintext
218 lines
7.1 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';
|
|
import { SDKManager } from '../../Main/Channel/SDKManager';
|
|
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);
|
|
|
|
GButton.BandClick(this._nodeTab.btnShare, ()=>{
|
|
SDKManager.show_reward_share(this.node.uuid, 1)
|
|
}, this);
|
|
|
|
this._nodeTab.btnShare.active = true
|
|
SDKManager.register_share_reward(this.node.uuid, (tag:number)=>{
|
|
console.log("结算界面分享回调", tag)
|
|
if (tag == 1) {
|
|
this._nodeTab.btnShare.active = false
|
|
}
|
|
})
|
|
|
|
let lvCfg = GameManager.getLevelCfg(GameManager.CurLevelId)
|
|
|
|
//星级
|
|
for (let i = 1; i <= 3; i++) {
|
|
let starSpt = this._nodeTab["star" + i].getComponent(Sprite)
|
|
let starPath = ""
|
|
let showAct = false
|
|
if(this._data.end_star == 3) {
|
|
starPath = "lv_23"
|
|
showAct = true
|
|
} else if (this._data.end_star < i) {
|
|
starPath = "lv_21"
|
|
} else {
|
|
starPath = "lv_22"
|
|
showAct = true
|
|
}
|
|
ResManager.I.changeBundleSpriteFrame(starSpt, starPath, "Zhujiemian")
|
|
//动作
|
|
let starNode = this._nodeTab["starNode"+i]
|
|
if (showAct) {
|
|
this.doStarAction1(starNode, (i-1)*0.2)
|
|
} else {
|
|
this.doStarAction2(starNode, (i-1)*0.2)
|
|
}
|
|
}
|
|
|
|
//成功失败
|
|
let iswin = this._data.status == 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();
|
|
}
|
|
}
|
|
|
|
|
|
/**星星动作 */
|
|
private doStarAction1(node:Node, tdelay:number) {
|
|
let ttime = 0.5;
|
|
//透明效果
|
|
let opa = node.getComponent(UIOpacity)
|
|
if (!opa) {
|
|
opa = node.addComponent(UIOpacity)
|
|
}
|
|
opa.opacity = 0
|
|
tween(opa)
|
|
.delay(tdelay)
|
|
.to(ttime, { opacity: 255 }, { easing: 'quadIn' })
|
|
.start();
|
|
|
|
//缩放效果
|
|
node.setScale(new Vec3(3, 3, 3))
|
|
tween(node)
|
|
.delay(tdelay)
|
|
.to(ttime, { scale: new Vec3(1, 1, 1) }, { easing: 'quadIn' })
|
|
.start();
|
|
|
|
//旋转效果
|
|
tween(node)
|
|
.delay(tdelay)
|
|
// .to(ttime, { angle: 720 }, { easing: 'quadOut' })
|
|
.to(ttime, { eulerAngles: new Vec3(0, 0, 360) }, { easing: 'quadIn' })
|
|
.start();
|
|
}
|
|
private doStarAction2(node:Node, tdelay:number) {
|
|
let ttime = 0.5;
|
|
//透明效果
|
|
let opa = node.getComponent(UIOpacity)
|
|
if (!opa) {
|
|
opa = node.addComponent(UIOpacity)
|
|
}
|
|
opa.opacity = 0
|
|
tween(opa)
|
|
.delay(tdelay)
|
|
.to(ttime, { opacity: 255 }, { easing: 'quadIn' })
|
|
.start();
|
|
|
|
//缩放效果
|
|
tween(node)
|
|
.delay(tdelay)
|
|
.to(ttime*0.5, { scale: new Vec3(1.3, 1.3, 1.3) }, { easing: 'quadIn' })
|
|
.to(ttime*0.5, { scale: new Vec3(1, 1, 1) }, { easing: 'quadOut' })
|
|
.start();
|
|
}
|
|
}
|
|
|
|
|