补充UI细节 添加每日挑战
This commit is contained in:
@@ -110,6 +110,14 @@ export class DOStage {
|
||||
StorageManager.getInstance().onChanged()
|
||||
}
|
||||
|
||||
public get_score(): number {
|
||||
return this.data.score
|
||||
}
|
||||
public set_score(score: number): void {
|
||||
this.data.score = score
|
||||
StorageManager.getInstance().onChanged()
|
||||
}
|
||||
|
||||
public get_duration(): number {
|
||||
return this.data.duration
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DataProgress, DataUser } from "../types/global";
|
||||
import { DataProgress, DataUser, StageProgress } from "../types/global";
|
||||
import { StorageManager } from "./StorageManager"
|
||||
|
||||
|
||||
@@ -15,22 +15,37 @@ export class DOUser {
|
||||
}
|
||||
|
||||
//====================================持久化数据
|
||||
public get_isCompletedMain(): boolean {
|
||||
return this.data.isCompletedMain
|
||||
}
|
||||
public set_isCompletedMain(isCompletedMain: boolean): void {
|
||||
this.data.isCompletedMain = isCompletedMain
|
||||
StorageManager.getInstance().saveUser()
|
||||
}
|
||||
|
||||
public get_dones(): Array<string> {
|
||||
return this.data.dones
|
||||
}
|
||||
public add_done(stageID: string): void {
|
||||
if (this.data.dones.indexOf(stageID) < 0) {
|
||||
this.data.dones.push(stageID)
|
||||
StorageManager.getInstance().saveUser()
|
||||
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
|
||||
}
|
||||
return 0
|
||||
}
|
||||
public update_stage_done(stageID: string, progress: number): void {
|
||||
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) {
|
||||
find.progress = progress
|
||||
}
|
||||
else {
|
||||
find = {stageID: stageID, progress: progress}
|
||||
this.data.dones.push(find)
|
||||
}
|
||||
StorageManager.getInstance().saveUser()
|
||||
}
|
||||
|
||||
public get_progress(difficulty: string): number {
|
||||
|
||||
@@ -39,7 +39,7 @@ export class EventManager {
|
||||
}
|
||||
}
|
||||
|
||||
public DispatchEvent(eventID: string, arg: any): void {
|
||||
public DispatchEvent(eventID: string, arg: any=null): void {
|
||||
if (this.listeners.has(eventID)) {
|
||||
var list: Array<any> = this.listeners.get(eventID)
|
||||
for (var i=0; i<list.length; i++) {
|
||||
|
||||
@@ -141,6 +141,11 @@ export class LevelManager {
|
||||
})
|
||||
}
|
||||
|
||||
public getLevelList(difficulty: string): Array<string> {
|
||||
var list = this.levelMap.get(difficulty)
|
||||
return list
|
||||
}
|
||||
|
||||
public getLevelStr(difficulty: string, index: number): string {
|
||||
var list = this.levelMap.get(difficulty)
|
||||
if (list) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
|
||||
import { config } from "../constants/config"
|
||||
import { DataStage, createDataStage } from "../types/global"
|
||||
import { DOStage } from "./DOStage"
|
||||
import { DOUser } from "./DOUser"
|
||||
@@ -29,7 +30,7 @@ export class StorageManager {
|
||||
this.user = new DOUser(JSON.parse(jsonStr))
|
||||
}
|
||||
else {
|
||||
this.user = new DOUser({isCompletedMain: true, dones: new Array(), progresses: new Array()})
|
||||
this.user = new DOUser({dones: new Array(), progresses: new Array()})
|
||||
}
|
||||
}
|
||||
this.stageID = ""
|
||||
@@ -47,15 +48,7 @@ export class StorageManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public cleanStage(stageID: string): void {
|
||||
if (this.stageMap.has(stageID)) {
|
||||
this.stageMap.delete(stageID)
|
||||
}
|
||||
Laya.LocalStorage.removeItem(stageID)
|
||||
this.stageID = ""
|
||||
this.stageChanged = false
|
||||
}
|
||||
|
||||
public newStage(stageID: string, type: number, name: string, difficulty: string, index: number): DOStage {
|
||||
this.stageID = stageID
|
||||
this.stageChanged = false
|
||||
@@ -82,6 +75,25 @@ export class StorageManager {
|
||||
}
|
||||
return null
|
||||
}
|
||||
public getStage(): DOStage {//获取当前关卡数据对象,注意判空
|
||||
if (this.stageID && this.stageMap) {
|
||||
return this.stageMap.get(this.stageID)
|
||||
}
|
||||
return null
|
||||
}
|
||||
public cleanStage(): void {//清空当前关卡数据对象,注意判空
|
||||
this.user.update_stage_done(this.stageID, 0)
|
||||
if (this.stageMap.has(this.stageID)) {
|
||||
this.stageMap.delete(this.stageID)
|
||||
}
|
||||
Laya.LocalStorage.removeItem(this.stageID)
|
||||
this.stageID = ""
|
||||
this.stageChanged = false
|
||||
}
|
||||
public cleanMainStage(): void {//清空主线关卡数据
|
||||
this.stageID = config.DEFAULT_STAGE_ID
|
||||
this.cleanStage()
|
||||
}
|
||||
public saveStage(): void {
|
||||
if (this.stageChanged) {
|
||||
this.stageChanged = false
|
||||
@@ -98,7 +110,7 @@ export class StorageManager {
|
||||
|
||||
|
||||
public cleanAll(): void {
|
||||
this.user = new DOUser({isCompletedMain: true, dones: new Array(), progresses: new Array()})
|
||||
this.user = new DOUser({dones: new Array(), progresses: new Array()})
|
||||
|
||||
this.stageID = ""
|
||||
this.stageChanged = false
|
||||
|
||||
@@ -36,6 +36,13 @@ export class UIManager extends Laya.Script {
|
||||
})
|
||||
}
|
||||
|
||||
public loadDCUI(): void {
|
||||
Laya.loader.load(respath.dc_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))
|
||||
@@ -48,7 +55,6 @@ export class UIManager extends Laya.Script {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
public closeStageUI(): void {
|
||||
if (this.stage) {
|
||||
this.stage.owner.destroy()
|
||||
|
||||
Reference in New Issue
Block a user