Merge branch 'main' of 47.107.44.202:xionglijia/18xchat
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
|||||||
{"ver":"1.1.50","importer":"scene","imported":true,"uuid":"dab4ae00-c26e-4176-9c7e-709d8899e525","files":[".json"],"subMetas":{},"userData":{}}
|
|
||||||
+1368
-282
File diff suppressed because it is too large
Load Diff
@@ -1 +1,11 @@
|
|||||||
{"ver":"1.1.50","importer":"scene","imported":true,"uuid":"1a23cd3e-e487-4fd1-a415-346c2087464d","files":[".json"],"subMetas":{},"userData":{}}
|
{
|
||||||
|
"ver": "1.1.50",
|
||||||
|
"importer": "scene",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "16b0d021-6436-4bbc-ba5e-05ebe3e84ba4",
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "1.1.50",
|
|
||||||
"importer": "scene",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "16b0d021-6436-4bbc-ba5e-05ebe3e84ba4",
|
|
||||||
"files": [
|
|
||||||
".json"
|
|
||||||
],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,29 @@
|
|||||||
import { _decorator, AssetManager, assetManager, Component, Node, director, Prefab, resources, Sprite, SpriteFrame, Texture2D, v2, SpriteAtlas, ImageAsset, instantiate, AudioClip, Asset, JsonAsset, Material, VideoPlayer, VideoClip } from 'cc';
|
import {
|
||||||
|
_decorator,
|
||||||
|
AssetManager,
|
||||||
|
assetManager,
|
||||||
|
Component,
|
||||||
|
Node,
|
||||||
|
director,
|
||||||
|
Prefab,
|
||||||
|
resources,
|
||||||
|
Sprite,
|
||||||
|
SpriteFrame,
|
||||||
|
Texture2D,
|
||||||
|
v2,
|
||||||
|
SpriteAtlas,
|
||||||
|
ImageAsset,
|
||||||
|
instantiate,
|
||||||
|
AudioClip,
|
||||||
|
Asset,
|
||||||
|
JsonAsset,
|
||||||
|
Material,
|
||||||
|
VideoPlayer,
|
||||||
|
VideoClip,
|
||||||
|
} from "cc";
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@ccclass('ResManager')
|
@ccclass("ResManager")
|
||||||
export default class ResManager {
|
export default class ResManager {
|
||||||
private static _I: ResManager = null;
|
private static _I: ResManager = null;
|
||||||
public static get I(): ResManager {
|
public static get I(): ResManager {
|
||||||
@@ -11,30 +33,26 @@ export default class ResManager {
|
|||||||
return ResManager._I;
|
return ResManager._I;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**切换场景 */
|
/**切换场景 */
|
||||||
enterScene(i_sceneName: string) {
|
enterScene(i_sceneName: string) {
|
||||||
director.loadScene(i_sceneName, () => { });
|
director.loadScene(i_sceneName, () => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** 场景-跳转到主界面场景*/
|
/** 场景-跳转到主界面场景*/
|
||||||
goMainScene() {
|
goMainScene() {
|
||||||
this.enterScene('MainScene');
|
this.enterScene("MainScene");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 场景-跳转到游戏场景*/
|
/** 场景-跳转到游戏场景*/
|
||||||
goGameScene() {
|
goGameScene() {
|
||||||
this.enterScene('GameScene');
|
this.enterScene("GameScene");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 场景-跳转到自定义场景*/
|
/** 场景-跳转到自定义场景*/
|
||||||
goCustomScene(sceneName:string) {
|
goCustomScene(sceneName: string) {
|
||||||
this.enterScene(sceneName);
|
this.enterScene(sceneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// /**加载bundle */
|
// /**加载bundle */
|
||||||
// loadBundle(bundleName, cb?) {
|
// loadBundle(bundleName, cb?) {
|
||||||
@@ -57,116 +75,132 @@ export default class ResManager {
|
|||||||
/**预加载bundle中的PB*/
|
/**预加载bundle中的PB*/
|
||||||
preLoadSubpackagePrefab(url: string, cb) {
|
preLoadSubpackagePrefab(url: string, cb) {
|
||||||
let bundle = assetManager.getBundle("PB");
|
let bundle = assetManager.getBundle("PB");
|
||||||
if (bundle){
|
if (bundle) {
|
||||||
bundle.preload(url, Prefab, (err, res) => {
|
bundle.preload(url, Prefab, (err, res) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
cb && cb();
|
cb && cb();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
assetManager.loadBundle("PB", (err: Error, _bundle: AssetManager.Bundle) => {
|
assetManager.loadBundle(
|
||||||
|
"PB",
|
||||||
|
(err: Error, _bundle: AssetManager.Bundle) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
this.preLoadSubpackagePrefab(url, cb);
|
this.preLoadSubpackagePrefab(url, cb);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**预加载bundle中的文件*/
|
/**预加载bundle中的文件*/
|
||||||
preLoadSubpackageFile(url: string, pkgName: string, ftype, succCB, failCB) {
|
preLoadSubpackageFile(url: string, pkgName: string, ftype, succCB, failCB) {
|
||||||
let bundle = assetManager.getBundle(pkgName);
|
let bundle = assetManager.getBundle(pkgName);
|
||||||
if (bundle){
|
if (bundle) {
|
||||||
bundle.preload(url, ftype, (err, res) => {
|
bundle.preload(url, ftype, (err, res) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
failCB && failCB(err);
|
failCB && failCB(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
succCB && succCB();
|
succCB && succCB();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
assetManager.loadBundle(pkgName, (err: Error, _bundle: AssetManager.Bundle) => {
|
assetManager.loadBundle(
|
||||||
|
pkgName,
|
||||||
|
(err: Error, _bundle: AssetManager.Bundle) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
failCB && failCB(err);
|
failCB && failCB(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
this.preLoadSubpackageFile(url, pkgName, ftype, succCB, failCB);
|
this.preLoadSubpackageFile(url, pkgName, ftype, succCB, failCB);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** 加载bundle中的PB*/
|
/** 加载bundle中的PB*/
|
||||||
loadSubpackagePrefab(url: string, cb) {
|
loadSubpackagePrefab(url: string, cb) {
|
||||||
let bundle = assetManager.getBundle("Chat18x");
|
let bundle = assetManager.getBundle("Chat18x");
|
||||||
if (bundle){
|
if (bundle) {
|
||||||
bundle.load(url, Prefab, (err, res: Prefab) => {
|
bundle.load(url, Prefab, (err, res: Prefab) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
let cc_N = instantiate(res);
|
let cc_N = instantiate(res);
|
||||||
cb && cb(cc_N);
|
cb && cb(cc_N);
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
assetManager.loadBundle("PB", (err: Error, _bundle: AssetManager.Bundle) => {
|
assetManager.loadBundle(
|
||||||
|
"PB",
|
||||||
|
(err: Error, _bundle: AssetManager.Bundle) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
this.loadSubpackagePrefab(url, cb);
|
this.loadSubpackagePrefab(url, cb);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**获取pb节点 */
|
/**获取pb节点 */
|
||||||
getPrefab(path: string, cb: Function, target: Node) {
|
getPrefab(path: string, cb: Function, target: Node) {
|
||||||
this.loadSubpackagePrefab(path, (pb: Prefab) => {
|
this.loadSubpackagePrefab(path, (pb: Prefab) => {
|
||||||
if (target && !target.isValid) {
|
if (target && !target.isValid) {
|
||||||
pb.destroy()
|
pb.destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pb['path'] = path;
|
pb["path"] = path;
|
||||||
cb && cb(pb);
|
cb && cb(pb);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** 加载bundle中的PB*/
|
/** 加载bundle中的PB*/
|
||||||
loadSubpackage3DModel(url: string, cb) {
|
loadSubpackage3DModel(url: string, cb) {
|
||||||
let bundle = assetManager.getBundle("Model3D");
|
let bundle = assetManager.getBundle("Model3D");
|
||||||
if (bundle){
|
if (bundle) {
|
||||||
bundle.load(url, Prefab, (err, res: Prefab) => {
|
bundle.load(url, Prefab, (err, res: Prefab) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
let cc_N = instantiate(res);
|
let cc_N = instantiate(res);
|
||||||
cb && cb(cc_N);
|
cb && cb(cc_N);
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
assetManager.loadBundle("Model3D", (err: Error, _bundle: AssetManager.Bundle) => {
|
assetManager.loadBundle(
|
||||||
|
"Model3D",
|
||||||
|
(err: Error, _bundle: AssetManager.Bundle) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
this.loadSubpackage3DModel(url, cb);
|
this.loadSubpackage3DModel(url, cb);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 改变图片--bundle资源 sprite-frame类型的图片*/
|
/** 改变图片--bundle资源 sprite-frame类型的图片*/
|
||||||
changeBundleVideo(spt: VideoPlayer, url: string, packageName: string, cb: Function = null) {
|
changeBundleVideo(
|
||||||
|
spt: VideoPlayer,
|
||||||
|
url: string,
|
||||||
|
packageName: string,
|
||||||
|
cb: Function = null
|
||||||
|
) {
|
||||||
if (!spt || !url) return;
|
if (!spt || !url) return;
|
||||||
let spttemp:any = spt
|
let spttemp: any = spt;
|
||||||
spttemp.frameUrl = url
|
spttemp.frameUrl = url;
|
||||||
let bundle = assetManager.getBundle(packageName);
|
let bundle = assetManager.getBundle(packageName);
|
||||||
if (bundle){
|
if (bundle) {
|
||||||
bundle.load(url, VideoClip, (err, res: VideoClip) => {
|
bundle.load(url, VideoClip, (err, res: VideoClip) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
if (!spt.isValid) {
|
if (!spt.isValid) {
|
||||||
return;
|
return;
|
||||||
@@ -178,27 +212,38 @@ export default class ResManager {
|
|||||||
//spt.spriteFrame = res;
|
//spt.spriteFrame = res;
|
||||||
cb && cb(res);
|
cb && cb(res);
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
assetManager.loadBundle(packageName, (err: Error, _bundle: AssetManager.Bundle) => {
|
assetManager.loadBundle(
|
||||||
|
packageName,
|
||||||
|
(err: Error, _bundle: AssetManager.Bundle) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
this.changeBundleVideo(spt, url, packageName, cb);
|
this.changeBundleVideo(spt, url, packageName, cb);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** 改变图片--bundle资源 sprite-frame类型的图片*/
|
/** 改变图片--bundle资源 sprite-frame类型的图片*/
|
||||||
changeBundleSpriteFrame(spt: Sprite, url: string, packageName: string, cb: Function = null) {
|
changeBundleSpriteFrame(
|
||||||
|
spt: Sprite,
|
||||||
|
url: string,
|
||||||
|
packageName: string,
|
||||||
|
cb: Function = null
|
||||||
|
) {
|
||||||
if (!spt || !url) return;
|
if (!spt || !url) return;
|
||||||
let spttemp:any = spt
|
let spttemp: any = spt;
|
||||||
spttemp.frameUrl = url
|
spttemp.frameUrl = url;
|
||||||
let bundle = assetManager.getBundle(packageName);
|
let bundle = assetManager.getBundle(packageName);
|
||||||
if (bundle){
|
if (bundle) {
|
||||||
bundle.load(url + "/spriteFrame", SpriteFrame, (err, res: SpriteFrame) => {
|
bundle.load(
|
||||||
|
url + "/spriteFrame",
|
||||||
|
SpriteFrame,
|
||||||
|
(err, res: SpriteFrame) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
if (!spt.isValid) {
|
if (!spt.isValid) {
|
||||||
return;
|
return;
|
||||||
@@ -208,93 +253,108 @@ export default class ResManager {
|
|||||||
}
|
}
|
||||||
spt.spriteFrame = res;
|
spt.spriteFrame = res;
|
||||||
cb && cb(res);
|
cb && cb(res);
|
||||||
});
|
}
|
||||||
}else{
|
);
|
||||||
assetManager.loadBundle(packageName, (err: Error, _bundle: AssetManager.Bundle) => {
|
} else {
|
||||||
|
assetManager.loadBundle(
|
||||||
|
packageName,
|
||||||
|
(err: Error, _bundle: AssetManager.Bundle) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
this.changeBundleSpriteFrame(spt, url, packageName, cb);
|
this.changeBundleSpriteFrame(spt, url, packageName, cb);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** 改变图片--bundle资源 texture类型的图片*/
|
/** 改变图片--bundle资源 texture类型的图片*/
|
||||||
changeBundleTexture(spt: Sprite, url: string, packageName: string, cb: Function = null) {
|
changeBundleTexture(
|
||||||
|
spt: Sprite,
|
||||||
|
url: string,
|
||||||
|
packageName: string,
|
||||||
|
cb: Function = null
|
||||||
|
) {
|
||||||
if (!spt || !url) return;
|
if (!spt || !url) return;
|
||||||
let bundle = assetManager.getBundle(packageName);
|
let bundle = assetManager.getBundle(packageName);
|
||||||
if (bundle){
|
if (bundle) {
|
||||||
bundle.load(url + "/texture", Texture2D, (err, res: Texture2D) => {
|
bundle.load(url + "/texture", Texture2D, (err, res: Texture2D) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
if (!spt.isValid) {
|
if (!spt.isValid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let spriteFrame = new SpriteFrame()
|
let spriteFrame = new SpriteFrame();
|
||||||
spriteFrame.texture = res
|
spriteFrame.texture = res;
|
||||||
spt.spriteFrame = spriteFrame;
|
spt.spriteFrame = spriteFrame;
|
||||||
cb && cb(res);
|
cb && cb(res);
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
assetManager.loadBundle(packageName, (err: Error, _bundle: AssetManager.Bundle) => {
|
assetManager.loadBundle(
|
||||||
|
packageName,
|
||||||
|
(err: Error, _bundle: AssetManager.Bundle) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
this.changeBundleTexture(spt, url, packageName, cb);
|
this.changeBundleTexture(spt, url, packageName, cb);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** 加载bundle中的音频文件*/
|
/** 加载bundle中的音频文件*/
|
||||||
getBundleAudio(url: string, cb) {
|
getBundleAudio(url: string, cb) {
|
||||||
let bundle = assetManager.getBundle("Audio");
|
let bundle = assetManager.getBundle("Audio");
|
||||||
if (bundle){
|
if (bundle) {
|
||||||
bundle.load(url, AudioClip, (err, res: AudioClip) => {
|
bundle.load(url, AudioClip, (err, res: AudioClip) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
cb && cb(res);
|
cb && cb(res);
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
assetManager.loadBundle("Audio", (err: Error, _bundle: AssetManager.Bundle) => {
|
assetManager.loadBundle(
|
||||||
|
"Audio",
|
||||||
|
(err: Error, _bundle: AssetManager.Bundle) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
this.getBundleAudio(url, cb);
|
this.getBundleAudio(url, cb);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** 加载bundle中的配置表*/
|
/** 加载bundle中的配置表*/
|
||||||
loadSubpackageDataTable(url: string, cb) {
|
loadSubpackageDataTable(url: string, cb) {
|
||||||
let bundle = assetManager.getBundle("DataTable");
|
let bundle = assetManager.getBundle("DataTable");
|
||||||
if (bundle){
|
if (bundle) {
|
||||||
bundle.load(url, JsonAsset, (err, res: JsonAsset) => {
|
bundle.load(url, JsonAsset, (err, res: JsonAsset) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
cb && cb(res);
|
cb && cb(res);
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
assetManager.loadBundle("DataTable", (err: Error, _bundle: AssetManager.Bundle) => {
|
assetManager.loadBundle(
|
||||||
|
"DataTable",
|
||||||
|
(err: Error, _bundle: AssetManager.Bundle) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
this.loadSubpackagePrefab(url, cb);
|
this.loadSubpackagePrefab(url, cb);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//region 加载远程音频
|
//region 加载远程音频
|
||||||
/** 加载远程资源*/
|
/** 加载远程资源*/
|
||||||
@@ -302,10 +362,10 @@ export default class ResManager {
|
|||||||
assetManager.loadRemote<AudioClip>(url, (err, res: AudioClip) => {
|
assetManager.loadRemote<AudioClip>(url, (err, res: AudioClip) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
cb && cb(res);
|
cb && cb(res);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 加载远程资源*/
|
/** 加载远程资源*/
|
||||||
@@ -333,7 +393,7 @@ export default class ResManager {
|
|||||||
changeRemoteSpriteFrame(spt: Sprite, url: string, cb: Function = null) {
|
changeRemoteSpriteFrame(spt: Sprite, url: string, cb: Function = null) {
|
||||||
if (!spt || !url) return;
|
if (!spt || !url) return;
|
||||||
// 临时加了一个字段,用来保存当前加载的资源路径
|
// 临时加了一个字段,用来保存当前加载的资源路径
|
||||||
let spttemp:any = spt;
|
let spttemp: any = spt;
|
||||||
// 在异步回调时判断这个组件是不是还在加载同一个 url,避免多次调用时产生覆盖冲突
|
// 在异步回调时判断这个组件是不是还在加载同一个 url,避免多次调用时产生覆盖冲突
|
||||||
spttemp.frameUrl = url;
|
spttemp.frameUrl = url;
|
||||||
// 加载
|
// 加载
|
||||||
@@ -341,7 +401,7 @@ export default class ResManager {
|
|||||||
console.log("changeRemoteSpriteFrame方法加载远程图片: ", url);
|
console.log("changeRemoteSpriteFrame方法加载远程图片: ", url);
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
if (!spt.isValid) {
|
if (!spt.isValid) {
|
||||||
return;
|
return;
|
||||||
@@ -355,7 +415,7 @@ export default class ResManager {
|
|||||||
spriteFrame.texture = texture;
|
spriteFrame.texture = texture;
|
||||||
spt.spriteFrame = spriteFrame;
|
spt.spriteFrame = spriteFrame;
|
||||||
cb && cb(res);
|
cb && cb(res);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 加载远程视频 */
|
/** 加载远程视频 */
|
||||||
@@ -390,24 +450,24 @@ export default class ResManager {
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/** 加载resources里的PB path:不带后缀*/
|
/** 加载resources里的PB path:不带后缀*/
|
||||||
private loadResourcePrefab(path: string, cb) {
|
public loadResourcePrefab(path: string, cb) {
|
||||||
resources.load(path, Prefab, (err, res: Prefab) => {
|
resources.load(path, Prefab, (err, res: Prefab) => {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
cb && cb(res);
|
cb && cb(res);
|
||||||
} else {
|
} else {
|
||||||
// loader.rlease(path);
|
// loader.rlease(path);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
/** 加载resources里的图片*/
|
/** 加载resources里的图片*/
|
||||||
private loadResourceRes(path: string, cb) {
|
private loadResourceRes(path: string, cb) {
|
||||||
resources.load(path, ImageAsset, (err, res: ImageAsset) => {
|
resources.load(path, ImageAsset, (err, res: ImageAsset) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
cb && cb(res);
|
cb && cb(res);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
/** 加载resources里图集里的图片*/
|
/** 加载resources里图集里的图片*/
|
||||||
// 加载 SpriteAtlas(图集),并且获取其中的一个 SpriteFrame
|
// 加载 SpriteAtlas(图集),并且获取其中的一个 SpriteFrame
|
||||||
@@ -425,10 +485,13 @@ export default class ResManager {
|
|||||||
/** 改变图片--resources里sprite-frame类型的图片*/
|
/** 改变图片--resources里sprite-frame类型的图片*/
|
||||||
changeResourceSpriteFrame(spt: Sprite, path: string, cb: Function = null) {
|
changeResourceSpriteFrame(spt: Sprite, path: string, cb: Function = null) {
|
||||||
if (!spt || !path) return;
|
if (!spt || !path) return;
|
||||||
resources.load(path + "/spriteFrame", SpriteFrame, (err, res: SpriteFrame) => {
|
resources.load(
|
||||||
|
path + "/spriteFrame",
|
||||||
|
SpriteFrame,
|
||||||
|
(err, res: SpriteFrame) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
if (!spt.isValid) {
|
if (!spt.isValid) {
|
||||||
return;
|
return;
|
||||||
@@ -436,7 +499,8 @@ export default class ResManager {
|
|||||||
|
|
||||||
spt.spriteFrame = res;
|
spt.spriteFrame = res;
|
||||||
cb && cb(res);
|
cb && cb(res);
|
||||||
})
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
/** 改变图片--resources里texture类型的图片*/
|
/** 改变图片--resources里texture类型的图片*/
|
||||||
changeResourceTexture(spt: Sprite, path: string, cb: Function = null) {
|
changeResourceTexture(spt: Sprite, path: string, cb: Function = null) {
|
||||||
@@ -444,78 +508,79 @@ export default class ResManager {
|
|||||||
resources.load(path + "/texture", Texture2D, (err, res: Texture2D) => {
|
resources.load(path + "/texture", Texture2D, (err, res: Texture2D) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
if (!spt.isValid) {
|
if (!spt.isValid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let spriteFrame = new SpriteFrame()
|
let spriteFrame = new SpriteFrame();
|
||||||
spriteFrame.texture = res
|
spriteFrame.texture = res;
|
||||||
spt.spriteFrame = spriteFrame;
|
spt.spriteFrame = spriteFrame;
|
||||||
cb && cb(res);
|
cb && cb(res);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//设置图片置灰
|
//设置图片置灰
|
||||||
SetGray(spt: Sprite, isGray: boolean) {
|
SetGray(spt: Sprite, isGray: boolean) {
|
||||||
//cc.assetManager.builtins.getBuiltin("material", "builtin-" + name)
|
//cc.assetManager.builtins.getBuiltin("material", "builtin-" + name)
|
||||||
if (isGray) {
|
if (isGray) {
|
||||||
let bundle = assetManager.getBundle("Materials");
|
let bundle = assetManager.getBundle("Materials");
|
||||||
if (bundle){
|
if (bundle) {
|
||||||
bundle.load("ui_sprite_gray", Material, (err, res: Material) => {
|
bundle.load("ui_sprite_gray", Material, (err, res: Material) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
// spt.setSharedMaterial(res, 0)
|
// spt.setSharedMaterial(res, 0)
|
||||||
spt.customMaterial = res
|
spt.customMaterial = res;
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
assetManager.loadBundle("Materials", (err: Error, _bundle: AssetManager.Bundle) => {
|
assetManager.loadBundle(
|
||||||
|
"Materials",
|
||||||
|
(err: Error, _bundle: AssetManager.Bundle) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
this.SetGray(spt, isGray);
|
this.SetGray(spt, isGray);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// spt.setSharedMaterial(null, 0)
|
// spt.setSharedMaterial(null, 0)
|
||||||
spt.customMaterial = null
|
spt.customMaterial = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**设置图片模糊*/
|
/**设置图片模糊*/
|
||||||
SetBlur(spt: Sprite, isBule: boolean) {
|
SetBlur(spt: Sprite, isBule: boolean) {
|
||||||
if (isBule) {
|
if (isBule) {
|
||||||
let bundle = assetManager.getBundle("Materials");
|
let bundle = assetManager.getBundle("Materials");
|
||||||
if (bundle){
|
if (bundle) {
|
||||||
bundle.load("mohu", Material, (err, res: Material) => {
|
bundle.load("mohu", Material, (err, res: Material) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
// spt.setSharedMaterial(res, 0)
|
// spt.setSharedMaterial(res, 0)
|
||||||
spt.customMaterial = res
|
spt.customMaterial = res;
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
assetManager.loadBundle("Materials", (err: Error, _bundle: AssetManager.Bundle) => {
|
assetManager.loadBundle(
|
||||||
|
"Materials",
|
||||||
|
(err: Error, _bundle: AssetManager.Bundle) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
this.SetBlur(spt, isBule);
|
this.SetBlur(spt, isBule);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// spt.setSharedMaterial(null, 0)
|
// spt.setSharedMaterial(null, 0)
|
||||||
spt.customMaterial = null
|
spt.customMaterial = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
import { _decorator, Camera, Component, Node } from "cc";
|
|
||||||
import GameRootUI from "../Main/Common/GameRootUI";
|
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
|
||||||
|
|
||||||
//游戏场景
|
|
||||||
@ccclass('GameScene')
|
|
||||||
export class GameScene extends Component {
|
|
||||||
|
|
||||||
@property(Node)
|
|
||||||
UIRoot: Node = null
|
|
||||||
@property(Node)
|
|
||||||
UILayerMod: Node = null
|
|
||||||
@property(Camera)
|
|
||||||
MainCamera: Camera = null
|
|
||||||
|
|
||||||
start() {
|
|
||||||
//每个场景必须添加的
|
|
||||||
let gameRootUI = this.node.getComponent(GameRootUI)
|
|
||||||
if (!gameRootUI){
|
|
||||||
gameRootUI = this.node.addComponent(GameRootUI)
|
|
||||||
gameRootUI.InitByCreate(this.UIRoot, this.UILayerMod, "UI/GameUI/Game_UI");
|
|
||||||
}
|
|
||||||
GameRootUI.MainCamera = this.MainCamera
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.24",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "d9d41102-bfd6-4256-8356-bfca87f844ec",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -14,7 +14,9 @@ export class MainScene extends Component {
|
|||||||
@property(Camera)
|
@property(Camera)
|
||||||
MainCamera: Camera = null;
|
MainCamera: Camera = null;
|
||||||
|
|
||||||
start() {
|
start() {}
|
||||||
|
|
||||||
|
init() {
|
||||||
//每个场景必须添加的
|
//每个场景必须添加的
|
||||||
let gameRootUI = this.node.getComponent(GameRootUI);
|
let gameRootUI = this.node.getComponent(GameRootUI);
|
||||||
if (!gameRootUI) {
|
if (!gameRootUI) {
|
||||||
|
|||||||
@@ -1,104 +0,0 @@
|
|||||||
import { _decorator, Button, Component, Node } from "cc";
|
|
||||||
import li_BaseView from "../../Main/Common/li_BaseView";
|
|
||||||
import Utils from "../../Main/Common/Utils";
|
|
||||||
import { GButton } from "../../Main/Common/GButton";
|
|
||||||
import ResManager from "../../Main/Manager/ResManager";
|
|
||||||
import { DataManager, DataId } from "../../chat18x/data/DataManager";
|
|
||||||
import { LoginData } from "../../chat18x/data/LoginData";
|
|
||||||
import { PlayerData } from "../../chat18x/data/PlayerData";
|
|
||||||
import { AccountData } from "../../chat18x/data/AccountData";
|
|
||||||
import { WalletData } from "../../chat18x/data/WalletData";
|
|
||||||
import { GlobalData } from "../../chat18x/data/GlobalData";
|
|
||||||
import { EnvData } from "../../chat18x/data/EnvData";
|
|
||||||
import DeviceIdService from "db://assets/Scripts/chat18x/foundation/identity/DeviceIdService";
|
|
||||||
import MachineInfoService from "db://assets/Scripts/chat18x/foundation/identity/MachineInfoService";
|
|
||||||
import { AuthService } from "db://assets/Scripts/chat18x/network/services/AuthService";
|
|
||||||
import { PlayerDataService } from "db://assets/Scripts/chat18x/network/services/PlayerDataService";
|
|
||||||
import { CommonService } from "db://assets/Scripts/chat18x/network/services/CommonService";
|
|
||||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
|
||||||
const { ccclass, property } = _decorator;
|
|
||||||
|
|
||||||
@ccclass("LoginUI")
|
|
||||||
export class LoginUI extends li_BaseView {
|
|
||||||
private _nodeTab: any = {};
|
|
||||||
private loginFinish = false;
|
|
||||||
|
|
||||||
loginBtn: Node;
|
|
||||||
protected start(): void {
|
|
||||||
Utils.parseNode(this.node, this._nodeTab);
|
|
||||||
|
|
||||||
this.loginBtn = this._nodeTab.btnLogin;
|
|
||||||
|
|
||||||
GButton.BandClick(this.loginBtn, this.onLogin, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
update(deltaTime: number) {
|
|
||||||
if (this.loginFinish) {
|
|
||||||
this.loginFinish = false;
|
|
||||||
this.enterGame();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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() {
|
|
||||||
ResManager.I.goMainScene();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "4.0.24",
|
|
||||||
"importer": "typescript",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "0fa6dc01-de0d-4847-ae6c-624111814d80",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
Component,
|
Component,
|
||||||
ImageAsset,
|
ImageAsset,
|
||||||
|
instantiate,
|
||||||
JsonAsset,
|
JsonAsset,
|
||||||
Label,
|
Label,
|
||||||
Material,
|
Material,
|
||||||
@@ -25,22 +26,48 @@ import Utils from "../../Main/Common/Utils";
|
|||||||
import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
|
import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
|
||||||
import { promptItem } from "../Item/promptItem";
|
import { promptItem } from "../Item/promptItem";
|
||||||
import LanguageUtils, { LanguageType } from "../../Main/Common/LanguageUtils";
|
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 { ConfigManager } from "../../chat18x/manager/ConfigManager";
|
||||||
import { AppConfig } from "db://assets/Scripts/chat18x/config/env/appConfig";
|
import { AppConfig } from "db://assets/Scripts/chat18x/config/env/appConfig";
|
||||||
import DeviceIdService from "db://assets/Scripts/chat18x/foundation/identity/DeviceIdService";
|
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;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@ccclass("PreloadUI")
|
@ccclass("PreloadUI")
|
||||||
export class PreloadUI extends Component {
|
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 jinduBar: Node = null;
|
||||||
private jinduFilled: Sprite = null;
|
private jinduFilled: Sprite = null;
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
//Utils.addInnerEL(InnerMsgCode.UI_ShowPrompt, this, this.resiveShowPrompt)
|
//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.jinduBar = this.node.getChildByName("jinduBar");
|
||||||
this.jinduFilled = this.jinduBar
|
this.jinduFilled = this.jinduBar
|
||||||
@@ -48,8 +75,8 @@ export class PreloadUI extends Component {
|
|||||||
.getComponent(Sprite);
|
.getComponent(Sprite);
|
||||||
|
|
||||||
//适配背景图
|
//适配背景图
|
||||||
let BG = this.node.getChildByName("BG");
|
//let BG = this.node.getChildByName("BG");
|
||||||
Utils.adjustBgPixelRatio(BG, 1);
|
//Utils.adjustBgPixelRatio(BG, 1);
|
||||||
|
|
||||||
this.jinduFilled.fillRange = 0;
|
this.jinduFilled.fillRange = 0;
|
||||||
|
|
||||||
@@ -77,9 +104,16 @@ export class PreloadUI extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update(deltaTime: number) {
|
update(deltaTime: number) {
|
||||||
if (this.preloadFinish) {
|
if (!this.preloadFinish) {
|
||||||
|
return;
|
||||||
|
//this.goToLoginScene();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.loginFinish) {
|
||||||
|
this.loginFinish = false;
|
||||||
this.preloadFinish = false;
|
this.preloadFinish = false;
|
||||||
this.goToLoginScene();
|
|
||||||
|
this.enterGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,25 +134,6 @@ export class PreloadUI extends Component {
|
|||||||
{ path: "ChatPanel", bundleName: "Chat18x", ftype: Prefab },
|
{ path: "ChatPanel", bundleName: "Chat18x", ftype: Prefab },
|
||||||
{ path: "GirlDetailPanel", bundleName: "Chat18x", ftype: Prefab },
|
{ path: "GirlDetailPanel", bundleName: "Chat18x", ftype: Prefab },
|
||||||
{ path: "GirlListPanel", 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 },
|
{ path: "tblanguage", bundleName: "DataTable", ftype: BufferAsset },
|
||||||
];
|
];
|
||||||
let num_prefab = 0; //已加载数量
|
let num_prefab = 0; //已加载数量
|
||||||
@@ -145,7 +160,7 @@ export class PreloadUI extends Component {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (num_succeed >= num_prefab) {
|
if (num_succeed >= num_prefab) {
|
||||||
this.loadDataTable();
|
this.startloginProcess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -153,29 +168,10 @@ export class PreloadUI extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//加载配置表
|
//加载配置表
|
||||||
loadDataTable() {
|
startloginProcess() {
|
||||||
let dataArr = [
|
this.jinduBar.active = false;
|
||||||
//"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;
|
this.preloadFinish = true;
|
||||||
}
|
this.loginBtn.active = true;
|
||||||
};
|
|
||||||
preloadFunc();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//显示加载进度
|
//显示加载进度
|
||||||
@@ -184,8 +180,73 @@ export class PreloadUI extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 跳转到登录场景
|
// 跳转到登录场景
|
||||||
private goToLoginScene() {
|
// private goToLoginScene() {
|
||||||
this.jinduBar.active = false;
|
// this.jinduBar.active = false;
|
||||||
ResManager.I.goCustomScene("LoginScene");
|
// 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,10 +70,13 @@ export class GirlListPopupPanel extends li_BaseView {
|
|||||||
this.girlName.string = LanguageUtils.getText(
|
this.girlName.string = LanguageUtils.getText(
|
||||||
girlData.getGrilName(this.category.toString(), this.girlId)
|
girlData.getGrilName(this.category.toString(), this.girlId)
|
||||||
);
|
);
|
||||||
this.girlTag.string = LanguageUtils.getText(
|
const tagContent = girlData.getGrilTagKey(
|
||||||
girlData.getGrilTagKey(this.category.toString(), this.girlId)
|
this.category.toString(),
|
||||||
|
this.girlId
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.girlTag.string = LanguageUtils.getText(tagContent.replace("|", "\n"));
|
||||||
|
|
||||||
const path = girlData.getGrilAvatar(this.category.toString(), this.girlId);
|
const path = girlData.getGrilAvatar(this.category.toString(), this.girlId);
|
||||||
this.refreshCoinNum();
|
this.refreshCoinNum();
|
||||||
//console.log(path);
|
//console.log(path);
|
||||||
|
|||||||
@@ -1624,8 +1624,8 @@
|
|||||||
},
|
},
|
||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 188.31899999999996,
|
"x": 200.56799999999996,
|
||||||
"y": 108.42700000000002,
|
"y": 109.65699999999993,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
@@ -1665,8 +1665,8 @@
|
|||||||
},
|
},
|
||||||
"_contentSize": {
|
"_contentSize": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
"width": 414.234375,
|
"width": 389.736375,
|
||||||
"height": 83.6
|
"height": 150.212
|
||||||
},
|
},
|
||||||
"_anchorPoint": {
|
"_anchorPoint": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
@@ -1766,7 +1766,7 @@
|
|||||||
"_target": null,
|
"_target": null,
|
||||||
"_left": 553.9668125000001,
|
"_left": 553.9668125000001,
|
||||||
"_right": 37.06381250000004,
|
"_right": 37.06381250000004,
|
||||||
"_top": 60.272999999999996,
|
"_top": 25.737000000000087,
|
||||||
"_bottom": 0,
|
"_bottom": 0,
|
||||||
"_horizontalCenter": 0,
|
"_horizontalCenter": 0,
|
||||||
"_verticalCenter": 0,
|
"_verticalCenter": 0,
|
||||||
@@ -3745,6 +3745,7 @@
|
|||||||
"__id__": 0
|
"__id__": 0
|
||||||
},
|
},
|
||||||
"fileId": "a56vp8DEdDloy+JjDTTm7J",
|
"fileId": "a56vp8DEdDloy+JjDTTm7J",
|
||||||
|
"instance": null,
|
||||||
"targetOverrides": null
|
"targetOverrides": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
Reference in New Issue
Block a user