You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
176 lines
7.1 KiB
176 lines
7.1 KiB
//#region 文件引入
|
|
import { _decorator, Button, Component, Label, Node, sp, Sprite,Animation, RichText } from "cc";
|
|
import BaseUIForm from "../../Mgr_UI/BaseUIForm";
|
|
import FrameScrollView from "../../CComEx/FrameScrollView";
|
|
import FrameLayout from "../../CComEx/FrameLayout";
|
|
import { IData, TrialConfig, TrialRankData } from "../../const/GameInterface";
|
|
import { Global } from "../../Global";
|
|
import rewardrankitem_Proxy from "./rewardrankitem_Proxy";
|
|
import rewardItem_Proxy from "./rewardItem_Proxy";
|
|
import TimeUtils from "../../ExUtils/TimeUtils";
|
|
import { GameTotalType } from "../../const/GameEnum";
|
|
import UIMgr from "../../Mgr_UI/UIMgr";
|
|
import { EUIForms } from "../../const/UIFormCnf";
|
|
import { MainConfig } from "db://assets/Launch/_MainConfig";
|
|
//#endregion 文件引入
|
|
const {ccclass, property,menu} = _decorator;
|
|
@ccclass("FinalTrialReWardUI_Proxy")
|
|
export default class FinalTrialReWardUI_Proxy extends BaseUIForm{
|
|
//#region 节点自动生成
|
|
|
|
@property(Label)
|
|
lab_title: Label = null;
|
|
@property(Label)
|
|
lab_myrank: Label = null;
|
|
@property(Node)
|
|
n_cd: Node = null;
|
|
@property(Label)
|
|
lab_cd: Label = null;
|
|
@property(Label)
|
|
lab_cddesc: Label = null;
|
|
@property(Button)
|
|
btn_get: Button = null;
|
|
@property(Label)
|
|
lab_get: Label = null;
|
|
//#endregion 节点自动生成
|
|
|
|
@property({type:[Node]})
|
|
topNodes:Node[] = [];
|
|
@property(FrameScrollView)
|
|
protected mScrollViewFrame: FrameScrollView;
|
|
@property(FrameLayout)
|
|
protected mMyRewardItems: FrameLayout;
|
|
|
|
private _selectedBoss: number = -1;
|
|
private _currTopRewardRank: TrialRankData[] = [];
|
|
private _curTrialcfg: TrialConfig = null;
|
|
private _myrewardidx: number = -1;
|
|
|
|
private _leftSec: number = 0;
|
|
|
|
onButtonClick(button:Button){
|
|
|
|
/**点击事件触发*/
|
|
switch (button) {
|
|
case this.btn_get:
|
|
if(this.mDataMgr.Trial.getReward(this._selectedBoss)){
|
|
this.refresh();
|
|
}
|
|
break;
|
|
default:
|
|
ConsoleEx.Log(button);
|
|
break;
|
|
}
|
|
}
|
|
|
|
protected start(): void {
|
|
this._selectedBoss = this.param;
|
|
this.reflashScrollView();
|
|
this.refresh();
|
|
}
|
|
|
|
|
|
protected CloseUI(btn?: Node): void {
|
|
this.unscheduleAllCallbacks();
|
|
super.CloseUI(btn);
|
|
}
|
|
|
|
|
|
addEvent(): void {
|
|
this.mScrollViewFrame.m_ItemRendererFuntion = this.ItemRenderer.bind(this);
|
|
this.mMyRewardItems.m_ItemRendererFuntion = this.MyRewardItemRenderer.bind(this);
|
|
}
|
|
|
|
// 奖励配行榜信息
|
|
ItemRenderer(idx:number,tNode:Node){
|
|
const num = this._curTrialcfg.rewardnum[idx];
|
|
const ClassPoxy: rewardrankitem_Proxy = tNode.getComponent(rewardrankitem_Proxy);
|
|
ClassPoxy.setInfo(idx, this._curTrialcfg.rewardtoken, num);
|
|
}
|
|
|
|
private reflashScrollView(){
|
|
this._curTrialcfg = this.mDataMgr.Trial.getTrialConfig(this._selectedBoss);
|
|
this.mScrollViewFrame.m_ItemCount = this._curTrialcfg.rewardnum.length;
|
|
}
|
|
|
|
// 自己的奖励物品列表
|
|
MyRewardItemRenderer(idx:number,tNode:Node){
|
|
const num = this._curTrialcfg.rewardnum[this._myrewardidx];
|
|
const ClassPoxy: rewardItem_Proxy = tNode.getComponent(rewardItem_Proxy);
|
|
ClassPoxy.setInfo(this._curTrialcfg.rewardtoken, num);
|
|
CNodeUtils.addBtnComponent(tNode, this.ItemClick.bind(this), this);
|
|
}
|
|
private ItemClick() {
|
|
const tData: IData = {
|
|
id: this._curTrialcfg.rewardtoken,
|
|
num: 0,
|
|
type: GameTotalType.TOKEN
|
|
}
|
|
UIMgr.Ins.ShowUI(EUIForms.ShopInfoUI, { param: {tdata: tData} });
|
|
}
|
|
|
|
private refresh(){
|
|
let myrank = 0;
|
|
if(this.mDataMgr.Trial.canGetReWards(this._selectedBoss)){
|
|
CNodeUtils.setActive(this.btn_get, true);
|
|
CNodeUtils.setActive(this.n_cd, false);
|
|
myrank = this.mDataMgr.Trial.getMyReWardrank(this._selectedBoss);
|
|
}else{
|
|
CNodeUtils.setActive(this.btn_get, false);
|
|
CNodeUtils.setActive(this.n_cd, true);
|
|
myrank = this.mDataMgr.Trial.getMyRTRank(this._selectedBoss);
|
|
}
|
|
if(myrank > 0){
|
|
this._leftSec = TimeUtils.GetRemainingTime();
|
|
CNodeUtils.setActive(this.lab_cd, true);
|
|
CNodeUtils.switchText(this.lab_cd, TimeUtils.makeTimeLeftString(this._leftSec));
|
|
CNodeUtils.switchText(this.lab_cddesc, "后可领奖");
|
|
CNodeUtils.switchText(this.lab_myrank, myrank < 500? myrank : "未上榜");
|
|
this._myrewardidx = myrank - 1;
|
|
if(myrank >= 4 && myrank <= 10){
|
|
this._myrewardidx = 3;
|
|
}else if(myrank >= 11 && myrank <= 100){
|
|
this._myrewardidx = 4;
|
|
}else{
|
|
this._myrewardidx = 5;
|
|
}
|
|
this.mMyRewardItems.m_ItemCount = 5;
|
|
if(this.n_cd.active){
|
|
this.schedule(()=>{
|
|
if(--this._leftSec >= 0){
|
|
CNodeUtils.switchText(this.lab_cd, TimeUtils.makeTimeLeftString(this._leftSec));
|
|
}else{
|
|
this._leftSec = 0;
|
|
CNodeUtils.setActive(this.btn_get, true);
|
|
CNodeUtils.setActive(this.n_cd, false);
|
|
this.unscheduleAllCallbacks();
|
|
}
|
|
}, 1)
|
|
}
|
|
}else{
|
|
CNodeUtils.switchText(this.lab_myrank, "未参与");
|
|
CNodeUtils.setActive(this.lab_cd, false);
|
|
CNodeUtils.switchText(this.lab_cddesc, "挑战后才可领奖");
|
|
this.mMyRewardItems.m_ItemCount = 0;
|
|
}
|
|
this.refreshTopRankInfo();
|
|
}
|
|
|
|
private refreshTopRankInfo(){
|
|
this._currTopRewardRank = this.mDataMgr.Trial.getRewardRank(this._selectedBoss);
|
|
for (let i = 0; i < this.topNodes.length; i++){
|
|
let item = this.topNodes[i];
|
|
const data = this._currTopRewardRank[i];
|
|
const name = item.getChildByName("name");
|
|
// const icon = item.getChildByName("icon");
|
|
const hurt = item.getChildByName("hurt");
|
|
if(!data.isPlayer){
|
|
const agent = Global.CsvMgr.Agent_csv[data.idx];
|
|
CNodeUtils.switchText(name, agent.name_cn);
|
|
}else{
|
|
CNodeUtils.switchText(name, (MainConfig.UserInfo.nick_name && MainConfig.UserInfo.nick_name.length > 0)? MainConfig.UserInfo.nick_name : "自己");
|
|
}
|
|
CNodeUtils.switchText(hurt, data.damage);
|
|
}
|
|
}
|
|
}
|