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.
129 lines
5.5 KiB
129 lines
5.5 KiB
//#region 文件引入
|
|
import { _decorator, Button, Component, Label, Node, sp, Sprite,Animation, RichText, instantiate, Layout, Widget } from "cc";
|
|
import BaseUIForm from "../../Mgr_UI/BaseUIForm";
|
|
import FrameScrollView from "../../CComEx/FrameScrollView";
|
|
import ResLoad from "../../ResUrl/ResLoad";
|
|
import { EResUrls } from "../../ResUrl/EResUrls";
|
|
import { EBundleName } from "../../const/GameEnum";
|
|
import buildItem_Proxy from "./buildItem_Proxy";
|
|
import BuildDataPoxy from "../../const/BuildDataPoxy";
|
|
import CsvMgr from "../../Mgr_CSV/CsvMgr";
|
|
import { IBuilds } from "../../Mgr_CSV/CsvEnum";
|
|
import UIMgr from "../../Mgr_UI/UIMgr";
|
|
//#endregion 文件引入
|
|
const {ccclass, property,menu} = _decorator;
|
|
@ccclass("InvestUI_Proxy")
|
|
export default class InvestUI_Proxy extends BaseUIForm{
|
|
//#region 节点自动生成
|
|
//#endregion 节点自动生成
|
|
|
|
@property(Node)
|
|
mConView:Node;
|
|
@property(Node)
|
|
mContent:Node;
|
|
|
|
private orgHight:number =0 ;
|
|
private mlist:Node[] = [];
|
|
|
|
private Builds:string[]= [];
|
|
private mBuildItems:Map<number,buildItem_Proxy> = new Map();
|
|
onButtonClick(button:Button){
|
|
/**点击事件触发*/
|
|
switch (button) {
|
|
default:
|
|
ConsoleEx.Log(button);
|
|
break;
|
|
}
|
|
}
|
|
addEvent(): void {
|
|
this.Builds = Object.keys(CsvMgr.Builds_csv);
|
|
}
|
|
|
|
private createNode(idx:number,max:number){
|
|
if (idx >= max) {
|
|
return;
|
|
}
|
|
ResLoad.Ins.Perfab(EResUrls.UIChildPrefabs(`buildItem_${idx + 1}`), EBundleName.UIPackage, (e, res) => {
|
|
if (!this.isValid) { return; }
|
|
if (!res) { return; }
|
|
let tNode = instantiate(res);
|
|
tNode.setParent(this.mContent);
|
|
this.checkLayout(idx + 1, max);
|
|
this.ItemRenderer(idx, tNode);
|
|
this.mlist.push(tNode);
|
|
this.createNode(idx + 1, max);
|
|
});
|
|
}
|
|
|
|
checkLayout(idx:number,max:number){
|
|
const tLayout: Layout = this.mContent.getComponent(Layout);
|
|
if (idx >= max) {
|
|
if (max < 4) {
|
|
tLayout.updateLayout();
|
|
this.mContent.uiTrans.setContentSize(this.mContent.uiTrans.width, this.orgHight);
|
|
this.mConView.uiTrans.setContentSize(this.mConView.uiTrans.width, this.orgHight);
|
|
this.mConView.getComponent(Widget).updateAlignment();
|
|
this.mContent.getComponent(Widget)?.updateAlignment();
|
|
tLayout.enabled = false;
|
|
} else {
|
|
this.mConView.getComponent(Widget).isAlignTop = true;
|
|
this.mConView.getComponent(Widget).updateAlignment();
|
|
tLayout.enabled = true;
|
|
}
|
|
} else {
|
|
if (idx > 0) {
|
|
tLayout.updateLayout();
|
|
this.mConView.getComponent(Widget).isAlignTop = false;
|
|
this.mConView.uiTrans.setContentSize(this.mConView.uiTrans.width, Math.min(this.mContent.uiTrans.height, this.orgHight));
|
|
this.mConView.getComponent(Widget).updateAlignment();
|
|
this.mContent.getComponent(Widget)?.updateAlignment();
|
|
}
|
|
}
|
|
}
|
|
|
|
protected start(): void {
|
|
this.mConView.getComponent(Widget).updateAlignment();
|
|
this.orgHight = this.mConView.uiTrans.height;
|
|
this.createNode(0, 3);
|
|
this.reflashList();
|
|
}
|
|
|
|
reflashList(){
|
|
for (let i = 0; i < this.mlist.length; i++) {
|
|
let tNode = this.mlist[i];
|
|
this.ItemRenderer(i,tNode);
|
|
}
|
|
}
|
|
|
|
ItemRenderer(idx:number,tNode:Node){
|
|
let isLeft = idx % 2 == 0;
|
|
const bid = this.Builds[idx];
|
|
const BuildConfig:IBuilds = CsvMgr.Builds_csv[bid];
|
|
tNode.setPosition(isLeft ? -130 : 130, tNode.position.y)
|
|
let classPoxy: buildItem_Proxy = tNode.getComponent(buildItem_Proxy);
|
|
classPoxy.setBuildData(BuildConfig.id);
|
|
!this.mBuildItems.has(BuildConfig.id) && this.mBuildItems.set(BuildConfig.id, classPoxy);
|
|
// const isUnLock = this.mDataMgr.Build.hasBuilding(BuildConfig.id);
|
|
// if(isUnLock){
|
|
// const BuildPoxy = this.mDataMgr.Build.getBuildPoxy(BuildConfig.id);
|
|
// CNodeUtils.setActive(classPoxy.n_Info, BuildPoxy.running);
|
|
// CNodeUtils.setActive(classPoxy.n_open, !BuildPoxy.running);
|
|
// CNodeUtils.switchText(classPoxy.lab_Lv,`lv.${BuildPoxy.level}`)
|
|
// CNodeUtils.switchText(classPoxy.lab_CoinSecond,`${BuildPoxy.income}两/秒`)
|
|
// CNodeUtils.switchText(classPoxy.lab_addCoin,`+${BuildPoxy.add}两/秒`)
|
|
// CNodeUtils.addBtnComponent(classPoxy.btn_UpBuild.node,this.BuildClick.bind(this,BuildConfig.id),this)
|
|
// }else{
|
|
// CNodeUtils.setActive(classPoxy.n_Info, false);
|
|
// CNodeUtils.setActive(classPoxy.n_open, false);
|
|
// CNodeUtils.addNoScaleBtnComponent(tNode,this.ShowLockTips.bind(this,BuildConfig.id),this)
|
|
// }
|
|
}
|
|
// ShowLockTips(bid:number){
|
|
// UIMgr.Ins.ShowTipsUI("未解锁")
|
|
// }
|
|
|
|
// BuildClick(bid:number){
|
|
// const BuildPoxy = this.mDataMgr.Build.getBuildPoxy(bid);
|
|
|
|
// }
|
|
}
|