This commit is contained in:
2025-07-17 17:18:21 +08:00
commit 1ffc1b5cf0
5309 changed files with 1150310 additions and 0 deletions
@@ -0,0 +1,71 @@
import { _decorator, Node } from "cc";
import ResManager from "../Main/Manager/ResManager";
import GameRootUI from "../Main/Common/GameRootUI";
import { CommonConfig } from "../Main/Config/CommonConfig";
import { promptItem } from "./Item/promptItem";
import { ConfirmDialog } from "./Item/ConfirmDialog";
import { CommAdDialog } from "./Item/CommAdDialog";
const { ccclass, property } = _decorator;
//项目管理器
@ccclass('SubManager')
export default class SubManager {
private static _I: SubManager = null;
public static get I(): SubManager {
if (!SubManager._I) {
SubManager._I = new SubManager();
SubManager._I.init();
}
return SubManager._I;
}
private init(){
}
//飘字提示----------------------------------------------------------------------------
public static ShowPrompt(text: string) {
if (!GameRootUI.I) {
console.warn("GameRootUI还未初始化", text);
return
}
ResManager.I.loadSubpackagePrefab("item/promptItem", (n_node: Node)=>{
GameRootUI.I.AddUIToLayer(n_node, CommonConfig.UILayerGroup.Layer_tips)
let pItem = n_node.getComponent(promptItem)
pItem.setLabel(text)
})
}
//显示确定框----------------------------------------------------------------------------
/**通用确认框 { content: string, strYes?: string, strNo?: string, yesCallback?: Function, noCallback?: Function, closeCallback?: Function } */
public static ShowConfirm(param:any) {
if (!GameRootUI.I) {
console.warn("GameRootUI还未初始化", param);
return
}
ResManager.I.loadSubpackagePrefab("item/ConfirmDialog", (n_node: Node)=>{
GameRootUI.I.AddUIToLayer(n_node, CommonConfig.UILayerGroup.Layer_tips)
let pItem = n_node.getComponent(ConfirmDialog)
pItem.setParam(param)
})
}
//显示通用广告框----------------------------------------------------------------------------
/**通用广告框 { content: string, strAd?: string, strLeft?: string, adCallback?: Function, leftCallback?: Function, closeCallback?: Function } */
public static ShowCommonAdDialog(param:any) {
if (!GameRootUI.I) {
console.warn("GameRootUI还未初始化", param);
return
}
ResManager.I.loadSubpackagePrefab("item/CommAdDialog", (n_node: Node)=>{
GameRootUI.I.AddUIToLayer(n_node, CommonConfig.UILayerGroup.Layer_tips)
let pItem = n_node.getComponent(CommAdDialog)
pItem.setParam(param)
})
}
}
@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "7f5d94a8-3fd8-4940-b9b4-0fc4544a6984",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "0a758804-5dd2-484d-913d-f93831bf806c",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "0a758804-5dd2-484d-913d-f93831bf806c@6c48a",
"displayName": "dl_bg_01",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "0a758804-5dd2-484d-913d-f93831bf806c",
"isUuid": true,
"visible": false,
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "0a758804-5dd2-484d-913d-f93831bf806c@f9941",
"displayName": "dl_bg_01",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 720,
"height": 1280,
"rawWidth": 720,
"rawHeight": 1280,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-360,
-640,
0,
360,
-640,
0,
-360,
640,
0,
360,
640,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
1280,
720,
1280,
0,
0,
720,
0
],
"nuv": [
0,
0,
1,
0,
0,
1,
1,
1
],
"minPos": [
-360,
-640,
0
],
"maxPos": [
360,
640,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "0a758804-5dd2-484d-913d-f93831bf806c@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": false,
"fixAlphaTransparencyArtifacts": false,
"redirect": "0a758804-5dd2-484d-913d-f93831bf806c@6c48a"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 410 KiB

@@ -0,0 +1,282 @@
import { _decorator, sys } from "cc";
import { SDKManager } from "../Channel/SDKManager";
import GlobalValue from "./GlobalValue";
import li_EventManager from "./li_EventManager";
import Utils from "./Utils";
import { InnerMsgCode } from "../Config/InnerMsgCode";
// import { EventManager, EventNameEnum } from "../manager/eventManager";
// import GlobalValue from "../manager/GlobalValue";
// import { DataManager } from "../manager/dataManager";
// import { SDKManager } from "../manager/sdkManager";
// import GlobalValue from "../global/GlobalValue";
const { ccclass, property } = _decorator;
/**
* http通讯
*/
@ccclass
export default class HttpUnit {
// static readonly ServerHttpHost = "https://bls.vip.hnhxzkj.com/";
static readonly ServerHttpHost = "https://xqmnyx.vip.hnhxzkj.com/api/";
static PlayerToken = ""; //登录时获取的token
static LoginState = 0; //登录状态 0未登录 1登录中 2已登录
static UserInfo:any = {}; //用户数据
static SerSetting:any = {}; //后台设置
//单例
private static I: HttpUnit;
public static get ins(): HttpUnit {
if (this.I == null) {
this.I = new HttpUnit();
}
return this.I;
}
public constructor() {
}
public jsonToQueryString(json: any) {
var str = '';
if (typeof json == "object") {
str = "?";
for (var k in json) {
if (str != "?") {
str += "&";
}
str += k + "=" + json[k];
}
}
return str;
}
private objectToFormData(obj: Object): FormData {
const formData = new FormData();
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
const value = obj[key];
if (Array.isArray(value)) {
for (const item of value) {
formData.append(key, item);
}
} else {
formData.append(key, value);
}
}
}
return formData;
}
private async quest(xhr: XMLHttpRequest, method: "GET" | "POST" | "PUT" = "GET", data: Object, formData: boolean = false) {
return new Promise((resolve, reason) => {
xhr.onreadystatechange = () => {
if (xhr.readyState == 4) {
if (xhr.status >= 200 && xhr.status < 300) {
// console.log("[Http] 返回", xhr.response);
resolve(JSON.parse(xhr.response));
} else {
reason(xhr.status)
}
}
};
xhr.onerror = (error) => {
console.error("http request onerror");
reason(error)
};
xhr.ontimeout = (e) => {
console.error("http request timeout");
reason(e)
}
//根据POST和GET方式,选择是否发送msg数据
if (formData) {
xhr.send(this.objectToFormData(data));
} else {
if (method == 'POST') {
xhr.send(JSON.stringify(data));
} else if (method == 'PUT') {
xhr.send(JSON.stringify(data));
} else {
xhr.send();
}
}
});
}
/**是否已登录成功 */
public static IsLogin(): boolean {
return HttpUnit.LoginState == 2;
}
//登录
private loginCB: Function = null;
public login(cb: Function = null) {
this.loginCB = cb;
SDKManager.login((_loginData) => {
console.log("SDK登录成功", _loginData)
SDKManager.getUserInfo((userInfo) => {
console.log("SDK获取用户信息成功", userInfo)
// let serparam = {
// platform: _loginData.platform,
// code: _loginData.code,
// user_info: {nickName:userInfo.nickName, avatarUrl:userInfo.avatarUrl}
// }
if (GlobalValue.IsTest) {
console.log("登录测试环境")
this.loginSer({platform:0, code:12345}, this.initData.bind(this))
} else {
if (_loginData.code == null) {
let uuid = sys.localStorage.getItem('uuid');
if (!uuid) {
uuid = Date.now(); //当前时间戳
sys.localStorage.setItem('uuid', uuid);
}
_loginData.code = uuid;
}
console.log("登录正式环境 loginData.code: ", _loginData.code)
this.loginSer({platform:1, code:_loginData.code}, this.initData.bind(this))
}
})
})
}
private initData(playerData) {
playerData = playerData || {};
this.loginCB && this.loginCB(playerData);
}
//登录服务器
private async loginSer(msg, cb: Function = null) {
let data: any = await HttpUnit.ins.api("login", msg, "POST", true);
console.log("login:", msg, data)
if (data.code == 1) {
HttpUnit.PlayerToken = data.data.token
HttpUnit.LoginState = 2
console.log("HttpUnit.PlayerToken:", HttpUnit.PlayerToken)
//获取玩家信息
// this.getUserInfo(cb);
// this.getCommSetting();
HttpUnit.UserInfo = data.data.user_info;
cb && cb(data.data.user_info);
}else{
console.log("登陆失败:"+ data.msg);
cb && cb(null);
}
}
//获取关卡列表数据
public async getLevelList(cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/levels", {}, "POST", true);
console.log("关卡数据:", data)
if (data.code == 1) {
cb && cb(data.data);
}else{
console.log("获取关卡数据失败:"+ data.msg);
cb && cb(null);
}
}
/**开始关卡*/
public async levelStart(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/start", msg, "POST", true);
console.log("开始关卡:", msg, data)
if (data.code == 1) {
cb && cb(data.data);
}else{
console.log("开始关卡失败:"+ data.msg);
cb && cb(null);
}
}
/**推进关卡*/
public async sendUserTalk(msg:any, cb: Function = null) {
let data: any = await HttpUnit.ins.api("game/propel", msg, "POST", true);
console.log("推进关卡:", msg, data)
if (data.code == 1) {
cb && cb(data.data);
}else{
console.log("推进关卡失败:"+ data.msg);
cb && cb(null);
}
}
public async api(path: string, data: any, method: "GET" | "POST" | "PUT" = "GET", bLock: boolean = false, isFormData: boolean = false) {
let url = HttpUnit.ServerHttpHost + path;
// console.log("[Http] 请求Url:",url, " 方式:", method, " Authorization:", GlobalValue.PlayerToken, " 数据:", JSON.stringify(data) );
bLock && this.lock();
var xhr = new XMLHttpRequest();
xhr.timeout = 10000;
// xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
// if (cc.sys.isNative) {
// xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
// }
// xhr.setRequestHeader('authorization', Config.TOKEN);
//发送数据
if (method == 'GET') {
url = url + encodeURI(this.jsonToQueryString(data));
xhr.open(method, url, true);
if (sys.isNative) {
xhr.setRequestHeader("Accept-Encoding", "gzip,deflate");
xhr.setRequestHeader("content-type", "text/html;charset=utf-8");
}
} else {
xhr.open(method, url, true);
xhr.setRequestHeader("Content-type", "application/json");
}
xhr.setRequestHeader('Authorization', "Bearer " + HttpUnit.PlayerToken);
let self = this;
return new Promise((resolve, reason) => {
self.quest(xhr, method, data, isFormData).then(value => {
bLock && self.unlock();
resolve(value);
}).catch(err => {
bLock && self.unlock();
resolve(null);
});
});
}
/**
* 发送请求
* @param url 接口地址
* @param data 消息字符串 (json格式)
* @param method 请求方式
* @param bLock 是否锁定屏幕
* @param formData 是否formData
* @returns
*/
public async send(url: string, data: any, method: "GET" | "POST" | "PUT" = "GET", bLock: boolean = false, formData: boolean = false) {
// console.log("[Http] 请求Url:",url, " 方式:", method, " 数据:", data);
bLock && this.lock();
var xhr = new XMLHttpRequest();
xhr.timeout = 10000;
if (method == 'GET') {
url = url + encodeURI(this.jsonToQueryString(data));
xhr.open(method, url, true);
if (sys.isNative) {
xhr.setRequestHeader("Accept-Encoding", "gzip,deflate");
xhr.setRequestHeader("content-type", "text/html;charset=utf-8");
}
} else {
xhr.open(method, url, true);
xhr.setRequestHeader("Content-type", "application/json");
}
let self = this;
return new Promise((resolve, reason) => {
self.quest(xhr, method, data, formData).then(value => {
bLock && self.unlock();
resolve(value);
}).catch(err => {
bLock && self.unlock();
resolve(null);
});
});
}
/**解锁屏幕 */
private unlock() {
// LockScreenUI.ins.unShowloading();
// Config.loading.hide2();
}
/**锁屏 */
private lock() {
// Config.loading.show2();
// LockScreenUI.ins.Showloading('网络加载中请稍后...');
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "9add7165-7073-43fb-946a-e68243da7b5b",
"files": [
".jpg",
".json"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "9add7165-7073-43fb-946a-e68243da7b5b@6c48a",
"displayName": "jinhyun_stage_bg",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "9add7165-7073-43fb-946a-e68243da7b5b",
"isUuid": true,
"visible": false,
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "9add7165-7073-43fb-946a-e68243da7b5b@f9941",
"displayName": "jinhyun_stage_bg",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 996,
"height": 1280,
"rawWidth": 996,
"rawHeight": 1280,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-498,
-640,
0,
498,
-640,
0,
-498,
640,
0,
498,
640,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
1280,
996,
1280,
0,
0,
996,
0
],
"nuv": [
0,
0,
1,
0,
0,
1,
1,
1
],
"minPos": [
-498,
-640,
0
],
"maxPos": [
498,
640,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "9add7165-7073-43fb-946a-e68243da7b5b@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": false,
"fixAlphaTransparencyArtifacts": false,
"redirect": "9add7165-7073-43fb-946a-e68243da7b5b@6c48a"
}
}
@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "732a8512-6223-483c-aec8-822bae14e1f6",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "732a8512-6223-483c-aec8-822bae14e1f6@6c48a",
"displayName": "mochiduki_aoi_laugh",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "732a8512-6223-483c-aec8-822bae14e1f6",
"isUuid": true,
"visible": false,
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "732a8512-6223-483c-aec8-822bae14e1f6@f9941",
"displayName": "mochiduki_aoi_laugh",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -13.5,
"offsetY": -5.5,
"trimX": 76,
"trimY": 11,
"width": 746,
"height": 1178,
"rawWidth": 925,
"rawHeight": 1189,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-373,
-589,
0,
373,
-589,
0,
-373,
589,
0,
373,
589,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
76,
1178,
822,
1178,
76,
0,
822,
0
],
"nuv": [
0.08216216216216216,
0,
0.8886486486486487,
0,
0.08216216216216216,
0.990748528174937,
0.8886486486486487,
0.990748528174937
],
"minPos": [
-373,
-589,
0
],
"maxPos": [
373,
589,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "732a8512-6223-483c-aec8-822bae14e1f6@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": true,
"fixAlphaTransparencyArtifacts": false,
"redirect": "732a8512-6223-483c-aec8-822bae14e1f6@6c48a"
}
}
@@ -0,0 +1,134 @@
{
"ver": "1.0.27",
"importer": "image",
"imported": true,
"uuid": "3fc5949d-c04d-4d5e-9d66-7f57dd10660a",
"files": [
".jpg",
".json"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "3fc5949d-c04d-4d5e-9d66-7f57dd10660a@6c48a",
"displayName": "munuonuo_stage_bg",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "3fc5949d-c04d-4d5e-9d66-7f57dd10660a",
"isUuid": true,
"visible": false,
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "3fc5949d-c04d-4d5e-9d66-7f57dd10660a@f9941",
"displayName": "munuonuo_stage_bg",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 996,
"height": 1280,
"rawWidth": 996,
"rawHeight": 1280,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-498,
-640,
0,
498,
-640,
0,
-498,
640,
0,
498,
640,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
1280,
996,
1280,
0,
0,
996,
0
],
"nuv": [
0,
0,
1,
0,
0,
1,
1,
1
],
"minPos": [
-498,
-640,
0
],
"maxPos": [
498,
640,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "3fc5949d-c04d-4d5e-9d66-7f57dd10660a@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": false,
"fixAlphaTransparencyArtifacts": false,
"redirect": "3fc5949d-c04d-4d5e-9d66-7f57dd10660a@6c48a"
}
}