add trophy logic
This commit is contained in:
@@ -5,6 +5,7 @@ import { CalendarUnit } from "./CalendarUnit";
|
||||
import { LevelManager } from "../models/LevelManager";
|
||||
import { UIManager } from "../models/UIManager";
|
||||
import { respath } from "../constants/respath";
|
||||
import { MONTH_LIST } from "../models/DCManager";
|
||||
|
||||
|
||||
const { regClass, property } = Laya;
|
||||
@@ -16,6 +17,8 @@ export class DailyChallenge extends Laya.Script {
|
||||
public btn_back: Laya.Button
|
||||
@property(Laya.Image)
|
||||
public btn_trophy: Laya.Image
|
||||
@property(Laya.Sprite)
|
||||
public btn_trophy_red: Laya.Sprite
|
||||
@property(Laya.Image)
|
||||
public icon_trophy: Laya.Image
|
||||
@property(Laya.Box)
|
||||
@@ -62,9 +65,15 @@ export class DailyChallenge extends Laya.Script {
|
||||
UIManager.getInstance().loadHomeUI()
|
||||
this.owner.destroy()
|
||||
})
|
||||
|
||||
var user = StorageManager.getInstance().getUser()
|
||||
this.btn_trophy_red.visible = user.get_trophyHasUnread()
|
||||
this.btn_trophy.on(Laya.Event.CLICK, this, ()=>{
|
||||
user.set_trophyAllread()
|
||||
this.btn_trophy_red.visible = false
|
||||
UIManager.getInstance().loadTrophyUI()
|
||||
})
|
||||
|
||||
this.btn_play.on(Laya.Event.CLICK, this, (evt: Laya.Event)=>{
|
||||
// console.log(">>>>>>>>>>>>>>>>>>>>>>>", this.selectedUnit.day)
|
||||
var now = new Date()
|
||||
@@ -99,12 +108,12 @@ export class DailyChallenge extends Laya.Script {
|
||||
}
|
||||
}
|
||||
|
||||
this.indexMax = config.MONTH_LIST.length - 1
|
||||
this.indexMax = MONTH_LIST.length - 1
|
||||
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]
|
||||
for (var i=0; i<MONTH_LIST.length; i++) {
|
||||
var obj = MONTH_LIST[i]
|
||||
if (nowYear == obj.year && nowMonth == obj.month) {
|
||||
this.indexMax = i;
|
||||
break
|
||||
@@ -129,8 +138,8 @@ export class DailyChallenge extends Laya.Script {
|
||||
var nowYear = now.getFullYear()
|
||||
var nowMonth = now.getMonth() + 1
|
||||
this.currentIndex = 0
|
||||
for (var i=0; i<config.MONTH_LIST.length; i++) {
|
||||
var obj = config.MONTH_LIST[i]
|
||||
for (var i=0; i<MONTH_LIST.length; i++) {
|
||||
var obj = MONTH_LIST[i]
|
||||
if (nowYear == obj.year && nowMonth == obj.month) {
|
||||
this.currentIndex = i;
|
||||
break
|
||||
@@ -143,7 +152,7 @@ export class DailyChallenge extends Laya.Script {
|
||||
public loadWithIndex(index: number): void {
|
||||
this.btn_left.visible = this.currentIndex > 0
|
||||
this.btn_right.visible = this.currentIndex < this.indexMax
|
||||
var info = config.MONTH_LIST[index]
|
||||
var info = MONTH_LIST[index]
|
||||
var user = StorageManager.getInstance().getUser()
|
||||
var now = new Date()
|
||||
var nowYear = now.getFullYear()
|
||||
@@ -152,7 +161,7 @@ export class DailyChallenge extends Laya.Script {
|
||||
|
||||
this.icon_trophy.skin = info.icon_res
|
||||
//设置背景
|
||||
var starCount = user.get_doneCountBydate(info.year, info.month)
|
||||
var starCount = user.get_doneCountByDate(info.year, info.month)
|
||||
if (starCount >= info.dayCount) {
|
||||
this.bg_dc.skin = respath.dc_top_bg_month_finish
|
||||
}
|
||||
@@ -249,4 +258,13 @@ export class DailyChallenge extends Laya.Script {
|
||||
var unit = evt.target.getComponent(CalendarUnit)
|
||||
this.onApplyUnit(unit)
|
||||
}
|
||||
|
||||
onStart(): void {
|
||||
var user = StorageManager.getInstance().getUser()
|
||||
var find = user.get_trophyHasNew()
|
||||
if (find) {
|
||||
UIManager.getInstance().loadTrophyClaimUI(find)
|
||||
user.set_trophyNew(find, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user