60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
import type { TrophyRecord } from "../../types/global"
|
|
import { config } from "../../constants/config"
|
|
import { MONTH_LIST } from "../../models/DCManager"
|
|
import { ResourceManager } from "../../models/ResourceManager"
|
|
import { Utility_EaseOut_2 } from "../../utils/utility"
|
|
|
|
const { regClass, property } = Laya
|
|
|
|
@regClass()
|
|
export class TrophyClaim 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
|
|
|
|
private mask: Laya.Image
|
|
private center: Laya.Box
|
|
|
|
onAwake(): void {
|
|
this.mask = this.owner.getChildByName("Image") as Laya.Image
|
|
this.mask.alpha = 0
|
|
Laya.Tween.to(this.mask, {alpha: 0.8}, 600)
|
|
|
|
this.center = this.owner.getChildByName("center") as Laya.Box
|
|
this.center.scaleX = 0
|
|
this.center.scaleY = 0
|
|
Laya.Tween.to(this.center, {scaleX: 1, scaleY: 1}, 200, Utility_EaseOut_2, null, 200)
|
|
|
|
const label_titlle = this.center.getChildByName("label_titlle") as Laya.Label
|
|
label_titlle.alpha = 0
|
|
Laya.Tween.to(label_titlle, {alpha: 1}, 600, Laya.Ease.linearNone, null, 600)
|
|
|
|
const btn_close = this.center.getChildByName("btn_close") as Laya.Box
|
|
btn_close.alpha = 0
|
|
Laya.Tween.to(btn_close, {alpha: 1}, 600, Laya.Ease.linearNone, null, 800)
|
|
}
|
|
|
|
public onSetShow(record: TrophyRecord): void {
|
|
for (let i = 0; i < MONTH_LIST.length; i++) {
|
|
const obj = MONTH_LIST[i]
|
|
if (obj.year === record.year && obj.month === record.month) {
|
|
ResourceManager.getInstance().loadTexture(obj.icon_res, this.icon)
|
|
break
|
|
}
|
|
}
|
|
|
|
this.label_date.text = `${config.MONTH_ABBRS[record.month - 1]} ${record.day},${record.year}`
|
|
|
|
this.btn_close.on(Laya.Event.CLICK, this, () => {
|
|
this.owner.destroy()
|
|
})
|
|
}
|
|
}
|