添加奖杯库
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
export const respath = {
|
||||
home_ui_res: "resources/Home.lh",
|
||||
dc_ui_res: "resources/DailyChallenge.lh",
|
||||
trophy_ui_res: "resources/TrophyRoom.lh",
|
||||
stage_ui_res: "resources/Stage.lh",
|
||||
gameover_ui_res: "resources/GameOver.lh",
|
||||
gamedone_ui_res: "resources/GameDone.lh",
|
||||
|
||||
@@ -43,6 +43,13 @@ export class UIManager extends Laya.Script {
|
||||
})
|
||||
}
|
||||
|
||||
public loadTrophyUI(): void {
|
||||
Laya.loader.load(respath.trophy_ui_res).then((go)=>{
|
||||
var prefab = go.create()
|
||||
this.getUIRoot().addChild(prefab)
|
||||
})
|
||||
}
|
||||
|
||||
public loadStageUI(stageID: string): void {
|
||||
if (this.stage) {
|
||||
this.stage.onLoadStage(StorageManager.getInstance().loadStage(stageID))
|
||||
|
||||
@@ -14,6 +14,8 @@ export class DailyChallenge extends Laya.Script {
|
||||
|
||||
@property(Laya.Button)
|
||||
public btn_back: Laya.Button
|
||||
@property(Laya.Image)
|
||||
public btn_trophy: Laya.Image
|
||||
|
||||
@property(Laya.Image)
|
||||
public bg_dc: Laya.Image;
|
||||
@@ -52,6 +54,9 @@ export class DailyChallenge extends Laya.Script {
|
||||
UIManager.getInstance().loadHomeUI()
|
||||
this.owner.destroy()
|
||||
})
|
||||
this.btn_trophy.on(Laya.Event.CLICK, this, ()=>{
|
||||
UIManager.getInstance().loadTrophyUI()
|
||||
})
|
||||
var dayBegin = 4
|
||||
var dayCount = 31
|
||||
var user = StorageManager.getInstance().getUser()
|
||||
|
||||
38
src/views/TrophyRoom.ts
Normal file
38
src/views/TrophyRoom.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
|
||||
|
||||
import { TrophyUnit } from "./TrophyUnit";
|
||||
|
||||
const { regClass, property } = Laya;
|
||||
|
||||
@regClass()
|
||||
export class TrophyRoom extends Laya.Script {
|
||||
declare owner : Laya.Box;
|
||||
|
||||
@property(Laya.Button)
|
||||
public btn_back: Laya.Button;
|
||||
|
||||
@property(Laya.Box)
|
||||
public obj_items: Laya.Box;
|
||||
private items: Array<TrophyUnit> = new Array()
|
||||
|
||||
//第一次执行update之前执行,只会执行一次
|
||||
onStart(): void {
|
||||
|
||||
this.btn_back.on(Laya.Event.CLICK, this, ()=>{
|
||||
this.owner.destroy()
|
||||
})
|
||||
|
||||
var month = 5
|
||||
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 obj = hbox.getChildAt(j).getComponent(TrophyUnit)
|
||||
this.items.push(obj)
|
||||
obj.onInit(2025, month)
|
||||
month ++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
3
src/views/TrophyRoom.ts.meta
Normal file
3
src/views/TrophyRoom.ts.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"uuid": "554595b0-0dd8-4e4b-8073-8d775219659c"
|
||||
}
|
||||
24
src/views/TrophyUnit.ts
Normal file
24
src/views/TrophyUnit.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { config } from "../constants/config";
|
||||
import { StorageManager } from "../models/StorageManager";
|
||||
|
||||
const { regClass, property } = Laya;
|
||||
|
||||
@regClass()
|
||||
export class TrophyUnit extends Laya.Script {
|
||||
declare owner : Laya.Box;
|
||||
|
||||
@property(Laya.Image)
|
||||
public icon: Laya.Image;
|
||||
@property(Laya.Label)
|
||||
public label_count: Laya.Label;
|
||||
@property(Laya.Label)
|
||||
public label_month: Laya.Label;
|
||||
|
||||
public onInit(year: number, month: number): void {
|
||||
var user = StorageManager.getInstance().getUser()
|
||||
var starCount = user.get_doneCountBydate(year, month)
|
||||
this.label_count.text = `${starCount}/31`
|
||||
this.label_month.text = config.MONTH_ABBRS[month-1]
|
||||
|
||||
}
|
||||
}
|
||||
3
src/views/TrophyUnit.ts.meta
Normal file
3
src/views/TrophyUnit.ts.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"uuid": "79064920-30a6-4b11-a82e-bbdd4112c4e1"
|
||||
}
|
||||
Reference in New Issue
Block a user