修改为单场景

This commit is contained in:
2025-09-20 18:41:10 +08:00
parent 86059e7525
commit 5eb3abacc8
11 changed files with 1531 additions and 3508 deletions
+113 -52
View File
@@ -6,6 +6,7 @@ import {
Button,
Component,
ImageAsset,
instantiate,
JsonAsset,
Label,
Material,
@@ -25,22 +26,48 @@ import Utils from "../../Main/Common/Utils";
import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
import { promptItem } from "../Item/promptItem";
import LanguageUtils, { LanguageType } from "../../Main/Common/LanguageUtils";
import { DataManager } from "../../chat18x/data/DataManager";
import { DataId, DataManager } from "../../chat18x/data/DataManager";
import { ConfigManager } from "../../chat18x/manager/ConfigManager";
import { AppConfig } from "db://assets/Scripts/chat18x/config/env/appConfig";
import DeviceIdService from "db://assets/Scripts/chat18x/foundation/identity/DeviceIdService";
import { AccountData } from "../../chat18x/data/AccountData";
import { EnvData } from "../../chat18x/data/EnvData";
import { GlobalData } from "../../chat18x/data/GlobalData";
import { LoginData } from "../../chat18x/data/LoginData";
import { PlayerData } from "../../chat18x/data/PlayerData";
import { WalletData } from "../../chat18x/data/WalletData";
import MachineInfoService from "../../chat18x/foundation/identity/MachineInfoService";
import { AuthService } from "../../chat18x/network/services/AuthService";
import { CommonService } from "../../chat18x/network/services/CommonService";
import { PlayerDataService } from "../../chat18x/network/services/PlayerDataService";
import proto from "db://assets/Scripts/proto/proto.pb.js";
import { ViewManager } from "../../Main/Manager/ViewManager";
import { MainScene } from "../MainScene";
const { ccclass, property } = _decorator;
@ccclass("PreloadUI")
export class PreloadUI extends Component {
private preloadFinish = false; //资源加载完成
@property(MainScene)
mainScene: MainScene = null;
private _nodeTab: any = {};
private preloadFinish = false; //资源加载完成
private loginFinish = false; //登录完成
loginBtn: Node;
private jinduBar: Node = null;
private jinduFilled: Sprite = null;
start() {
//Utils.addInnerEL(InnerMsgCode.UI_ShowPrompt, this, this.resiveShowPrompt)
Utils.parseNode(this.node, this._nodeTab);
this.loginBtn = this._nodeTab.btnLogin;
this.loginBtn.active = false;
GButton.BandClick(this.loginBtn, this.onLogin, this);
this.jinduBar = this.node.getChildByName("jinduBar");
this.jinduFilled = this.jinduBar
@@ -48,8 +75,8 @@ export class PreloadUI extends Component {
.getComponent(Sprite);
//适配背景图
let BG = this.node.getChildByName("BG");
Utils.adjustBgPixelRatio(BG, 1);
//let BG = this.node.getChildByName("BG");
//Utils.adjustBgPixelRatio(BG, 1);
this.jinduFilled.fillRange = 0;
@@ -77,9 +104,16 @@ export class PreloadUI extends Component {
}
update(deltaTime: number) {
if (this.preloadFinish) {
if (!this.preloadFinish) {
return;
//this.goToLoginScene();
}
if (this.loginFinish) {
this.loginFinish = false;
this.preloadFinish = false;
this.goToLoginScene();
this.enterGame();
}
}
@@ -100,25 +134,6 @@ export class PreloadUI extends Component {
{ path: "ChatPanel", bundleName: "Chat18x", ftype: Prefab },
{ path: "GirlDetailPanel", bundleName: "Chat18x", ftype: Prefab },
{ path: "GirlListPanel", bundleName: "Chat18x", ftype: Prefab },
// {path:"Music/music_interface", bundleName: "Audio", ftype: AudioClip},
// {path:"bg/mengli_stage_bg", bundleName: "Raw", ftype: ImageAsset},
// {path:"cg0/mengli_0_cg", bundleName: "Raw", ftype: ImageAsset},
// {path:"cg1/mengli_1_cg", bundleName: "Raw", ftype: ImageAsset},
// {path:"cg2/mengli_2_cg", bundleName: "Raw", ftype: ImageAsset},
// {path:"cg3/mengli_3_cg", bundleName: "Raw", ftype: ImageAsset},
// {path:"emo_1/mengli_shy", bundleName: "Raw", ftype: ImageAsset},
// {path:"emo_2/mengli_laugh", bundleName: "Raw", ftype: ImageAsset},
// {path:"emo_3/mengli_disgust", bundleName: "Raw", ftype: ImageAsset},
// {path:"role/mengli_default", bundleName: "Raw", ftype: ImageAsset},
// {path:"Zjm/raw1", bundleName: "Raw", ftype: ImageAsset},
// {path:"touming", bundleName: "common", ftype: ImageAsset},
// // {path:"chanpin_1_0", bundleName: "daoju", ftype: ImageAsset}, //有合图加载失败
// {path:"zjm_1", bundleName: "Zhujiemian", ftype: ImageAsset},
// {path:"zjm_19", bundleName: "Zhujiemian", ftype: ImageAsset},
// {path:"zjm_30", bundleName: "Zhujiemian", ftype: ImageAsset},
// {path:"mohu", bundleName: "Materials", ftype: Material},
// {path:"UI/Cross/Cross_UI", bundleName: "PB", ftype: Prefab},
// {path:"UI/StartUI/Start_UI", bundleName: "PB", ftype: Prefab},
{ path: "tblanguage", bundleName: "DataTable", ftype: BufferAsset },
];
let num_prefab = 0; //已加载数量
@@ -145,7 +160,7 @@ export class PreloadUI extends Component {
);
} else {
if (num_succeed >= num_prefab) {
this.loadDataTable();
this.startloginProcess();
}
}
};
@@ -153,29 +168,10 @@ export class PreloadUI extends Component {
}
//加载配置表
loadDataTable() {
let dataArr = [
//"commonGlobal",
// "levelHole",
//"Music",
//"Sound",
];
//配置表使用方法: let cfgs = Resource.getConfig("Sound")
let num_prefab = 0;
let preloadFunc = () => {
if (num_prefab < dataArr.length) {
let cfgname = dataArr[num_prefab];
ResManager.I.loadSubpackageDataTable(cfgname, (ret: JsonAsset) => {
num_prefab++;
Resource.addSubJsonConfig(cfgname, ret.json);
preloadFunc();
});
} else {
this.preloadFinish = true;
}
};
preloadFunc();
startloginProcess() {
this.jinduBar.active = false;
this.preloadFinish = true;
this.loginBtn.active = true;
}
//显示加载进度
@@ -184,8 +180,73 @@ export class PreloadUI extends Component {
}
// 跳转到登录场景
private goToLoginScene() {
this.jinduBar.active = false;
ResManager.I.goCustomScene("LoginScene");
// private goToLoginScene() {
// this.jinduBar.active = false;
// ResManager.I.goCustomScene("LoginScene");
// }
async onLogin() {
const deviceId = DeviceIdService.I.id;
const os = MachineInfoService.I.getMachineOs();
const reqData = {
platType: "guest",
userId: deviceId,
device: deviceId,
os,
};
console.log("登录请求数据:", reqData);
let res = await AuthService.I.login(reqData);
console.log("登录响应数据:", res);
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
const resData = res.data;
const loginData = DataManager.I.getDataById<LoginData>(DataId.Login);
loginData.token = resData.token;
loginData.refreshToken = resData.refreshToken;
loginData.expire = Number(resData.expire);
const playerData = DataManager.I.getDataById<PlayerData>(DataId.Player);
playerData.name = resData.name;
const accountData = DataManager.I.getDataById<AccountData>(
DataId.Account
);
accountData.accId = resData.accId;
const envData = DataManager.I.getDataById<EnvData>(DataId.Env);
envData.cdn = resData.cdn;
this.loginFinish = true;
this.reqMyInfo();
this.reqGlobalData();
}
}
// 请求个人数据
private async reqMyInfo() {
const reqData = {};
let res = await PlayerDataService.I.reqMyInfo(reqData);
console.log("个人信息响应数据:", res);
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
const resData = res.data;
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
walletData.balance = Number(resData.balance);
walletData.vipExpire = Number(resData.vipExpire);
}
}
// 请求全局数据
private async reqGlobalData() {
const reqData = {
resName: "TbGlobalConfig",
};
let res = await CommonService.I.reqResConfig(reqData);
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
// 保存数据
const globalData = DataManager.I.getDataById<GlobalData>(DataId.Global);
globalData.globals = res.data;
}
}
private enterGame() {
this.mainScene.init();
this.node.destroy();
//ResManager.I.goMainScene();
}
}