继续补充横屏逻辑

This commit is contained in:
2025-05-26 21:17:05 +08:00
parent 12b16320e6
commit 4e0e536c49
5 changed files with 45 additions and 26 deletions

View File

@@ -71,14 +71,22 @@ export class StorageManager {
this.user.update_progress(difficulty, index)
}
}
else if (type == config.STAGE_TYPE.DC) {
var random = Math.random()
difficulty = config.DIFFICULTY_LIST[Math.floor(random*config.DIFFICULTY_LIST.length)]
var list = LevelManager.getInstance().getLevelList(difficulty)
random = Math.random()
index = Math.floor(random*list.length)
console.log("每日挑战随机一个关卡", difficulty, index)
else if (type == config.STAGE_TYPE.DC) {//每天调整如果已经创建过关卡那么就用之前的关卡配置
var value = this.getStage(stageID)
if (value) {
difficulty = value.get_difficulty()
index = value.get_stageIndex()
}
else {
var random = Math.random()
difficulty = config.DIFFICULTY_LIST[Math.floor(random*config.DIFFICULTY_LIST.length)]
var list = LevelManager.getInstance().getLevelList(difficulty)
random = Math.random()
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)

View File

@@ -11,6 +11,7 @@ import { DOStage } from "./DOStage"
import { GamePause } from "../views/GamePause"
import { GameOver } from "../views/GameOver"
import { GameDone } from "../views/GameDone"
import { TopBar } from "../views/TopBar"
const { regClass, property } = Laya
@@ -44,7 +45,7 @@ export class UIManager extends Laya.Script {
return this.UIRoot
}
private topbar : TopBar
private stage: Stage
private dc_ui: DailyChallenge
private trophyRoom: TrophyRoom
@@ -70,9 +71,14 @@ export class UIManager extends Laya.Script {
public loadTopBarUI(): void {
Laya.loader.load(respath.topbar_ui_res).then((go)=>{
var prefab = go.create()
this.getUIRoot().addChild(prefab)
this.topbar = this.getUIRoot().addChild(prefab).getComponent(TopBar)
})
}
public setTopbarTo(isClassic: boolean): void {
if (this.topbar) {
this.topbar.onClickTab(isClassic)
}
}
public loadDCUI(): void {
Laya.loader.load(respath.dc_ui_res()).then((go)=>{

View File

@@ -67,10 +67,15 @@ export class GameDone extends Laya.Script {
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);
if (doStage.get_stageType() == config.STAGE_TYPE.MAIN) {
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 if (doStage.get_stageType() == config.STAGE_TYPE.DC) {
UIManager.getInstance().setTopbarTo(true)
}
}
else {
UIManager.getInstance().loadHomeUI()

View File

@@ -34,12 +34,12 @@ export class GameOver extends Laya.Script {
})
this.btn_restart.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
var stageID = doStage.get_stageID()
var type = doStage.get_stageType()
var difficulty = doStage.get_difficulty()
StorageManager.getInstance().newStage(stageID, type, difficulty, difficulty)
UIManager.getInstance().loadStageUI(stageID);
this.owner.destroy()
var stageID = doStage.get_stageID()
var type = doStage.get_stageType()
var difficulty = doStage.get_difficulty()
StorageManager.getInstance().newStage(stageID, type, difficulty, difficulty)
UIManager.getInstance().loadStageUI(stageID);
this.owner.destroy()
})
var type = doStage.get_stageType()

View File

@@ -58,17 +58,15 @@ export class TopBar extends Laya.Script {
this.btn_classic.on(Laya.Event.CLICK, this, ()=>{
if (this.isClassic == false) {
this.isClassic = true
this.onClickTab()
this.onClickTab(true)
}
})
this.btn_dc.on(Laya.Event.CLICK, this, ()=>{
if (this.isClassic) {
this.isClassic = false
this.onClickTab()
this.onClickTab(false)
}
})
this.onClickTab()
this.onClickTab(this.isClassic)
var showToggle = Laya.LocalStorage.getItem("showToggle")
@@ -110,8 +108,9 @@ export class TopBar extends Laya.Script {
}
onClickTab(): void {
if (this.isClassic) {
onClickTab(isClassic: boolean): void {
this.isClassic = true
if (isClassic) {
UIManager.getInstance().closeTrophyUI()
UIManager.getInstance().closeDCUI()
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID)
@@ -122,6 +121,7 @@ export class TopBar extends Laya.Script {
}
this.updateLeftTab()
}
updateLeftTab(): void {
this.sprite_classic.alpha = this.isClassic ? 1 : 0.1
this.label_classic.color = this.isClassic ? "#ffffff" : "#0e2a53"