153 lines
5.2 KiB
TypeScript
153 lines
5.2 KiB
TypeScript
import { _decorator, Button, Component, instantiate, Label, Node, Prefab, tween, UIOpacity, UITransform } from "cc";
|
|
import { AreanNetMgr } from "../../AreanNetMgr";
|
|
import { areanMgr } from "../../AreanManager";
|
|
import { UIDanChange } from "db://assets/module_arean/ui_dan_change/UIDanChange";
|
|
import { UserMgr } from "db://assets/module_basic/scripts/UserMgr";
|
|
import { CommonFun } from "db://assets/module_arean/scripts/CommonFun";
|
|
import {EFightModel, IRewardData} from "db://assets/module_basic/shared/protocols/public/arean/AreanTypeDef";
|
|
import { resLoader } from "db://assets/core_tgx/base/utils/ResLoader";
|
|
import { ModuleDef } from "db://assets/scripts/ModuleDef";
|
|
import { UserLocalCache } from "db://assets/module_basic/scripts/UserLocalCache";
|
|
import {RewardItem} from "db://assets/module_arean/ui_common_reward/RewardItem";
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('settlementView')
|
|
export class settlementView extends Component {
|
|
@property(Node)
|
|
spineRole: Node;
|
|
|
|
@property(Button)
|
|
btnContinue: Button;
|
|
|
|
@property(Button)
|
|
btnExit: Button;
|
|
|
|
|
|
@property(Label)
|
|
rankLabel: Label;
|
|
|
|
@property(Node)
|
|
danTips: Node;
|
|
|
|
@property(Node)
|
|
starNode: Node;
|
|
|
|
@property(Node)
|
|
rewardNode: Node;
|
|
|
|
private _curRank: number = 0;
|
|
private _curDanInfo: any = null;
|
|
|
|
public setData(rank: number) {
|
|
this._curRank = rank;
|
|
this.rankLabel.string = rank + "";
|
|
|
|
|
|
let role = areanMgr.BattleView.seatRole[areanMgr.BattleView.getLocalPlayerId()];
|
|
let newNode = new Node();
|
|
if (role) {
|
|
newNode = instantiate(role.node);
|
|
newNode.active = true;
|
|
newNode.setScale(1, 1);
|
|
newNode.setPosition(0, 0);
|
|
newNode.setParent(this.spineRole);
|
|
role.roleNode.getChildByName("effectNode").removeAllChildren();
|
|
}
|
|
}
|
|
|
|
public updateDan(danInfo: any): void {
|
|
console.log("游戏结算界面 === ",UserLocalCache.inst.fightModel,EFightModel.Ranking,danInfo);
|
|
if (UserLocalCache.inst.fightModel === EFightModel.Ranking) {
|
|
if (danInfo) this._updateDanInfo(danInfo)
|
|
}
|
|
}
|
|
|
|
// 更新段位
|
|
private _updateDanInfo(danInfo: any): void {
|
|
// let danInfo = _danInfo || {
|
|
// // 当前段位
|
|
// curDan : 1,
|
|
// // 本局获得的星星数
|
|
// changeStar : 2,
|
|
// // 当前星星数
|
|
// curAllStar : 3
|
|
// };
|
|
this._curDanInfo = danInfo;
|
|
console.log("段位变化的数据 ==== ", this._curDanInfo)
|
|
this.danTips.active = danInfo.changeStar === 0;
|
|
if (danInfo.changeStar > 0) {
|
|
let action = (node: Node, time: number) => {
|
|
tween(node.getComponent(UIOpacity))
|
|
.delay(time)
|
|
.to(0.1, { opacity: 255 })
|
|
.start();
|
|
}
|
|
this.starNode.active = true;
|
|
let star1 = this.starNode.getChildByName("star_1");
|
|
star1.getComponent(UIOpacity).opacity = 0;
|
|
let star2 = this.starNode.getChildByName("star_2");
|
|
star2.getComponent(UIOpacity).opacity = 0;
|
|
for (let i = 0; i < danInfo.changeStar; i++) {
|
|
let star = this.starNode.getChildByName(`star_${i + 1}`);
|
|
star.getComponent(UIOpacity).opacity = 0;
|
|
action(star, 0.1 * (i + 1));
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
closeWin() {
|
|
this.node.removeFromParent();
|
|
}
|
|
|
|
|
|
exitGame() {
|
|
if (UserLocalCache.inst.fightModel === EFightModel.Ranking && this._curDanInfo) {
|
|
UserMgr.inst.userInfo.danGrading = this._curDanInfo.curAllStar;
|
|
let danInfo = CommonFun.getInstance().calDanData(UserMgr.inst.userInfo.danGrading);
|
|
let danData = areanMgr.cfgMgr.DanData.getData(danInfo.curDan);
|
|
let obj = {
|
|
name: "",
|
|
changeStar: this._curDanInfo.changeStar,
|
|
icon: "",
|
|
curRank: this._curRank
|
|
};
|
|
if (danInfo) {
|
|
obj.name = danData.danName;
|
|
obj.changeStar = this._curDanInfo.changeStar;
|
|
obj.icon = danData.danIcon;
|
|
obj.curRank = this._curRank;
|
|
} else {
|
|
console.error("段位信息没有找到", this._curDanInfo.curAllStar)
|
|
}
|
|
// tgxUIMgr.inst.showUI(UIDanChange,()=>{
|
|
// this.closeWin();
|
|
// },null,obj);
|
|
|
|
const path = 'res/Prefebs/DanChange';
|
|
let sp: Prefab = resLoader.get(path, Prefab, ModuleDef.Arean);
|
|
let node = instantiate(sp);
|
|
areanMgr.BattleView.node.addChild(node);
|
|
node.getComponent(UIDanChange).initData(obj);
|
|
this.closeWin();
|
|
} else {
|
|
AreanNetMgr.inst.sendMsg_exit();
|
|
}
|
|
}
|
|
|
|
/** 展示奖励 */
|
|
public updateRewards(items : IRewardData[]) : void{
|
|
let len = items.length;
|
|
for (let i = 0; i < len; i++) {
|
|
let data = items[0];
|
|
let node = this.rewardNode.getChildByName(`RewardItem_${i + 1}`);
|
|
node.active = true;
|
|
node.getComponent(RewardItem).initData(data);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|