补充每日挑战UI细节
|
Before Width: | Height: | Size: 216 KiB After Width: | Height: | Size: 216 KiB |
BIN
assets/atlas/images/bg_dc_top2.png
Normal file
|
After Width: | Height: | Size: 173 KiB |
6
assets/atlas/images/bg_dc_top2.png.meta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"uuid": "3dc757bc-61c3-480f-9ee1-1b1c57cf028b",
|
||||
"importer": {
|
||||
"textureType": 2
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 539 KiB After Width: | Height: | Size: 539 KiB |
|
Before Width: | Height: | Size: 530 KiB After Width: | Height: | Size: 530 KiB |
@@ -17,6 +17,9 @@
|
||||
"btn_back": {
|
||||
"_$ref": "yvza2lgb"
|
||||
},
|
||||
"bg_dc": {
|
||||
"_$ref": "hdia0flx"
|
||||
},
|
||||
"label_year": {
|
||||
"_$ref": "pohsc0lz"
|
||||
},
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
{
|
||||
"_$type": "f2970e4d-7a09-4a9b-aef3-45d330c86f4f",
|
||||
"scriptPath": "../src/views/Home.ts",
|
||||
"bg_dc": {
|
||||
"_$ref": "7270vjom"
|
||||
},
|
||||
"label_dc_title": {
|
||||
"_$ref": "zbppj6k0"
|
||||
},
|
||||
@@ -71,7 +74,7 @@
|
||||
"name": "bg",
|
||||
"width": 936,
|
||||
"height": 468,
|
||||
"skin": "res://342d91e6-0434-4d52-b16c-3c536060f881",
|
||||
"skin": "res://3dc757bc-61c3-480f-9ee1-1b1c57cf028b",
|
||||
"useSourceSize": true,
|
||||
"color": "#ffffff"
|
||||
},
|
||||
|
||||
@@ -34,8 +34,8 @@ export const config = {
|
||||
BLUE: "#2559c0",
|
||||
},
|
||||
|
||||
MONTH_ABBRS: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
||||
|
||||
MONTH_ABBRS: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
||||
MONTH_FULLNAMES: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,5 +9,12 @@ export const respath = {
|
||||
|
||||
score_add_ui_res: "resources/ScoreAdd.lh",
|
||||
difficulty_ui_res: "resources/Difficulty.lh",
|
||||
|
||||
|
||||
home_top_dc_bg_normal: "atlas/images/bg_dc_top1.png",
|
||||
home_top_dc_bg_finish: "atlas/images/bg_dc_top2.png",
|
||||
dc_top_bg_normal: "atlas/images/img_dc_bg1.png",
|
||||
dc_top_bg_day_finish: "atlas/images/img_dc_bg2.png",
|
||||
dc_top_bg_month_finish: "atlas/images/img_dc_finished.png",
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,14 @@ import { StorageManager } from "./StorageManager"
|
||||
export class DOUser {
|
||||
|
||||
private data: DataUser
|
||||
|
||||
private mapDones: Map<string, number> = new Map()
|
||||
|
||||
constructor(dataUser: DataUser) {
|
||||
this.data = dataUser
|
||||
for (var i=0; i<this.data.dones.length; i++) {
|
||||
var obj = this.data.dones[i]
|
||||
this.mapDones.set(obj.stageID, obj.progress)
|
||||
}
|
||||
}
|
||||
public getData(): DataUser {
|
||||
return this.data
|
||||
@@ -16,19 +20,21 @@ export class DOUser {
|
||||
|
||||
//====================================持久化数据
|
||||
public get_done(stageID: string): number {
|
||||
var find: StageProgress
|
||||
for (var i=0; i<this.data.dones.length; i++) {
|
||||
var obj = this.data.dones[i]
|
||||
if (obj.stageID == stageID) {
|
||||
find = obj
|
||||
break
|
||||
}
|
||||
}
|
||||
if (find) {
|
||||
return find.progress
|
||||
if (this.mapDones.has(stageID)) {
|
||||
return this.mapDones.get(stageID)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
public get_doneCountBydate(year: number, month: number): number {
|
||||
var count = 0
|
||||
var key = `${year}-${month}`
|
||||
this.mapDones.forEach((progres: number, stageID: string)=>{
|
||||
if (stageID.startsWith(key) && progres >= 1) {
|
||||
count ++
|
||||
}
|
||||
})
|
||||
return count
|
||||
}
|
||||
public update_stage_done(stageID: string, progress: number): void {
|
||||
var find: StageProgress
|
||||
for (var i=0; i<this.data.dones.length; i++) {
|
||||
@@ -45,6 +51,7 @@ export class DOUser {
|
||||
find = {stageID: stageID, progress: progress}
|
||||
this.data.dones.push(find)
|
||||
}
|
||||
this.mapDones.set(find.stageID, find.progress)
|
||||
StorageManager.getInstance().saveUser()
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import { StorageManager } from "../models/StorageManager";
|
||||
import { CalendarUnit } from "./CalendarUnit";
|
||||
import { LevelManager } from "../models/LevelManager";
|
||||
import { UIManager } from "../models/UIManager";
|
||||
import { respath } from "../constants/respath";
|
||||
|
||||
const { regClass, property } = Laya;
|
||||
|
||||
@@ -14,6 +15,8 @@ export class DailyChallenge extends Laya.Script {
|
||||
@property(Laya.Button)
|
||||
public btn_back: Laya.Button
|
||||
|
||||
@property(Laya.Image)
|
||||
public bg_dc: Laya.Image;
|
||||
@property(Laya.Label)
|
||||
public label_year: Laya.Label;
|
||||
@property(Laya.Label)
|
||||
@@ -49,19 +52,33 @@ export class DailyChallenge extends Laya.Script {
|
||||
UIManager.getInstance().loadHomeUI()
|
||||
this.owner.destroy()
|
||||
})
|
||||
|
||||
var dayBegin = 4
|
||||
var dayCount = 31
|
||||
var user = StorageManager.getInstance().getUser()
|
||||
var now = new Date()
|
||||
var year = now.getFullYear()
|
||||
var month = now.getMonth() + 1
|
||||
var dayNow = new Date().getDate()
|
||||
var stageID = `${year}-${month}-${day}`
|
||||
|
||||
var stageID = `${year}-${month}-${dayNow}`
|
||||
var starCount = user.get_doneCountBydate(year, month)
|
||||
if (starCount >= dayCount) {
|
||||
this.bg_dc.skin = respath.dc_top_bg_month_finish
|
||||
}
|
||||
else {
|
||||
var progress = user.get_done(stageID)
|
||||
console.log("progress >>>>>>>>>>>>>", stageID, progress)
|
||||
if (progress >= 1) {
|
||||
this.bg_dc.skin = respath.dc_top_bg_day_finish
|
||||
}
|
||||
else {
|
||||
this.bg_dc.skin = respath.dc_top_bg_normal
|
||||
}
|
||||
}
|
||||
this.label_year.text = year.toString()
|
||||
this.label_month.text = config.MONTH_ABBRS[month-1]
|
||||
var starCount = 0
|
||||
var day = 1
|
||||
var dayCount = 31
|
||||
var begin = 4
|
||||
this.label_month.text = config.MONTH_FULLNAMES[month-1]
|
||||
this.label_star.text = `${starCount}/${dayCount}`
|
||||
|
||||
var day = 1
|
||||
var index = -1
|
||||
for (var i=0; i<this.obj_items.numChildren; i++) {
|
||||
var hbox = this.obj_items.getChildAt(i)
|
||||
@@ -70,20 +87,17 @@ export class DailyChallenge extends Laya.Script {
|
||||
var obj = hbox.getChildAt(j) as Laya.Box
|
||||
var l_obj = l_hbox.getChildAt(j) as Laya.Label
|
||||
index ++
|
||||
if (index >= begin && index < begin+dayCount) {
|
||||
if (index >= dayBegin && index < dayBegin+dayCount) {
|
||||
obj.visible = true
|
||||
l_obj.visible = true
|
||||
var unit = obj.getComponent(CalendarUnit)
|
||||
this.units.push(unit)
|
||||
var stageID = `${year}-${month}-${day}`
|
||||
var progress = StorageManager.getInstance().getUser().get_done(stageID)
|
||||
var progress = user.get_done(stageID)
|
||||
unit.onInit(day, day<=dayNow, progress, l_obj, this, this.onClickUnit)
|
||||
if (day == dayNow) {
|
||||
this.selectedUnit = unit
|
||||
}
|
||||
if (progress >= 1) {
|
||||
starCount ++
|
||||
}
|
||||
day ++
|
||||
}
|
||||
else {
|
||||
@@ -92,7 +106,7 @@ export class DailyChallenge extends Laya.Script {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.label_star.text = `${starCount}/${dayCount}`
|
||||
|
||||
|
||||
this.onApplyUnit(this.selectedUnit)
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ const { regClass, property } = Laya
|
||||
export class Home extends Laya.Script {
|
||||
declare owner : Laya.Box;
|
||||
|
||||
@property(Laya.Image)
|
||||
public bg_dc: Laya.Image;
|
||||
@property(Laya.Label)
|
||||
public label_dc_title: Laya.Label;
|
||||
@property(Laya.Sprite)
|
||||
@@ -34,15 +36,19 @@ export class Home extends Laya.Script {
|
||||
|
||||
//组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
|
||||
onAwake(): void {
|
||||
|
||||
var user = StorageManager.getInstance().getUser()
|
||||
|
||||
var now = new Date()
|
||||
var year = now.getFullYear()
|
||||
var month = now.getMonth() + 1
|
||||
var dayNow = new Date().getDate()
|
||||
this.label_dc_title.text = `${config.MONTH_ABBRS[month-1]} ${dayNow}`
|
||||
var stageID = `${year}-${month}-${dayNow}`
|
||||
|
||||
if (user.get_doneCountBydate(year, month) >= 31)
|
||||
this.bg_dc.skin = respath.home_top_dc_bg_finish
|
||||
else
|
||||
this.bg_dc.skin = respath.home_top_dc_bg_normal
|
||||
this.label_dc_title.text = `${config.MONTH_ABBRS[month-1]} ${dayNow}`
|
||||
|
||||
var progress = user.get_done(stageID)
|
||||
if (progress <= 0) {
|
||||
this.btn_play.visible = true
|
||||
|
||||