add trophy logic
This commit is contained in:
@@ -19,6 +19,7 @@ export class Main extends Laya.Script {
|
||||
}
|
||||
|
||||
onLateUpdate(): void {
|
||||
StorageManager.getInstance().saveUser()
|
||||
StorageManager.getInstance().saveStage()
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import { respath } from "./respath";
|
||||
|
||||
|
||||
|
||||
@@ -38,21 +37,7 @@ export const config = {
|
||||
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"],
|
||||
|
||||
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},
|
||||
{year: 2025, month: 4, begin: 2, dayCount: 30, icon_res: respath.trophy_04},
|
||||
{year: 2025, month: 5, begin: 4, dayCount: 31, icon_res: respath.trophy_05},
|
||||
{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_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},
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
export const respath = {
|
||||
home_ui_res: "resources/Home.lh",
|
||||
dc_ui_res: "resources/DailyChallenge.lh",
|
||||
trophy_claim_ui_res: "resources/TrophyClaim.lh",
|
||||
trophy_show_ui_res: "resources/TrophyShow.lh",
|
||||
trophy_ui_res: "resources/TrophyRoom.lh",
|
||||
trophy_year_ui_res: "resources/TrophyRoomYear.lh",
|
||||
trophy_cell_ui_res: "resources/TrophyRoomCell.lh",
|
||||
|
||||
59
src/models/DCManager.ts
Normal file
59
src/models/DCManager.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
|
||||
|
||||
import { respath } from "../constants/respath"
|
||||
|
||||
|
||||
export const 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},
|
||||
{year: 2025, month: 4, begin: 2, dayCount: 30, icon_res: respath.trophy_04},
|
||||
{year: 2025, month: 5, begin: 4, dayCount: 31, icon_res: respath.trophy_05},
|
||||
{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_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},
|
||||
|
||||
{year: 2026, month: 1, begin: 4, dayCount: 31, icon_res: respath.trophy_01},
|
||||
{year: 2026, month: 2, begin: 0, dayCount: 30, icon_res: respath.trophy_02},
|
||||
{year: 2026, month: 3, begin: 0, dayCount: 31, icon_res: respath.trophy_03},
|
||||
{year: 2026, month: 4, begin: 3, dayCount: 30, icon_res: respath.trophy_04},
|
||||
{year: 2026, month: 5, begin: 5, dayCount: 31, icon_res: respath.trophy_05},
|
||||
{year: 2026, month: 6, begin: 1, dayCount: 30, icon_res: respath.trophy_06},
|
||||
{year: 2026, month: 7, begin: 3, dayCount: 31, icon_res: respath.trophy_07},
|
||||
{year: 2026, month: 8, begin: 6, dayCount: 31, icon_res: respath.trophy_08},
|
||||
{year: 2026, month: 9, begin: 2, dayCount: 30, icon_res: respath.trophy_09},
|
||||
{year: 2026, month: 10, begin: 4, dayCount: 31, icon_res: respath.trophy_10},
|
||||
{year: 2026, month: 11, begin: 0, dayCount: 30, icon_res: respath.trophy_11},
|
||||
{year: 2026, month: 12, begin: 2, dayCount: 31, icon_res: respath.trophy_12},
|
||||
]
|
||||
|
||||
|
||||
export function G_getMonthInfo(year: number, month: number): any {
|
||||
for (var i=0; i<MONTH_LIST.length; i++) {
|
||||
var obj = MONTH_LIST[i]
|
||||
if (obj.year == year && obj.month == month) {
|
||||
return obj
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export class DCManager {
|
||||
|
||||
private static instance: DCManager
|
||||
public static getInstance(): DCManager {
|
||||
if (!DCManager.instance) {
|
||||
DCManager.instance = new DCManager()
|
||||
}
|
||||
return DCManager.instance
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
3
src/models/DCManager.ts.meta
Normal file
3
src/models/DCManager.ts.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"uuid": "261c816d-1904-4442-9934-b0d91044ca02"
|
||||
}
|
||||
@@ -31,7 +31,7 @@ export class DOBlock {
|
||||
this.checked = show == this.get_correct()
|
||||
if (this.checked == false)
|
||||
this.set_score(0)
|
||||
StorageManager.getInstance().onChanged()
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
|
||||
public get_score(): number {
|
||||
@@ -39,7 +39,7 @@ export class DOBlock {
|
||||
}
|
||||
public set_score(score: number): void {
|
||||
this.data.score = score
|
||||
StorageManager.getInstance().onChanged()
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
|
||||
public get_notes(): Array<number> {
|
||||
@@ -48,20 +48,20 @@ export class DOBlock {
|
||||
public add_note(noteNumber: number): void {
|
||||
if (this.data.notes.indexOf(noteNumber) < 0) {
|
||||
this.data.notes.push(noteNumber)
|
||||
StorageManager.getInstance().onChanged()
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
}
|
||||
public remove_note(noteNumber: number): void {
|
||||
var find = this.data.notes.indexOf(noteNumber)
|
||||
if (find >= 0) {
|
||||
this.data.notes.splice(find, 1)
|
||||
StorageManager.getInstance().onChanged()
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
}
|
||||
public clean_notes(): void {
|
||||
if (this.data.notes.length > 0) {
|
||||
this.data.notes = new Array()
|
||||
StorageManager.getInstance().onChanged()
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
}
|
||||
//====================================持久化数据
|
||||
|
||||
@@ -107,7 +107,7 @@ export class DOStage {
|
||||
}
|
||||
public set_mistake(mistake: number): void {
|
||||
this.data.mistake = mistake
|
||||
StorageManager.getInstance().onChanged()
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
|
||||
public get_score(): number {
|
||||
@@ -115,7 +115,7 @@ export class DOStage {
|
||||
}
|
||||
public set_score(score: number): void {
|
||||
this.data.score = score
|
||||
StorageManager.getInstance().onChanged()
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
|
||||
public get_duration(): number {
|
||||
@@ -123,7 +123,7 @@ export class DOStage {
|
||||
}
|
||||
public set_duration(duration: number): void {//关卡计时
|
||||
this.data.duration = duration
|
||||
StorageManager.getInstance().onChanged()
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
|
||||
public get_note_open(): boolean {
|
||||
@@ -131,7 +131,7 @@ export class DOStage {
|
||||
}
|
||||
public set_note_open(note_open: boolean): void {
|
||||
this.data.note_open = note_open
|
||||
StorageManager.getInstance().onChanged()
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
|
||||
public get_select_index(): number {
|
||||
@@ -139,7 +139,7 @@ export class DOStage {
|
||||
}
|
||||
public set_select_index(select_index: number): void {//当前选中
|
||||
this.data.select_index = select_index
|
||||
StorageManager.getInstance().onChanged()
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
|
||||
public get_hint(): number {
|
||||
@@ -147,7 +147,7 @@ export class DOStage {
|
||||
}
|
||||
public set_hint(hint: number): void {//提示
|
||||
this.data.hint = hint
|
||||
StorageManager.getInstance().onChanged()
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
|
||||
public get_undos(): Array<DataUndo> {
|
||||
@@ -163,14 +163,14 @@ export class DOStage {
|
||||
var dataUndo: DataUndo = {index: index, show: show, notes: _notes}
|
||||
console.log("add_undo >>>>>>>>>>>>>>>>>>>>>>>>>>>>", JSON.stringify(dataUndo))
|
||||
this.data.undos.push(dataUndo)
|
||||
StorageManager.getInstance().onChanged()
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
public pop_undo(): DataUndo {
|
||||
var dataUndo: DataUndo
|
||||
if (this.data.undos.length > 0) {
|
||||
dataUndo = this.data.undos[this.data.undos.length-1]
|
||||
this.data.undos.splice(this.data.undos.length-1, 1)
|
||||
StorageManager.getInstance().onChanged()
|
||||
StorageManager.getInstance().onStageChanged()
|
||||
}
|
||||
return dataUndo
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DataProgress, DataUser, StageProgress } from "../types/global";
|
||||
import { DataProgress, DataUser, StageProgress, TrophyRecord } from "../types/global";
|
||||
import { StorageManager } from "./StorageManager"
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ export class DOUser {
|
||||
}
|
||||
return 0
|
||||
}
|
||||
public get_doneCountBydate(year: number, month: number): number {
|
||||
public get_doneCountByDate(year: number, month: number): number {
|
||||
var count = 0
|
||||
var key = `${year}-${month}`
|
||||
this.mapDones.forEach((progres: number, stageID: string)=>{
|
||||
@@ -35,6 +35,16 @@ export class DOUser {
|
||||
})
|
||||
return count
|
||||
}
|
||||
public get_isAllDoneByDate(year: number, month: number): boolean {
|
||||
var boolean = true
|
||||
var key = `${year}-${month}`
|
||||
this.mapDones.forEach((progres: number, stageID: string)=>{
|
||||
if (stageID.startsWith(key) && progres < 1) {
|
||||
boolean = false
|
||||
}
|
||||
})
|
||||
return boolean
|
||||
}
|
||||
public update_stage_done(stageID: string, progress: number): void {
|
||||
var find: StageProgress
|
||||
for (var i=0; i<this.data.dones.length; i++) {
|
||||
@@ -52,9 +62,78 @@ export class DOUser {
|
||||
this.data.dones.push(find)
|
||||
}
|
||||
this.mapDones.set(find.stageID, find.progress)
|
||||
StorageManager.getInstance().saveUser()
|
||||
StorageManager.getInstance().onUserChanged()
|
||||
}
|
||||
|
||||
//================奖杯获得记录
|
||||
public get_trophyRecord(year: number, month: number): TrophyRecord {
|
||||
var find: TrophyRecord
|
||||
for (var i=0; i<this.data.trophy_records.length; i++) {
|
||||
var obj = this.data.trophy_records[i]
|
||||
if (obj.year == year && obj.month == month) {
|
||||
find = obj
|
||||
break
|
||||
}
|
||||
}
|
||||
return find
|
||||
}
|
||||
public get_trophyHasNew(): TrophyRecord {
|
||||
var find: TrophyRecord
|
||||
for (var i=0; i<this.data.trophy_records.length; i++) {
|
||||
var obj = this.data.trophy_records[i]
|
||||
if (obj.isNew) {
|
||||
find = obj
|
||||
break
|
||||
}
|
||||
}
|
||||
return find
|
||||
}
|
||||
public set_trophyNew(record: TrophyRecord, isNew: boolean): void {
|
||||
if (record.isNew != isNew) {
|
||||
record.isNew = isNew
|
||||
StorageManager.getInstance().onUserChanged()
|
||||
}
|
||||
}
|
||||
public get_trophyHasUnread(): boolean {
|
||||
var unread = false
|
||||
for (var i=0; i<this.data.trophy_records.length; i++) {
|
||||
var obj = this.data.trophy_records[i]
|
||||
if (obj.read == false) {
|
||||
unread = true
|
||||
break
|
||||
}
|
||||
}
|
||||
return unread
|
||||
}
|
||||
public set_trophyAllread(): void {
|
||||
var changed = false
|
||||
for (var i=0; i<this.data.trophy_records.length; i++) {
|
||||
var obj = this.data.trophy_records[i]
|
||||
if (obj.read == false) {
|
||||
obj.read = true
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
StorageManager.getInstance().onUserChanged()
|
||||
}
|
||||
}
|
||||
public add_trophy_record(year: number, month: number, day: number): void {
|
||||
var find
|
||||
for (var i=0; i<this.data.trophy_records.length; i++) {
|
||||
var obj = this.data.trophy_records[i]
|
||||
if (obj.year == year && obj.month == month) {
|
||||
find = obj
|
||||
break
|
||||
}
|
||||
}
|
||||
if (!find) {
|
||||
this.data.trophy_records.push({year: year, month: month, day: day, isNew: true, read: false})
|
||||
StorageManager.getInstance().onUserChanged()
|
||||
}
|
||||
}
|
||||
|
||||
//=======关卡难度进度
|
||||
public get_progress(difficulty: string): number {
|
||||
var find: DataProgress
|
||||
for (var i=0; i<this.data.progresses.length; i++) {
|
||||
@@ -85,7 +164,7 @@ export class DOUser {
|
||||
find = {difficulty: difficulty, index: index}
|
||||
this.data.progresses.push(find)
|
||||
}
|
||||
StorageManager.getInstance().saveUser()
|
||||
StorageManager.getInstance().onUserChanged()
|
||||
}
|
||||
|
||||
//====================================持久化数据
|
||||
|
||||
@@ -17,6 +17,7 @@ export class StorageManager {
|
||||
}
|
||||
|
||||
private user: DOUser;
|
||||
private userChanged = false
|
||||
|
||||
private stageID: string = "";
|
||||
private stageChanged = false
|
||||
@@ -30,9 +31,11 @@ export class StorageManager {
|
||||
this.user = new DOUser(JSON.parse(jsonStr))
|
||||
}
|
||||
else {
|
||||
this.user = new DOUser({dones: new Array(), progresses: new Array()})
|
||||
this.user = new DOUser({dones: new Array(), trophy_records: new Array(), progresses: new Array()})
|
||||
}
|
||||
}
|
||||
this.userChanged = false
|
||||
|
||||
this.stageID = ""
|
||||
this.stageChanged = false
|
||||
}
|
||||
@@ -42,12 +45,17 @@ export class StorageManager {
|
||||
return this.user
|
||||
}
|
||||
public saveUser(): void {
|
||||
if (this.user) {
|
||||
var jsonStr = JSON.stringify(this.user.getData())
|
||||
Laya.LocalStorage.setItem("user", jsonStr)
|
||||
if (this.userChanged) {
|
||||
this.userChanged = false
|
||||
if (this.user) {
|
||||
var jsonStr = JSON.stringify(this.user.getData())
|
||||
Laya.LocalStorage.setItem("user", jsonStr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public onUserChanged(): void {
|
||||
this.userChanged = true
|
||||
}
|
||||
|
||||
public newStage(stageID: string, type: number, name: string, difficulty: string, index: number): DOStage {
|
||||
this.stageID = stageID
|
||||
@@ -104,13 +112,14 @@ export class StorageManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
public onChanged(): void {
|
||||
public onStageChanged(): void {
|
||||
this.stageChanged = true
|
||||
}
|
||||
|
||||
|
||||
public cleanAll(): void {
|
||||
this.user = new DOUser({dones: new Array(), progresses: new Array()})
|
||||
this.user = new DOUser({dones: new Array(), trophy_records: new Array(), progresses: new Array()})
|
||||
this.userChanged = false
|
||||
|
||||
this.stageID = ""
|
||||
this.stageChanged = false
|
||||
|
||||
@@ -2,6 +2,9 @@ import { respath } from "../constants/respath"
|
||||
import { StorageManager } from "./StorageManager"
|
||||
import { Stage } from "../views/Stage"
|
||||
import { DailyChallenge } from "../views/DailyChallenge"
|
||||
import { TrophyRecord } from "../types/global"
|
||||
import { TrophyClaim } from "../views/TrophyClaim"
|
||||
import { TrophyShow } from "../views/TrophyShow"
|
||||
|
||||
|
||||
const { regClass, property } = Laya
|
||||
@@ -45,6 +48,14 @@ export class UIManager extends Laya.Script {
|
||||
})
|
||||
}
|
||||
|
||||
public loadTrophyClaimUI(record: TrophyRecord): void {
|
||||
Laya.loader.load(respath.trophy_claim_ui_res).then((go)=>{
|
||||
var prefab = go.create()
|
||||
var obj = this.getUIRoot().addChild(prefab).getComponent(TrophyClaim)
|
||||
obj.onSetShow(record)
|
||||
})
|
||||
}
|
||||
|
||||
public loadTrophyUI(): void {
|
||||
Laya.loader.load(respath.trophy_ui_res).then((go)=>{
|
||||
var prefab = go.create()
|
||||
@@ -52,6 +63,14 @@ export class UIManager extends Laya.Script {
|
||||
})
|
||||
}
|
||||
|
||||
public loadTrophyShowUI(record: TrophyRecord): void {
|
||||
Laya.loader.load(respath.trophy_show_ui_res).then((go)=>{
|
||||
var prefab = go.create()
|
||||
var obj = this.getUIRoot().addChild(prefab).getComponent(TrophyShow)
|
||||
obj.onSetShow(record)
|
||||
})
|
||||
}
|
||||
|
||||
public loadStageUI(stageID: string): void {
|
||||
if (this.stage) {
|
||||
this.stage.onLoadStage(StorageManager.getInstance().loadStage(stageID))
|
||||
|
||||
@@ -17,7 +17,7 @@ export interface DataUndo {
|
||||
|
||||
//关卡数据
|
||||
export interface DataStage {
|
||||
id: string,
|
||||
id: string,//关卡ID dc关卡格式为:年-月-日
|
||||
type: number,
|
||||
name: string,
|
||||
difficulty: string,
|
||||
@@ -46,14 +46,22 @@ export function createDataStage(id: string, type: number, name: string, difficul
|
||||
|
||||
|
||||
export interface StageProgress {//关卡完成进度
|
||||
stageID: string,
|
||||
stageID: string,//关卡ID dc关卡格式为:年-月-日
|
||||
progress: number,
|
||||
}
|
||||
export interface DataProgress {
|
||||
export interface TrophyRecord {
|
||||
year: number,
|
||||
month: number,
|
||||
day: number,
|
||||
isNew: boolean,
|
||||
read: boolean,
|
||||
}
|
||||
export interface DataProgress {//关卡难度进度
|
||||
difficulty: string,
|
||||
index: number,
|
||||
}
|
||||
export interface DataUser {
|
||||
dones: Array<StageProgress>,//关卡完成进度
|
||||
trophy_records: Array<TrophyRecord>,//奖杯获得记录
|
||||
progresses: Array<DataProgress>,//主线各个难度进度
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import { Difficulty } from "./Difficulty";
|
||||
import { LevelManager } from "../models/LevelManager";
|
||||
import { config } from "../constants/config";
|
||||
import { Utility_ConvertSecondToString } from "../utils/utility";
|
||||
import { G_getMonthInfo } from "../models/DCManager";
|
||||
|
||||
const { regClass, property } = Laya
|
||||
|
||||
@@ -44,17 +45,11 @@ export class Home extends Laya.Script {
|
||||
var now = new Date()
|
||||
var nowYear = now.getFullYear()
|
||||
var nowMonth = now.getMonth() + 1
|
||||
var find
|
||||
for (var i=0; i<config.MONTH_LIST.length; i++) {
|
||||
var obj = config.MONTH_LIST[i]
|
||||
if (obj.year == nowYear && obj.month == nowMonth) {
|
||||
find = obj
|
||||
break
|
||||
}
|
||||
}
|
||||
var nowDay = now.getDate()
|
||||
var find = G_getMonthInfo(nowYear, nowMonth)
|
||||
if (find) {
|
||||
this.icon_dc.skin = find.icon_res
|
||||
if (user.get_doneCountBydate(nowYear, nowMonth) >= find.dayCount) {
|
||||
if (user.get_doneCountByDate(nowYear, nowMonth) >= find.dayCount) {
|
||||
this.bg_dc.skin = respath.home_top_dc_bg_finish
|
||||
this.label_dc_title.color = "#ffffff"
|
||||
this.label_dc_date.color = "#ffffff"
|
||||
@@ -70,8 +65,7 @@ export class Home extends Laya.Script {
|
||||
this.label_dc_title.color = "#2d3138"
|
||||
this.label_dc_date.color = "#2d3138"
|
||||
}
|
||||
|
||||
var nowDay = new Date().getDate()
|
||||
|
||||
var stageID = `${nowYear}-${nowMonth}-${nowDay}`
|
||||
this.label_dc_date.text = `${config.MONTH_ABBRS[nowMonth-1]} ${nowDay}`
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import { config } from "../constants/config";
|
||||
import { StorageManager } from "../models/StorageManager";
|
||||
import { Utility_ConvertSecondToString } from "../utils/utility";
|
||||
import { EVENT_TYPES, EventManager } from "../models/EventManager";
|
||||
import { G_getMonthInfo } from "../models/DCManager";
|
||||
|
||||
|
||||
const { regClass, property } = Laya;
|
||||
@@ -377,14 +378,31 @@ export class Stage extends Laya.Script {
|
||||
}
|
||||
}
|
||||
}
|
||||
user.update_stage_done(this.data.get_stageID(), finished/all)//更新关卡完成进度
|
||||
var progress = finished/all
|
||||
user.update_stage_done(this.data.get_stageID(), progress)//更新关卡完成进度
|
||||
if (this.getIsComplete()) {
|
||||
console.log("完成关卡")
|
||||
console.log("完成关卡", finished, all, progress)
|
||||
this.paused = true
|
||||
this.data.set_score(score)
|
||||
if (this.data.get_stageType() == config.STAGE_TYPE.MAIN) {//主线关卡更新难度进度
|
||||
user.update_progress(this.data.get_difficulty(), this.data.get_stageIndex()+1)
|
||||
}
|
||||
else if (this.data.get_stageType() == config.STAGE_TYPE.DC) {//dc
|
||||
if (progress >= 1) {//完成每日挑战关卡检查是否或者当月奖杯
|
||||
var now = new Date()
|
||||
var nowYear = now.getFullYear()
|
||||
var nowMonth = now.getMonth() + 1
|
||||
var doneCount = user.get_doneCountByDate(nowYear, nowMonth)
|
||||
var dayCount = 0
|
||||
var info = G_getMonthInfo(nowYear, nowMonth)
|
||||
if (info)
|
||||
dayCount = info.dayCount
|
||||
console.log("dc完成信息>>>>>>>>>>>>>>>", nowYear, nowMonth, doneCount, dayCount)
|
||||
if (doneCount >= dayCount) {//当月每日挑战全部完成
|
||||
user.add_trophy_record(nowYear, nowMonth, now.getDate())
|
||||
}
|
||||
}
|
||||
}
|
||||
UIManager.getInstance().loadGameDoneUI()
|
||||
}
|
||||
}
|
||||
|
||||
36
src/views/TrophyClaim.ts
Normal file
36
src/views/TrophyClaim.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { config } from "../constants/config";
|
||||
import { MONTH_LIST } from "../models/DCManager";
|
||||
import { TrophyRecord } from "../types/global";
|
||||
|
||||
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
|
||||
|
||||
public onSetShow(record: TrophyRecord): void {
|
||||
for (var i=0; i<MONTH_LIST.length; i++) {
|
||||
var obj = MONTH_LIST[i]
|
||||
if (obj.year == record.year && obj.month == record.month) {
|
||||
this.icon.skin = obj.icon_res
|
||||
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()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
3
src/views/TrophyClaim.ts.meta
Normal file
3
src/views/TrophyClaim.ts.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"uuid": "0550b681-b602-49fe-900f-e30866ce922c"
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
|
||||
|
||||
|
||||
import { config } from "../constants/config";
|
||||
|
||||
import { respath } from "../constants/respath";
|
||||
import { MONTH_LIST } from "../models/DCManager";
|
||||
import { TrophyUnit } from "./TrophyUnit";
|
||||
|
||||
const { regClass, property } = Laya;
|
||||
@@ -28,8 +29,8 @@ export class TrophyRoom extends Laya.Script {
|
||||
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]
|
||||
infos.push(obj)
|
||||
if (obj.year == nowYear && obj.month == nowMonth) {
|
||||
break
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
|
||||
import { config } from "../constants/config";
|
||||
import { MONTH_LIST } from "../models/DCManager";
|
||||
import { TrophyRecord } from "../types/global";
|
||||
|
||||
|
||||
const { regClass, property } = Laya;
|
||||
|
||||
@regClass()
|
||||
@@ -13,7 +19,19 @@ export class TrophyShow extends Laya.Script {
|
||||
@property(Laya.Box)
|
||||
public btn_close: Laya.Box
|
||||
|
||||
public onSetShow(): void {
|
||||
|
||||
public onSetShow(record: TrophyRecord): void {
|
||||
for (var i=0; i<MONTH_LIST.length; i++) {
|
||||
var obj = MONTH_LIST[i]
|
||||
if (obj.year == record.year && obj.month == record.month) {
|
||||
this.icon.skin = obj.icon_res
|
||||
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()
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { config } from "../constants/config";
|
||||
import { respath } from "../constants/respath";
|
||||
import { StorageManager } from "../models/StorageManager";
|
||||
import { UIManager } from "../models/UIManager";
|
||||
|
||||
const { regClass, property } = Laya;
|
||||
|
||||
@@ -19,7 +20,7 @@ export class TrophyUnit extends Laya.Script {
|
||||
|
||||
public onInit(info: any): void {
|
||||
var user = StorageManager.getInstance().getUser()
|
||||
var starCount = user.get_doneCountBydate(info.year, info.month)
|
||||
var starCount = user.get_doneCountByDate(info.year, info.month)
|
||||
this.icon.skin = info.icon_res
|
||||
this.label_count.text = `${starCount}/${info.dayCount}`
|
||||
this.label_month.text = config.MONTH_ABBRS[info.month-1]
|
||||
@@ -35,7 +36,10 @@ export class TrophyUnit extends Laya.Script {
|
||||
}
|
||||
|
||||
this.icon.on(Laya.Event.CLICK, this, ()=>{
|
||||
|
||||
var find = user.get_trophyRecord(info.year, info.month)
|
||||
if (find) {
|
||||
UIManager.getInstance().loadTrophyShowUI(find)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user