添加横屏页面
This commit is contained in:
@@ -4,24 +4,50 @@ import { config } from "./config";
|
||||
export const respath = {
|
||||
home_ui_res: "resources/Home.lh",
|
||||
topbar_ui_res: "resources/TopBar.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",
|
||||
|
||||
stage_ui_res: function func(): string {
|
||||
return config.H_SCREEN ? "resources/Stage_H.lh" : "resources/Stage.lh"
|
||||
},
|
||||
|
||||
gamepause_ui_res: "resources/GamePause.lh",
|
||||
gameover_ui_res: "resources/GameOver.lh",
|
||||
gamedone_ui_res: "resources/GameDone.lh",
|
||||
gamepause_ui_res: function func(): string {
|
||||
return config.H_SCREEN ? "resources/GamePause_H.lh" : "resources/GamePause.lh"
|
||||
},
|
||||
gameover_ui_res: function func(): string {
|
||||
return config.H_SCREEN ? "resources/GameOver_H.lh" : "resources/GameOver.lh"
|
||||
},
|
||||
gamedone_ui_res: function func(isClassic: boolean): string {
|
||||
if (isClassic) {
|
||||
return config.H_SCREEN ? "resources/GameDone_Normal_H.lh" : "resources/GameDone_Normal.lh"
|
||||
}
|
||||
else {
|
||||
return config.H_SCREEN ? "resources/GameDone_DC_H.lh" : "resources/GameDone_DC.lh"
|
||||
}
|
||||
},
|
||||
|
||||
score_add_ui_res: "resources/ScoreAdd.lh",
|
||||
common_tips_ui_res: "resources/CommonTips.lh",
|
||||
difficulty_ui_res: "resources/Difficulty.lh",
|
||||
|
||||
dc_ui_res: function func(): string {
|
||||
return config.H_SCREEN ? "resources/dc/DailyChallenge_H.lh" : "resources/dc/DailyChallenge.lh"
|
||||
},
|
||||
trophy_claim_ui_res: function func(): string {
|
||||
return config.H_SCREEN ? "resources/dc/TrophyClaim_H.lh" : "resources/dc/TrophyClaim.lh"
|
||||
},
|
||||
trophy_show_ui_res: function func(): string {
|
||||
return config.H_SCREEN ? "resources/dc/TrophyShow_H.lh" : "resources/dc/TrophyShow.lh"
|
||||
},
|
||||
trophy_ui_res: function func(): string {
|
||||
return config.H_SCREEN ? "resources/dc/TrophyRoom_H.lh" : "resources/dc/TrophyRoom.lh"
|
||||
},
|
||||
trophy_year_ui_res: function func(): string {
|
||||
return config.H_SCREEN ? "resources/dc/TrophyRoomYear_H.lh" : "resources/dc/TrophyRoomYear.lh"
|
||||
},
|
||||
trophy_cell_ui_res: function func(): string {
|
||||
return config.H_SCREEN ? "resources/dc/TrophyRoomCell_H.lh" : "resources/dc/TrophyRoomCell.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_bg2.png",
|
||||
|
||||
@@ -60,7 +60,7 @@ export class StorageManager {
|
||||
|
||||
public newStage(stageID: string, type: number, name: string, difficulty: string = config.DIFFICULTY_TYPE.Easy): DOStage {
|
||||
this.stageID = stageID
|
||||
this.stageChanged = false
|
||||
this.stageChanged = true
|
||||
|
||||
var index
|
||||
if (type == config.STAGE_TYPE.MAIN) {//主线关卡
|
||||
@@ -79,14 +79,14 @@ export class StorageManager {
|
||||
index = Math.floor(random*list.length)
|
||||
console.log("每日挑战随机一个关卡", difficulty, index)
|
||||
}
|
||||
this.user.update_stage_done(this.stageID, 0)//重置关卡进度
|
||||
var dataStage: DataStage = createDataStage(stageID, type, name, difficulty, index)
|
||||
var doStage: DOStage = new DOStage(dataStage)
|
||||
this.stageMap.set(stageID, doStage)
|
||||
return doStage
|
||||
}
|
||||
public loadStage(stageID: string): DOStage {
|
||||
this.stageID = stageID
|
||||
this.stageChanged = false
|
||||
|
||||
public getStage(stageID: string): DOStage {//获取指定关卡数据对象,注意判空
|
||||
if (this.stageMap.has(stageID)) {
|
||||
var doStage: DOStage = this.stageMap.get(stageID)
|
||||
return doStage
|
||||
@@ -102,25 +102,19 @@ export class StorageManager {
|
||||
}
|
||||
return null
|
||||
}
|
||||
public getStage(): DOStage {//获取当前关卡数据对象,注意判空
|
||||
if (this.stageID && this.stageMap) {
|
||||
return this.stageMap.get(this.stageID)
|
||||
|
||||
public loadStage(stageID: string): DOStage {//载入关卡
|
||||
var doStage = this.getStage(stageID)
|
||||
if (doStage) {
|
||||
this.stageID = stageID
|
||||
this.stageChanged = false
|
||||
return doStage
|
||||
}
|
||||
console.log("载入关卡失败>>>>>", 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
|
||||
|
||||
@@ -6,6 +6,11 @@ import { TrophyRecord } from "../types/global"
|
||||
import { TrophyClaim } from "../views/dc/TrophyClaim"
|
||||
import { TrophyShow } from "../views/dc/TrophyShow"
|
||||
import { config } from "../constants/config"
|
||||
import { TrophyRoom } from "../views/dc/TrophyRoom"
|
||||
import { DOStage } from "./DOStage"
|
||||
import { GamePause } from "../views/GamePause"
|
||||
import { GameOver } from "../views/GameOver"
|
||||
import { GameDone } from "../views/GameDone"
|
||||
|
||||
|
||||
const { regClass, property } = Laya
|
||||
@@ -33,6 +38,8 @@ export class UIManager extends Laya.Script {
|
||||
}
|
||||
|
||||
private stage: Stage
|
||||
private dc_ui: DailyChallenge
|
||||
private trophyRoom: TrophyRoom
|
||||
|
||||
|
||||
public getUIRoot(): Laya.Node {
|
||||
@@ -54,15 +61,21 @@ export class UIManager extends Laya.Script {
|
||||
}
|
||||
|
||||
public loadDCUI(): void {
|
||||
Laya.loader.load(respath.dc_ui_res).then((go)=>{
|
||||
Laya.loader.load(respath.dc_ui_res()).then((go)=>{
|
||||
var prefab = go.create()
|
||||
var dc = this.getUIRoot().addChild(prefab).getComponent(DailyChallenge)
|
||||
dc.loadWithMonth()
|
||||
this.dc_ui = this.getUIRoot().addChild(prefab).getComponent(DailyChallenge)
|
||||
this.dc_ui.loadWithMonth()
|
||||
})
|
||||
}
|
||||
public closeDCUI(): void {
|
||||
if (this.dc_ui) {
|
||||
this.dc_ui.owner.destroy()
|
||||
this.dc_ui = null
|
||||
}
|
||||
}
|
||||
|
||||
public loadTrophyClaimUI(record: TrophyRecord): void {
|
||||
Laya.loader.load(respath.trophy_claim_ui_res).then((go)=>{
|
||||
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)
|
||||
@@ -70,14 +83,20 @@ export class UIManager extends Laya.Script {
|
||||
}
|
||||
|
||||
public loadTrophyUI(): void {
|
||||
Laya.loader.load(respath.trophy_ui_res).then((go)=>{
|
||||
Laya.loader.load(respath.trophy_ui_res()).then((go)=>{
|
||||
var prefab = go.create()
|
||||
this.getUIRoot().addChild(prefab)
|
||||
this.trophyRoom = this.getUIRoot().addChild(prefab).getComponent(TrophyRoom)
|
||||
})
|
||||
}
|
||||
public closeTrophyUI(): void {
|
||||
if (this.trophyRoom) {
|
||||
this.trophyRoom.owner.destroy()
|
||||
this.trophyRoom = null
|
||||
}
|
||||
}
|
||||
|
||||
public loadTrophyShowUI(record: TrophyRecord): void {
|
||||
Laya.loader.load(respath.trophy_show_ui_res).then((go)=>{
|
||||
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)
|
||||
@@ -103,22 +122,25 @@ export class UIManager extends Laya.Script {
|
||||
}
|
||||
}
|
||||
|
||||
public loadGamePauseUI(): void {
|
||||
Laya.loader.load(respath.gamepause_ui_res).then((go)=>{
|
||||
public loadGamePauseUI(doStage: DOStage): void {
|
||||
Laya.loader.load(respath.gamepause_ui_res()).then((go)=>{
|
||||
var prefab = go.create()
|
||||
this.getUIRoot().addChild(prefab)
|
||||
var ui = this.getUIRoot().addChild(prefab).getComponent(GamePause)
|
||||
ui.onSetStageInfo(doStage)
|
||||
})
|
||||
}
|
||||
public loadGameOverUI(): void {
|
||||
Laya.loader.load(respath.gameover_ui_res).then((go)=>{
|
||||
public loadGameOverUI(doStage: DOStage): void {
|
||||
Laya.loader.load(respath.gameover_ui_res()).then((go)=>{
|
||||
var prefab = go.create()
|
||||
this.getUIRoot().addChild(prefab)
|
||||
var ui = this.getUIRoot().addChild(prefab).getComponent(GameOver)
|
||||
ui.onSetStageInfo(doStage)
|
||||
})
|
||||
}
|
||||
public loadGameDoneUI(): void {
|
||||
Laya.loader.load(respath.gamedone_ui_res).then((go)=>{
|
||||
public loadGameDoneUI(isClassic: boolean, doStage: DOStage): void {
|
||||
Laya.loader.load(respath.gamedone_ui_res(isClassic)).then((go)=>{
|
||||
var prefab = go.create()
|
||||
this.getUIRoot().addChild(prefab)
|
||||
var ui = this.getUIRoot().addChild(prefab).getComponent(GameDone)
|
||||
ui.onSetStageInfo(doStage)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { G_ShowScoreTips } from "../views/common/GUITips";
|
||||
import { DOBlock } from "../models/DOBlock";
|
||||
import { config } from "../constants/config";
|
||||
|
||||
const { regClass, property } = Laya;
|
||||
|
||||
@@ -59,12 +60,15 @@ export class Block extends Laya.Script {
|
||||
}
|
||||
|
||||
public setBlockColor(color: string, alpha: number=1, animated: boolean=false, completedColor: string = "", completedAlpha: number=1): void {
|
||||
var blockSize = 116
|
||||
if (config.H_SCREEN)
|
||||
blockSize = 96
|
||||
this.owner.graphics.clear()
|
||||
this.owner.graphics.drawRect(0, 0, 116, 116, color)
|
||||
this.owner.graphics.drawRect(0, 0, blockSize, blockSize, color)
|
||||
if (animated) {
|
||||
Laya.Tween.to(this.owner, {alpha:alpha}, 500, Laya.Ease.elasticOut, Laya.Handler.create(this, () => {
|
||||
this.owner.graphics.clear()
|
||||
this.owner.graphics.drawRect(0, 0, 116, 116, completedColor)
|
||||
this.owner.graphics.drawRect(0, 0, blockSize, blockSize, completedColor)
|
||||
this.owner.alpha = completedAlpha
|
||||
}))
|
||||
}
|
||||
@@ -92,11 +96,14 @@ export class Block extends Laya.Script {
|
||||
}
|
||||
|
||||
public setTipsBgColor(visible: boolean, noteNumber: number=0, color: string="", alpha: number=1): void {
|
||||
var blockSize = 38
|
||||
if (config.H_SCREEN)
|
||||
blockSize = 30
|
||||
if (visible) {
|
||||
var obj = this.tips_bgs[noteNumber-1]
|
||||
obj.visible = true
|
||||
obj.graphics.clear()
|
||||
obj.graphics.drawRect(0, 0, 38, 38, color)
|
||||
obj.graphics.drawRect(0, 0, blockSize, blockSize, color)
|
||||
obj.alpha = alpha
|
||||
}
|
||||
else {
|
||||
|
||||
59
src/views/CommonTips.ts
Normal file
59
src/views/CommonTips.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { respath } from "../constants/respath";
|
||||
import { UIManager } from "../models/UIManager";
|
||||
|
||||
const { regClass, property } = Laya;
|
||||
|
||||
|
||||
export function G_ShowCommonTips(title: string, content: string, showToggle: boolean, func: any): void {
|
||||
Laya.loader.load(respath.common_tips_ui_res).then((go)=>{
|
||||
var prefab = go.create()
|
||||
var obj = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(CommonTips)
|
||||
obj.showCommonTips(title, content, showToggle, func)
|
||||
})
|
||||
}
|
||||
|
||||
@regClass()
|
||||
export class CommonTips extends Laya.Script {
|
||||
declare owner : Laya.Box;
|
||||
|
||||
@property(Laya.Label)
|
||||
public label_title: Laya.Label
|
||||
@property(Laya.Label)
|
||||
public label_content: Laya.Label
|
||||
|
||||
@property(Laya.Box)
|
||||
public btn_ok: Laya.Box
|
||||
@property(Laya.Box)
|
||||
public btn_cancel: Laya.Box
|
||||
|
||||
@property(Laya.Box)
|
||||
public toggle: Laya.Box
|
||||
@property(Laya.Image)
|
||||
public check: Laya.Image
|
||||
private isChecked = false
|
||||
|
||||
public showCommonTips(title: string, content: string, showToggle: boolean, func: any): void {
|
||||
this.label_title.text = title
|
||||
this.label_content.text = content
|
||||
this.toggle.visible = showToggle
|
||||
this.check.visible = false
|
||||
this.toggle.on(Laya.Event.CLICK, this, ()=>{
|
||||
this.isChecked = !this.isChecked
|
||||
this.check.visible = this.isChecked
|
||||
})
|
||||
|
||||
this.btn_ok.on(Laya.Event.CLICK, this, ()=>{
|
||||
if (func) {
|
||||
func(true, this.isChecked)
|
||||
}
|
||||
this.owner.destroy()
|
||||
})
|
||||
this.btn_cancel.on(Laya.Event.CLICK, this, ()=>{
|
||||
if (func) {
|
||||
func(false, this.isChecked)
|
||||
}
|
||||
this.owner.destroy()
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
3
src/views/CommonTips.ts.meta
Normal file
3
src/views/CommonTips.ts.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"uuid": "b0dfcf08-5aef-4078-8149-1fbd00d8038f"
|
||||
}
|
||||
@@ -3,8 +3,8 @@ import { StorageManager } from "../models/StorageManager";
|
||||
import { Utility_ConvertSecondToString } from "../utils/utility";
|
||||
import { respath } from "../constants/respath";
|
||||
import { Difficulty } from "./Difficulty";
|
||||
import { LevelManager } from "../models/LevelManager";
|
||||
import { config } from "../constants/config";
|
||||
import { DOStage } from "../models/DOStage";
|
||||
|
||||
const { regClass, property } = Laya;
|
||||
|
||||
@@ -12,13 +12,6 @@ const { regClass, property } = Laya;
|
||||
export class GameDone extends Laya.Script {
|
||||
declare owner : Laya.Box;
|
||||
|
||||
@property(Laya.Box)
|
||||
public obj_top: Laya.Box
|
||||
@property(Laya.Box)
|
||||
public obj_stars: Laya.Box
|
||||
@property(Laya.Image)
|
||||
public obj_star: Laya.Image
|
||||
|
||||
@property(Laya.Label)
|
||||
public label_diffucuty: Laya.Label
|
||||
@property(Laya.Label)
|
||||
@@ -35,52 +28,56 @@ export class GameDone extends Laya.Script {
|
||||
|
||||
|
||||
onStart(): void {
|
||||
var doStage = StorageManager.getInstance().getStage()
|
||||
var type = doStage.get_stageType()
|
||||
if (type == config.STAGE_TYPE.MAIN) {
|
||||
this.obj_top.y = 356
|
||||
this.obj_stars.visible = true
|
||||
this.obj_star.visible = false
|
||||
this.btn_new.visible = true
|
||||
this.btn_home.visible = true
|
||||
this.btn_continue.visible = false
|
||||
}
|
||||
else {
|
||||
this.obj_top.y = 456
|
||||
this.obj_stars.visible = false
|
||||
this.obj_star.visible = true
|
||||
this.btn_new.visible = false
|
||||
this.btn_home.visible = false
|
||||
this.btn_continue.visible = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public onSetStageInfo(doStage: DOStage): void {
|
||||
this.label_diffucuty.text = doStage.get_difficulty()
|
||||
this.label_time.text = Utility_ConvertSecondToString(doStage.get_duration())
|
||||
this.label_score.text = doStage.get_score().toString()
|
||||
|
||||
this.btn_new.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
|
||||
Laya.loader.load(respath.difficulty_ui_res).then((go)=>{
|
||||
var prefab = go.create()
|
||||
var d = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(Difficulty)
|
||||
d.onInit((value: string)=> {
|
||||
console.log("选择难度", value)
|
||||
StorageManager.getInstance().cleanStage()
|
||||
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value)
|
||||
if (config.H_SCREEN) {
|
||||
var user = StorageManager.getInstance().getUser()
|
||||
user.update_progress(doStage.get_difficulty(), doStage.get_stageIndex()+1)//主线关卡更新难度进度
|
||||
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, doStage.get_difficulty(), doStage.get_difficulty())
|
||||
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID);
|
||||
this.owner.destroy()
|
||||
}
|
||||
else {
|
||||
Laya.loader.load(respath.difficulty_ui_res).then((go)=>{
|
||||
var prefab = go.create()
|
||||
var d = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(Difficulty)
|
||||
d.onInit((value: string)=> {
|
||||
console.log("选择难度", value)
|
||||
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value)
|
||||
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID);
|
||||
this.owner.destroy()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
this.btn_home.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
|
||||
UIManager.getInstance().loadHomeUI()
|
||||
UIManager.getInstance().closeStageUI();
|
||||
this.owner.destroy()
|
||||
})
|
||||
|
||||
this.btn_continue.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
|
||||
this.btn_continue.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {//这个按钮只有从DC来的会显示
|
||||
UIManager.getInstance().loadDCUI()
|
||||
UIManager.getInstance().closeStageUI();
|
||||
this.owner.destroy()
|
||||
})
|
||||
|
||||
this.btn_home.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
|
||||
if (config.H_SCREEN) {
|
||||
UIManager.getInstance().closeDCUI()
|
||||
var user = StorageManager.getInstance().getUser()
|
||||
user.update_progress(doStage.get_difficulty(), doStage.get_stageIndex()+1)//主线关卡更新难度进度
|
||||
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, doStage.get_difficulty(), doStage.get_difficulty())
|
||||
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID);
|
||||
}
|
||||
else {
|
||||
UIManager.getInstance().loadHomeUI()
|
||||
UIManager.getInstance().closeStageUI();
|
||||
}
|
||||
this.owner.destroy()
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@ import { respath } from "../constants/respath";
|
||||
import { config } from "../constants/config";
|
||||
import { UIManager } from "../models/UIManager";
|
||||
import { StorageManager } from "../models/StorageManager";
|
||||
import { LevelManager } from "../models/LevelManager";
|
||||
import { EventManager, EVENT_TYPES } from "../models/EventManager";
|
||||
import { Difficulty } from "./Difficulty";
|
||||
import { DOStage } from "../models/DOStage";
|
||||
|
||||
const { regClass, property } = Laya;
|
||||
|
||||
@@ -23,45 +23,49 @@ export class GameOver extends Laya.Script {
|
||||
public btn_newOrClose: Laya.Sprite
|
||||
@property(Laya.Label)
|
||||
public label_newOrClose: Laya.Label
|
||||
|
||||
|
||||
//组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
|
||||
onAwake(): void {
|
||||
public onSetStageInfo(doStage: DOStage): void {
|
||||
|
||||
this.btn_second.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
|
||||
var doStage = StorageManager.getInstance().getStage()
|
||||
doStage.set_mistake(doStage.get_mistake()-1)
|
||||
EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_UPDATE_MISTAKE)
|
||||
this.owner.destroy()
|
||||
})
|
||||
|
||||
this.btn_restart.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
|
||||
var doStage = StorageManager.getInstance().getStage()
|
||||
var stageID = doStage.get_stageID()
|
||||
var type = doStage.get_stageType()
|
||||
var difficulty = doStage.get_difficulty()
|
||||
StorageManager.getInstance().cleanStage()
|
||||
StorageManager.getInstance().newStage(stageID, type, difficulty, difficulty)
|
||||
UIManager.getInstance().loadStageUI(stageID);
|
||||
this.owner.destroy()
|
||||
})
|
||||
|
||||
var doStage = StorageManager.getInstance().getStage()
|
||||
var type = doStage.get_stageType()
|
||||
|
||||
if (type == config.STAGE_TYPE.MAIN) {
|
||||
this.label_newOrClose.text = "New Game"
|
||||
this.btn_newOrClose.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
|
||||
Laya.loader.load(respath.difficulty_ui_res).then((go)=>{
|
||||
var prefab = go.create()
|
||||
var d = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(Difficulty)
|
||||
d.onInit((value: string)=> {
|
||||
console.log("选择难度", value)
|
||||
StorageManager.getInstance().cleanStage()
|
||||
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value)
|
||||
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID);
|
||||
this.owner.destroy()
|
||||
})
|
||||
})
|
||||
if (config.H_SCREEN) {
|
||||
var user = StorageManager.getInstance().getUser()
|
||||
user.update_progress(doStage.get_difficulty(), doStage.get_stageIndex()+1)//主线关卡更新难度进度
|
||||
var difficulty = doStage.get_difficulty()
|
||||
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty)
|
||||
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID);
|
||||
this.owner.destroy()
|
||||
}
|
||||
else {
|
||||
Laya.loader.load(respath.difficulty_ui_res).then((go)=>{
|
||||
var prefab = go.create()
|
||||
var d = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(Difficulty)
|
||||
d.onInit((value: string)=> {
|
||||
console.log("选择难度", value)
|
||||
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value)
|
||||
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID);
|
||||
this.owner.destroy()
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
else {
|
||||
@@ -72,6 +76,6 @@ export class GameOver extends Laya.Script {
|
||||
this.owner.destroy()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { UIManager } from "../models/UIManager";
|
||||
import { StorageManager } from "../models/StorageManager";
|
||||
import { Utility_ConvertSecondToString } from "../utils/utility";
|
||||
import { EVENT_TYPES, EventManager } from "../models/EventManager";
|
||||
import { DOStage } from "../models/DOStage";
|
||||
|
||||
|
||||
|
||||
@@ -26,8 +27,10 @@ export class GamePause extends Laya.Script {
|
||||
|
||||
//组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
|
||||
onAwake(): void {
|
||||
|
||||
var doStage = StorageManager.getInstance().getStage()
|
||||
|
||||
}
|
||||
|
||||
public onSetStageInfo(doStage: DOStage): void {
|
||||
|
||||
this.label_time.text = Utility_ConvertSecondToString(doStage.get_duration())
|
||||
this.label_diffucuty.text = doStage.get_difficulty()
|
||||
@@ -42,11 +45,10 @@ export class GamePause extends Laya.Script {
|
||||
var stageID = doStage.get_stageID()
|
||||
var type = doStage.get_stageType()
|
||||
var difficulty = doStage.get_difficulty()
|
||||
StorageManager.getInstance().cleanStage()
|
||||
StorageManager.getInstance().newStage(stageID, type, difficulty, difficulty)
|
||||
UIManager.getInstance().loadStageUI(stageID);
|
||||
this.owner.destroy()
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -115,13 +115,24 @@ export class Home extends Laya.Script {
|
||||
this.btn_go.visible = false
|
||||
}
|
||||
else {
|
||||
var doStage = StorageManager.getInstance().loadStage(config.DEFAULT_STAGE_ID)
|
||||
var doStage = StorageManager.getInstance().getStage(config.DEFAULT_STAGE_ID)
|
||||
if (doStage) {
|
||||
console.log("当前主线关卡进行中")
|
||||
var label_time = this.btn_go.getChildByName("time").getChildByName("label_time") as Laya.Label
|
||||
var duration = doStage.get_duration()
|
||||
var timeStr = Utility_ConvertSecondToString(duration)
|
||||
label_time.text = `${timeStr} - ${doStage.get_difficulty()}`
|
||||
console.log("当前主线关卡进行中 mistake=", doStage.get_mistake())
|
||||
if (doStage.get_mistake() >= config.MISTAKE_MAX) {
|
||||
this.btn_new_blue.visible = true
|
||||
this.btn_new_white.visible = false
|
||||
this.btn_go.visible = false
|
||||
}
|
||||
else {
|
||||
this.btn_new_blue.visible = false
|
||||
this.btn_new_white.visible = true
|
||||
this.btn_go.visible = true
|
||||
|
||||
var label_time = this.btn_go.getChildByName("time").getChildByName("label_time") as Laya.Label
|
||||
var duration = doStage.get_duration()
|
||||
var timeStr = Utility_ConvertSecondToString(duration)
|
||||
label_time.text = `${timeStr} - ${doStage.get_difficulty()}`
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.log("当前主线关卡未开始")
|
||||
@@ -146,7 +157,6 @@ export class Home extends Laya.Script {
|
||||
var d = UIManager.getInstance().getUIRoot().addChild(prefab).getComponent(Difficulty)
|
||||
d.onInit((value: string)=> {
|
||||
console.log("选择难度", value)
|
||||
StorageManager.getInstance().cleanMainStage()
|
||||
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value)
|
||||
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID);
|
||||
this.owner.destroy()
|
||||
|
||||
@@ -16,8 +16,11 @@ const { regClass, property } = Laya;
|
||||
export class Stage extends Laya.Script {
|
||||
declare owner : Laya.Box;
|
||||
|
||||
@property(Laya.Button)
|
||||
public btn_back: Laya.Button
|
||||
@property(Laya.Box)
|
||||
public btn_back: Laya.Box
|
||||
@property(Laya.Box)
|
||||
public btn_new: Laya.Box
|
||||
|
||||
@property(Laya.Button)
|
||||
public btn_pause: Laya.Button
|
||||
@property(Laya.Label)
|
||||
@@ -63,6 +66,7 @@ export class Stage extends Laya.Script {
|
||||
private static _instance: Stage
|
||||
onAwake(): void {
|
||||
Stage._instance = this
|
||||
|
||||
this.btn_back.on(Laya.Event.CLICK, this, ()=>{
|
||||
if (this.data.get_stageType() == config.STAGE_TYPE.MAIN) {
|
||||
UIManager.getInstance().loadHomeUI();
|
||||
@@ -73,8 +77,19 @@ export class Stage extends Laya.Script {
|
||||
UIManager.getInstance().closeStageUI();
|
||||
}
|
||||
})
|
||||
|
||||
if (this.btn_new) {
|
||||
this.btn_new.on(Laya.Event.CLICK, this, ()=>{
|
||||
var user = StorageManager.getInstance().getUser()
|
||||
user.update_progress(this.data.get_difficulty(), this.data.get_stageIndex()+1)//主线关卡更新难度进度
|
||||
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, this.data.get_difficulty(), this.data.get_difficulty())
|
||||
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
this.btn_pause.on(Laya.Event.CLICK, this, ()=>{
|
||||
UIManager.getInstance().loadGamePauseUI();
|
||||
UIManager.getInstance().loadGamePauseUI(this.data);
|
||||
})
|
||||
for (var i=0; i<this.obj_blocks.numChildren; i++) {
|
||||
var hbox = this.obj_blocks.getChildAt(i);
|
||||
@@ -142,11 +157,19 @@ export class Stage extends Laya.Script {
|
||||
this.data = doStage
|
||||
this.paused = false
|
||||
|
||||
if (config.H_SCREEN) {
|
||||
this.btn_back.visible = this.data.get_stageType() == config.STAGE_TYPE.DC
|
||||
this.btn_new.visible = this.data.get_stageType() == config.STAGE_TYPE.MAIN
|
||||
}
|
||||
|
||||
this.onUpdateScore()
|
||||
this.label_name.text = this.data.get_stageName()
|
||||
if (this.data.get_stageType() == config.STAGE_TYPE.MAIN && config.H_SCREEN)
|
||||
this.label_name.text = ""
|
||||
this.onUpdateMistake()
|
||||
|
||||
this.label_time.text = Utility_ConvertSecondToString(this.data.get_duration())
|
||||
Laya.timer.clearAll(this)
|
||||
Laya.timer.loop(1000, this, ()=>{
|
||||
if (this.paused) {
|
||||
return
|
||||
@@ -348,7 +371,7 @@ export class Stage extends Laya.Script {
|
||||
var show = this.selectedBlock.getData().get_show()
|
||||
var notes = this.selectedBlock.getData().get_notes()
|
||||
if (this.selectedBlock.getData().get_checked() == false) {
|
||||
if (this.data.get_note_open()) {
|
||||
if (this.data.get_note_open() && hint == false) {
|
||||
var relateds = this.findRelatedBlocks(this.selectedBlock)
|
||||
var find = false
|
||||
for (var i=0; i<relateds.length; i++) {
|
||||
@@ -408,6 +431,7 @@ export class Stage extends Laya.Script {
|
||||
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)
|
||||
UIManager.getInstance().loadGameDoneUI(true, this.data)
|
||||
}
|
||||
else if (this.data.get_stageType() == config.STAGE_TYPE.DC) {//dc
|
||||
if (progress >= 1) {//完成每日挑战关卡检查是否或者当月奖杯
|
||||
@@ -424,8 +448,8 @@ export class Stage extends Laya.Script {
|
||||
user.add_trophy_record(nowYear, nowMonth, now.getDate())
|
||||
}
|
||||
}
|
||||
UIManager.getInstance().loadGameDoneUI(false, this.data)
|
||||
}
|
||||
UIManager.getInstance().loadGameDoneUI()
|
||||
}
|
||||
}
|
||||
else {//失败
|
||||
@@ -434,7 +458,7 @@ export class Stage extends Laya.Script {
|
||||
if (this.data.get_mistake() >= config.MISTAKE_MAX) {
|
||||
console.log("关卡失败")
|
||||
this.paused = true
|
||||
UIManager.getInstance().loadGameOverUI()
|
||||
UIManager.getInstance().loadGameOverUI(this.data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { config } from "../constants/config";
|
||||
import { StorageManager } from "../models/StorageManager";
|
||||
import { UIManager } from "../models/UIManager";
|
||||
import { CommonData } from "./common/CommonData";
|
||||
import { G_ShowCommonTips } from "./CommonTips";
|
||||
|
||||
const { regClass, property } = Laya;
|
||||
|
||||
@@ -25,26 +26,56 @@ export class TopBar extends Laya.Script {
|
||||
|
||||
private isClassic: boolean = true
|
||||
|
||||
@property(Laya.Label)
|
||||
public obj_label: Laya.Label
|
||||
@property(Laya.Box)
|
||||
public obj_items: Laya.Box
|
||||
private items: Map<string, Laya.Label> = new Map()
|
||||
|
||||
onStart(): void {
|
||||
onStart(): void {
|
||||
|
||||
//如果是第一次以横屏启动游戏需要创建经典关卡
|
||||
var difficulty = Laya.LocalStorage.getItem("difficulty")//读取用户上次选择的难度
|
||||
if (!difficulty || difficulty.length<=0) {
|
||||
difficulty = config.DIFFICULTY_TYPE.Easy
|
||||
Laya.LocalStorage.setItem("difficulty", difficulty)
|
||||
}
|
||||
var doStage = StorageManager.getInstance().getStage(config.DEFAULT_STAGE_ID)
|
||||
if (!doStage) {
|
||||
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty)
|
||||
}
|
||||
else {
|
||||
var user = StorageManager.getInstance().getUser()
|
||||
if (user.get_done(config.DEFAULT_STAGE_ID) >= 1) {
|
||||
console.log("当前主线关卡完成")
|
||||
user.update_progress(doStage.get_difficulty(), doStage.get_stageIndex()+1)//主线关卡更新难度进度
|
||||
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty)
|
||||
}
|
||||
else if (doStage.get_mistake() >= config.MISTAKE_MAX) {//上次失败了则重新开始
|
||||
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty)
|
||||
}
|
||||
}
|
||||
|
||||
this.btn_classic.on(Laya.Event.CLICK, this, ()=>{
|
||||
if (this.isClassic == false) {
|
||||
this.isClassic = true
|
||||
this.setLeftTab()
|
||||
this.onClickTab()
|
||||
}
|
||||
})
|
||||
this.btn_dc.on(Laya.Event.CLICK, this, ()=>{
|
||||
if (this.isClassic) {
|
||||
this.isClassic = false
|
||||
this.setLeftTab()
|
||||
this.onClickTab()
|
||||
}
|
||||
})
|
||||
this.setLeftTab()
|
||||
this.onClickTab()
|
||||
|
||||
|
||||
var showToggle = Laya.LocalStorage.getItem("showToggle")
|
||||
if (!showToggle || showToggle.length <= 0) {
|
||||
Laya.LocalStorage.setItem("showToggle", "true")
|
||||
}
|
||||
|
||||
for (var i=0; i<this.obj_items.numChildren; i++) {
|
||||
var obj = this.obj_items.getChildAt(i)
|
||||
var value = config.DIFFICULTY_LIST[i]
|
||||
@@ -57,43 +88,59 @@ export class TopBar extends Laya.Script {
|
||||
var common = evt.target.getComponent(CommonData)
|
||||
var difficulty = Laya.LocalStorage.getItem("difficulty")
|
||||
if (common.strValue != difficulty) {
|
||||
this.setDifficulty(common.strValue)
|
||||
Laya.LocalStorage.setItem("difficulty", common.strValue)//记录横屏模式用户选择的难度
|
||||
|
||||
StorageManager.getInstance().cleanStage()
|
||||
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty)
|
||||
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID)
|
||||
if (Laya.LocalStorage.getItem("showToggle")=="true") {
|
||||
var title = "Start New Game"
|
||||
var content = "Current game progress will be lost"
|
||||
G_ShowCommonTips(title, content, true, (ok: boolean, toggleValue: boolean)=>{
|
||||
if (ok) {
|
||||
if (toggleValue) {
|
||||
Laya.LocalStorage.setItem("showToggle", "false")
|
||||
}
|
||||
this.onClickDifficulty(common.strValue)
|
||||
}
|
||||
})
|
||||
}
|
||||
else {
|
||||
this.onClickDifficulty(common.strValue)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//如果是第一次以横屏启动游戏需要创建经典关卡
|
||||
var difficulty = Laya.LocalStorage.getItem("difficulty")//读取用户上次选择的难度
|
||||
if (!difficulty || difficulty.length<=0) {
|
||||
difficulty = config.DIFFICULTY_TYPE.Easy
|
||||
Laya.LocalStorage.setItem("difficulty", difficulty)
|
||||
}
|
||||
var doStage = StorageManager.getInstance().loadStage(config.DEFAULT_STAGE_ID)
|
||||
if (!doStage) {
|
||||
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty)
|
||||
}
|
||||
|
||||
this.setDifficulty(difficulty)
|
||||
this.updateDifficulty(difficulty)
|
||||
|
||||
}
|
||||
|
||||
setLeftTab(): void {
|
||||
onClickTab(): void {
|
||||
if (this.isClassic) {
|
||||
UIManager.getInstance().closeTrophyUI()
|
||||
UIManager.getInstance().closeDCUI()
|
||||
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID)
|
||||
}
|
||||
else {
|
||||
UIManager.getInstance().closeStageUI()
|
||||
UIManager.getInstance().loadDCUI()
|
||||
}
|
||||
this.updateLeftTab()
|
||||
}
|
||||
updateLeftTab(): void {
|
||||
this.sprite_classic.alpha = this.isClassic ? 1 : 0.1
|
||||
this.label_classic.color = this.isClassic ? "#ffffff" : "#0e2a53"
|
||||
this.sprite_dc.alpha = this.isClassic ? 0.1 : 1
|
||||
this.label_dc.color = this.isClassic ? "#0e2a53" : "#ffffff"
|
||||
|
||||
if (this.isClassic) {
|
||||
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID)
|
||||
}
|
||||
this.obj_label.visible = this.isClassic
|
||||
this.obj_items.visible = this.isClassic
|
||||
}
|
||||
|
||||
setDifficulty(difficulty: string): void {
|
||||
onClickDifficulty(difficulty: string): void {
|
||||
Laya.LocalStorage.setItem("difficulty", difficulty)//记录横屏模式用户选择的难度
|
||||
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty)
|
||||
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID)
|
||||
|
||||
this.updateDifficulty(difficulty)
|
||||
}
|
||||
|
||||
updateDifficulty(difficulty: string): void {
|
||||
this.items.forEach((label: Laya.Label, key: string)=>{
|
||||
label.color = "#0e2a53"
|
||||
})
|
||||
|
||||
@@ -7,4 +7,4 @@ export function G_ShowScoreTips(text: string, parent: any): void {
|
||||
var Label = obj.getChildByName("offset").getChildByName("Label") as Laya.Label
|
||||
Label.text = text
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { config } from "../../constants/config";
|
||||
|
||||
const { regClass, property } = Laya;
|
||||
|
||||
@regClass()
|
||||
@@ -89,6 +91,10 @@ export class CalendarUnit extends Laya.Script {
|
||||
|
||||
this.obj_star.visible = this.progress >= 1
|
||||
|
||||
var blockSize = 48
|
||||
if (config.H_SCREEN)
|
||||
blockSize = 33
|
||||
|
||||
if (this.selected) {
|
||||
this.label_show.color = "#ffffff"
|
||||
this.obj_selected.visible = true
|
||||
@@ -96,7 +102,7 @@ export class CalendarUnit extends Laya.Script {
|
||||
this.obj_pie.visible = true
|
||||
this.obj_mask.visible = true
|
||||
this.sprite_pie.graphics.clear()
|
||||
this.sprite_pie.graphics.drawPie(48, 48, 48, 0, 360*this.progress, "#ffffff")
|
||||
this.sprite_pie.graphics.drawPie(blockSize, blockSize, blockSize, 0, 360*this.progress, "#ffffff")
|
||||
this.sprite_mask.graphics.clear()
|
||||
this.sprite_mask.graphics.drawCircle(0.5, 0.5, 0.5, "#1d5cdc")
|
||||
}
|
||||
@@ -112,7 +118,7 @@ export class CalendarUnit extends Laya.Script {
|
||||
this.obj_pie.visible = true
|
||||
this.obj_mask.visible = true
|
||||
this.sprite_pie.graphics.clear()
|
||||
this.sprite_pie.graphics.drawPie(48, 48, 48, 0, 360*this.progress, "#2d3138")
|
||||
this.sprite_pie.graphics.drawPie(blockSize, blockSize, blockSize, 0, 360*this.progress, "#2d3138")
|
||||
this.sprite_mask.graphics.clear()
|
||||
this.sprite_mask.graphics.drawCircle(0.5, 0.5, 0.5, "#ffffff")
|
||||
}
|
||||
|
||||
@@ -60,10 +60,12 @@ export class DailyChallenge extends Laya.Script {
|
||||
private indexMax: number
|
||||
|
||||
onAwake(): void {
|
||||
this.btn_back.on(Laya.Event.CLICK, this, ()=>{
|
||||
UIManager.getInstance().loadHomeUI()
|
||||
this.owner.destroy()
|
||||
})
|
||||
if (this.btn_back) {
|
||||
this.btn_back.on(Laya.Event.CLICK, this, ()=>{
|
||||
UIManager.getInstance().loadHomeUI()
|
||||
UIManager.getInstance().closeDCUI()
|
||||
})
|
||||
}
|
||||
|
||||
var user = StorageManager.getInstance().getUser()
|
||||
this.btn_trophy_red.visible = user.get_trophyHasUnread()
|
||||
@@ -80,7 +82,7 @@ export class DailyChallenge extends Laya.Script {
|
||||
var month = now.getMonth() + 1
|
||||
var dayNow = this.selectedUnit.day
|
||||
var stageID = `${year}-${month}-${dayNow}`
|
||||
var doStage = StorageManager.getInstance().loadStage(stageID)
|
||||
var doStage = StorageManager.getInstance().getStage(stageID)
|
||||
console.log("play >>>>>>>>>>>>>>>>>>>>>>>", stageID, doStage)
|
||||
if (!doStage) {
|
||||
var stageName = `${config.MONTH_ABBRS[month-1]} ${dayNow}`
|
||||
@@ -217,7 +219,7 @@ export class DailyChallenge extends Laya.Script {
|
||||
if (progress >= 1) {
|
||||
this.btn_play.visible = false
|
||||
this.obj_summary.visible = true
|
||||
var doStage = StorageManager.getInstance().loadStage(stageID)
|
||||
var doStage = StorageManager.getInstance().getStage(stageID)
|
||||
this.label_diffucuty.text = doStage.get_difficulty()
|
||||
this.label_score.text = doStage.get_score().toString()
|
||||
this.label_time.text = Utility_ConvertSecondToString(doStage.get_duration())
|
||||
@@ -225,7 +227,7 @@ export class DailyChallenge extends Laya.Script {
|
||||
else {
|
||||
this.btn_play.visible = true
|
||||
this.obj_summary.visible = false
|
||||
var doStage = StorageManager.getInstance().loadStage(stageID)
|
||||
var doStage = StorageManager.getInstance().getStage(stageID)
|
||||
if (doStage) {
|
||||
this.label_play.text = "Continue"
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
|
||||
|
||||
import { config } from "../../constants/config";
|
||||
import { respath } from "../../constants/respath";
|
||||
import { MONTH_LIST } from "../../models/DCManager";
|
||||
import { UIManager } from "../../models/UIManager";
|
||||
import { TrophyUnit } from "./TrophyUnit";
|
||||
|
||||
const { regClass, property } = Laya;
|
||||
@@ -12,8 +14,8 @@ const { regClass, property } = Laya;
|
||||
export class TrophyRoom extends Laya.Script {
|
||||
declare owner : Laya.Box;
|
||||
|
||||
@property(Laya.Button)
|
||||
public btn_back: Laya.Button;
|
||||
@property(Laya.Box)
|
||||
public btn_back: Laya.Box;
|
||||
|
||||
@property(Laya.Box)
|
||||
public obj_items: Laya.Box;
|
||||
@@ -21,8 +23,12 @@ export class TrophyRoom extends Laya.Script {
|
||||
//第一次执行update之前执行,只会执行一次
|
||||
onStart(): void {
|
||||
|
||||
var trophyCountOfCell = 3
|
||||
if (config.H_SCREEN)
|
||||
trophyCountOfCell = 5
|
||||
|
||||
this.btn_back.on(Laya.Event.CLICK, this, ()=>{
|
||||
this.owner.destroy()
|
||||
UIManager.getInstance().closeTrophyUI()
|
||||
})
|
||||
|
||||
var infos: Array<any> = new Array()
|
||||
@@ -52,7 +58,7 @@ export class TrophyRoom extends Laya.Script {
|
||||
list.push(obj)
|
||||
}
|
||||
console.log(">>>>>>>>>>>>years=", years)
|
||||
Laya.loader.load(respath.trophy_year_ui_res).then((go)=>{
|
||||
Laya.loader.load(respath.trophy_year_ui_res()).then((go)=>{
|
||||
for (var i=1; i<years.length; i++) {
|
||||
var obj_year = this.obj_items.getChildAt(i)
|
||||
if (!obj_year) {
|
||||
@@ -61,11 +67,11 @@ export class TrophyRoom extends Laya.Script {
|
||||
}
|
||||
}
|
||||
|
||||
Laya.loader.load(respath.trophy_cell_ui_res).then((go)=>{
|
||||
Laya.loader.load(respath.trophy_cell_ui_res()).then((go)=>{
|
||||
var itemsHeight = 0
|
||||
for (var i=0; i<years.length; i++) {
|
||||
var list = monthMap.get(years[i])
|
||||
var cellCount = Math.ceil(list.length/3)
|
||||
var cellCount = Math.ceil(list.length/trophyCountOfCell)
|
||||
var yearHeight = 120 + cellCount * 444
|
||||
itemsHeight += yearHeight
|
||||
|
||||
|
||||
Reference in New Issue
Block a user