complete dc logic

This commit is contained in:
2025-05-22 10:55:37 +08:00
parent 64868a980f
commit 16a5eb9e6b
50 changed files with 811 additions and 695 deletions

View File

@@ -39,6 +39,7 @@ export const config = {
MONTH_FULLNAMES: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
MONTH_LIST: [
{year: 2024, month: 12, begin: 0, dayCount: 31, icon_res: respath.trophy_12},
{year: 2025, month: 1, begin: 3, dayCount: 31, icon_res: respath.trophy_01},
{year: 2025, month: 2, begin: 6, dayCount: 30, icon_res: respath.trophy_02},
{year: 2025, month: 3, begin: 6, dayCount: 31, icon_res: respath.trophy_03},
@@ -47,10 +48,10 @@ export const config = {
{year: 2025, month: 6, begin: 0, dayCount: 30, icon_res: respath.trophy_06},
{year: 2025, month: 7, begin: 2, dayCount: 31, icon_res: respath.trophy_07},
{year: 2025, month: 8, begin: 5, dayCount: 31, icon_res: respath.trophy_08},
{year: 2025, month: 9, begin: 1, dayCount: 30, icon_res: respath.trophy_01},
{year: 2025, month: 10, begin: 3, dayCount: 31, icon_res: respath.trophy_02},
{year: 2025, month: 11, begin: 6, dayCount: 30, icon_res: respath.trophy_03},
{year: 2025, month: 12, begin: 1, dayCount: 31, icon_res: respath.trophy_04},
{year: 2025, month: 9, begin: 1, dayCount: 30, icon_res: respath.trophy_09},
{year: 2025, month: 10, begin: 3, dayCount: 31, icon_res: respath.trophy_10},
{year: 2025, month: 11, begin: 6, dayCount: 30, icon_res: respath.trophy_11},
{year: 2025, month: 12, begin: 1, dayCount: 31, icon_res: respath.trophy_12},
]
}

View File

@@ -4,6 +4,8 @@ export const respath = {
home_ui_res: "resources/Home.lh",
dc_ui_res: "resources/DailyChallenge.lh",
trophy_ui_res: "resources/TrophyRoom.lh",
trophy_year_ui_res: "resources/TrophyRoomYear.lh",
trophy_cell_ui_res: "resources/TrophyRoomCell.lh",
stage_ui_res: "resources/Stage.lh",
gameover_ui_res: "resources/GameOver.lh",
gamedone_ui_res: "resources/GameDone.lh",
@@ -30,5 +32,9 @@ export const respath = {
trophy_06: "atlas/trophys/trophy_06.png",
trophy_07: "atlas/trophys/trophy_07.png",
trophy_08: "atlas/trophys/trophy_08.png",
trophy_09: "atlas/trophys/trophy_09.png",
trophy_10: "atlas/trophys/trophy_10.png",
trophy_11: "atlas/trophys/trophy_11.png",
trophy_12: "atlas/trophys/trophy_12.png",
}

View File

@@ -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
View 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 {
}
}

View File

@@ -0,0 +1,3 @@
{
"uuid": "42f2370b-c65c-4119-8725-6d4520582431"
}

View File

@@ -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, ()=>{
})
}
}