complete dc logic
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
|
||||
import { config } from "../constants/config";
|
||||
import { respath } from "../constants/respath";
|
||||
import { TrophyUnit } from "./TrophyUnit";
|
||||
|
||||
const { regClass, property } = Laya;
|
||||
@@ -15,7 +16,6 @@ export class TrophyRoom extends Laya.Script {
|
||||
|
||||
@property(Laya.Box)
|
||||
public obj_items: Laya.Box;
|
||||
private items: Array<TrophyUnit> = new Array()
|
||||
|
||||
//第一次执行update之前执行,只会执行一次
|
||||
onStart(): void {
|
||||
@@ -24,34 +24,80 @@ export class TrophyRoom extends Laya.Script {
|
||||
this.owner.destroy()
|
||||
})
|
||||
|
||||
var list: Array<any> = new Array()
|
||||
var infos: Array<any> = new Array()
|
||||
var now = new Date()
|
||||
var nowYear = now.getFullYear()
|
||||
var nowMonth = now.getMonth() + 1
|
||||
for (var i=0; i<config.MONTH_LIST.length; i++) {
|
||||
var obj = config.MONTH_LIST[i]
|
||||
list.push(obj)
|
||||
infos.push(obj)
|
||||
if (obj.year == nowYear && obj.month == nowMonth) {
|
||||
break
|
||||
}
|
||||
}
|
||||
list.reverse()
|
||||
infos.reverse()
|
||||
|
||||
var index = -1
|
||||
for (var i=0; i<this.obj_items.numChildren; i++) {
|
||||
var hbox = this.obj_items.getChildAt(i).getChildByName("HBox")
|
||||
for (var j=0; j<hbox.numChildren; j++) {
|
||||
var unit = hbox.getChildAt(j).getComponent(TrophyUnit)
|
||||
index ++
|
||||
if (index < list.length) {
|
||||
unit.owner.visible = true
|
||||
unit.onInit(list[index])
|
||||
}
|
||||
else {
|
||||
unit.owner.visible = false
|
||||
var years: Array<number> = new Array()
|
||||
var monthMap: Map<number, Array<any>> = new Map()
|
||||
for (var i=0; i<infos.length; i++) {
|
||||
obj = infos[i]
|
||||
if (years.indexOf(obj.year) < 0) {
|
||||
years.push(obj.year)
|
||||
}
|
||||
if (monthMap.has(obj.year)== false) {
|
||||
monthMap.set(obj.year, new Array())
|
||||
}
|
||||
var list = monthMap.get(obj.year)
|
||||
list.push(obj)
|
||||
}
|
||||
console.log(">>>>>>>>>>>>years=", years)
|
||||
Laya.loader.load(respath.trophy_year_ui_res).then((go)=>{
|
||||
for (var i=1; i<years.length; i++) {
|
||||
var obj_year = this.obj_items.getChildAt(i)
|
||||
if (!obj_year) {
|
||||
var prefab = go.create()
|
||||
this.obj_items.addChild(prefab)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Laya.loader.load(respath.trophy_cell_ui_res).then((go)=>{
|
||||
var itemsHeight = 0
|
||||
for (var i=0; i<years.length; i++) {
|
||||
var list = monthMap.get(years[i])
|
||||
var cellCount = Math.ceil(list.length/3)
|
||||
var yearHeight = 120 + cellCount * 444
|
||||
itemsHeight += yearHeight
|
||||
|
||||
var obj_year = this.obj_items.getChildAt(i) as Laya.Box
|
||||
obj_year.height = yearHeight
|
||||
var label = obj_year.getChildByName("year").getChildByName("Label") as Laya.Label
|
||||
label.text = years[i].toString()
|
||||
|
||||
var index = -1
|
||||
for (var j=1; j<cellCount+1; j++) {
|
||||
var obj_cell = obj_year.getChildAt(j)
|
||||
if (!obj_cell) {
|
||||
var prefab = go.create()
|
||||
obj_cell = obj_year.addChild(prefab)
|
||||
}
|
||||
var hbox = obj_cell.getChildByName("HBox")
|
||||
for (var k=0; k<hbox.numChildren; k++) {
|
||||
var unit = hbox.getChildAt(k).getComponent(TrophyUnit)
|
||||
index ++
|
||||
if (index < list.length) {
|
||||
unit.owner.visible = true
|
||||
unit.onInit(list[index])
|
||||
}
|
||||
else {
|
||||
unit.owner.visible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.obj_items.height = itemsHeight
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
19
src/views/TrophyShow.ts
Normal file
19
src/views/TrophyShow.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
const { regClass, property } = Laya;
|
||||
|
||||
@regClass()
|
||||
export class TrophyShow extends Laya.Script {
|
||||
declare owner : Laya.Box;
|
||||
|
||||
@property(Laya.Image)
|
||||
public icon: Laya.Image
|
||||
|
||||
@property(Laya.Label)
|
||||
public label_date: Laya.Label
|
||||
|
||||
@property(Laya.Box)
|
||||
public btn_close: Laya.Box
|
||||
|
||||
public onSetShow(): void {
|
||||
|
||||
}
|
||||
}
|
||||
3
src/views/TrophyShow.ts.meta
Normal file
3
src/views/TrophyShow.ts.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"uuid": "42f2370b-c65c-4119-8725-6d4520582431"
|
||||
}
|
||||
@@ -33,5 +33,9 @@ export class TrophyUnit extends Laya.Script {
|
||||
this.icon.gray = true
|
||||
this.label_month.color = "#a7abb3"
|
||||
}
|
||||
|
||||
this.icon.on(Laya.Event.CLICK, this, ()=>{
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user