feat: add builder configuration file

feat: add cocos-service configuration file
feat: add device configuration file
feat: add engine configuration file
feat: add information configuration file
feat: add program configuration file
feat: add project configuration file
feat: add TypeScript configuration file
This commit is contained in:
ZhouXiao
2025-12-22 11:42:51 +08:00
parent 66cfa73345
commit 487c68994d
202 changed files with 57615 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
import { director } from "cc";
export class EventManager {
/**添加一个全局监听
* @param eventName 事件名
* @param event 事件Function
* @param target 添加监听事件的脚本this
*/
public static addListener(eventName: string, event: any, target: any) {
director.on(eventName, event, target);
};
/**
* 移除一个监听事件
* @param {*} eventName 事件名
* @param {*} event 事件Function
* @param {*} target 添加监听事件的Node
*/
public static removeListener(eventName: string, event: any, target: any) {
director.off(eventName, event, target);
};
/**
* 派发一个事件 令所有监听此事件的Node执行事件
* @param {*} eventName 事件名
* @param {*} arg1 传递的参数1
* @param {*} arg2 传递的参数2
* @param {*} arg3 传递的参数3
* @param {*} arg4 传递的参数4
* @param {*} arg5 传递的参数5
*/
public static dispatchEvent(eventName: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any) {
director.emit(eventName, arg1, arg2, arg3, arg4, arg5);
};
/**
* 移除 Node 上的所有事件
* @param {*} target 需要移除事件的Node
*/
public static removeListenerForTarget(target: any) {
director.targetOff(target);
};
};
export enum EventData {
/** 开始游戏 */
START_GAME = "START_GAME",
/** 复活 */
REIVE_GAME = "REIVE_GAME",
/**加金币 */
AddCoin = "AddCoin",
/**加生命 */
AddLife = "AddLife",
/** 预制体分帧加载开始 */
PREFAB_LOAD_START = "PREFAB_LOAD_START",
/** 预制体分帧加载进度更新 */
PREFAB_LOAD_PROGRESS = "PREFAB_LOAD_PROGRESS",
/** 预制体分帧加载完成 */
PREFAB_LOAD_COMPLETE = "PREFAB_LOAD_COMPLETE",
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "1dddfca2-37e3-4421-9802-d1ed36cd6abf",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,123 @@
import { loader } from "cc";
import { weiSan } from "../common/weiSanTools";
import { PlatformManager, releaseType } from "./PlatformManager";
/** 网络相关 管理类 */
export class NetworkManager {
/** 游戏ID */
public static gameHttpId: number = 0;
/** 更多游戏 链接 */
public static moreGameUrl: string;
/** 初始化 网络相关 */
public static initNetwork() {
if (PlatformManager.releaseType == releaseType.h5_common || PlatformManager.releaseType == releaseType.h5_weiSan) {
this.initNet_H5()
} else if (PlatformManager.releaseType == releaseType.test_TEST) {
this.moreGameUrl = "http://m.wesane.com/";
weiSan.log("发送:---游戏加载成功!");
}
}
/** 初始化 H5 网络请求 */
private static initNet_H5() {
this.getHttpGameId();
this.sendLoadGame();
}
/** 通过url 获取gameID */
private static getHttpGameId() {
var url = document.URL;
var game_id = 0;
if (PlatformManager.releaseType == releaseType.h5_common) {
var httpUrl = window.location.href;
var httpHead = httpUrl.substring(0, httpUrl.lastIndexOf("//") + 2);
var httpMid = window.location.host;
var httpAll = httpHead + httpMid + "/Service/Share/index";
var url = document.URL;
var index = url.lastIndexOf("\/");
var str = url.substring(0, index);
var index = str.lastIndexOf("/");
game_id = parseInt(str.substring(index + 1, str.length));
this.gameHttpId = game_id;
// console.log("gameIdNew", game_id);
var endHttp = httpUrl.substring(httpUrl.lastIndexOf("//") + 4, httpUrl.lastIndexOf("com") + 3);
var curWebMoreGame = httpHead + httpMid
// console.log("moreGame", curWebMoreGame);
var urlIndex = curWebMoreGame.lastIndexOf('//')
var urlG = curWebMoreGame.substring(urlIndex + 2, curWebMoreGame.indexOf("//") + 4);
if (urlG == 'g.') {
var newMoreUrl = curWebMoreGame.replace(urlG, "");
// console.log("chagee", newMoreUrl);
curWebMoreGame = newMoreUrl;
} else {
console.log("noChange");
}
this.moreGameUrl = curWebMoreGame;
msgHttpUrl.gamePv_commonH5 = httpHead + httpMid + "/Service/GamePv/index";
msgHttpUrl.score_commonH5 = httpHead + httpMid + "/Service/Score/index";
} else {
var para = url.substring(url.lastIndexOf("/game/") + 1, url.length);
var arr = para.split("/");
if (arr.length >= 2) {
game_id = parseInt(arr[1]);
}
this.moreGameUrl = "http://m.wesane.com/"; // this.httpHead + this.endHttp;
}
this.gameHttpId = game_id;
weiSan.log("gameId:", game_id , this.moreGameUrl );
};
/** 向服务器 发送 加载游戏成功 */
private static sendLoadGame() {
if (PlatformManager.releaseType == releaseType.h5_weiSan) {
this.sendMsg(msgHttpUrl.gamePv_weiSanH5, "gameID=" + this.gameHttpId.toString(), this.loadGameBack);
} else if (PlatformManager.releaseType == releaseType.h5_common) {
this.sendMsg(msgHttpUrl.gamePv_commonH5, "gameId=" + this.gameHttpId.toString(), this.loadGameBack);
}
};
/** 发送加载游戏成功回调 */
private static loadGameBack() {
weiSan.log("gamePv加载成功");
}
/** 向服务器 提交分数 */
public static sendGameScore(Score: number, gameType: any) {
if (PlatformManager.releaseType == releaseType.h5_weiSan) {
this.sendMsg(msgHttpUrl.score_weiSanH5, "gameScore=" + Score + "&gameId=" + this.gameHttpId + "&gameType=" + gameType, this.sendScoreBack);
} else if (PlatformManager.releaseType == releaseType.h5_common) {
this.sendMsg(msgHttpUrl.score_commonH5, "gameScore=" + Score + "&gameId=" + this.gameHttpId + "&gameType=" + gameType, this.sendScoreBack);
}
};
/** 向服务器 提交分数回调 */
private static sendScoreBack(Event: any) {
weiSan.log("---提交分数成功!" + Event);
if (Event.currentTarget.response != null && Event.currentTarget.response != "") {
var endShowText = JSON.parse(Event.currentTarget.response);
// weiSan.log("sendScoreBack:",endShowText.content);
}
}
/** 向服务器 POST请求 http */
public static sendMsg(url: string, postData: any, callback?: any) {
// var request = loader.getXMLHttpRequest();
var request = new XMLHttpRequest();
request.onreadystatechange = callback;
request.open("POST", url);
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
request.send(postData);
};
}
window.NetworkManager = NetworkManager;
/** 网络 消息号数据 */
export var msgHttpUrl = {
/** 微伞游戏H5 加载成功 */
gamePv_weiSanH5: "http://www.wesane.com/admin.php/Activityshow/gamelogo",
/** 微伞游戏H5 提交分数 */
score_weiSanH5: "http://www.wesane.com/admin.php/Gamescore/saveGamescore",
/** 通用H5游戏 加载成功 */
gamePv_commonH5: "",
/** 通用H5游戏 提交分数 */
score_commonH5: "",
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "700c5a3f-bf5b-4302-96ab-e576d03dccc1",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,115 @@
import { Enum, game, view , screen, sys } from "cc";
import { AdManager } from "../ads/AdManager";
import { Tools } from "../common/Tools";
import { NetworkManager } from "./NetworkManager";
/** 游戏管理类 */
export class PlatformManager {
/** 发布平台类型 */
public static releaseType: number;
/** 发布类型 h5 安卓 IOS 小程序 */
public static osType:number;
/** 存储本地数据 key的前标 */
public static storageKey: string = "demo_Game_";
/** 游戏是否 加载成功 */
public static loadGameBool:boolean = false;
/** 初始化平台 相关 */
public static initPlatform(){
if(this.loadGameBool) { return; } //第一次加载成功后 不加载第二次
this.initOsType();
NetworkManager.initNetwork();
if(PlatformManager.releaseType == releaseType.h5_weiSan || PlatformManager.releaseType == releaseType.h5_common){
if(NetworkManager.gameHttpId.toString() == "NaN"){
if(PlatformManager.releaseType == releaseType.h5_weiSan){
window.location.href = NetworkManager.moreGameUrl;
}else{
window.location.href = "http://www.vsane.com/";
}
}
loadInScene();
}
if(PlatformManager.releaseType != releaseType.applet_ziJie){
window.AdManager = AdManager;
}
this.loadGameBool = true;
};
/** 初始化 发布类型 */
private static initOsType(){
if( this.releaseType == releaseType.APP_google ){
this.osType = osType.android;
}else if( this.releaseType == releaseType.APP_ios ){
this.osType = osType.ios;
}else if(this.releaseType == releaseType.applet_wechat ||
this.releaseType == releaseType.applet_ziJie ){
this.osType = osType.applet;
}else{
this.osType = osType.h5;
}
}
/**
* 存储本地数据
* @param {*} isObject 是否是一个对象或者数组
*/
public static setStorage(key: string, value: any, isObject = false) {
key = this.storageKey + key;
if (PlatformManager.releaseType === releaseType.applet_ziJie) {
return tt.setStorageSync(key, value);
}
if (isObject) {
value = JSON.stringify(value);
}
/** 默认cocos 存储数据方法 */
sys.localStorage.setItem(key, value);
}
/**
* 获取存储数据
* @param {*} isObject 是否是一个对象或者数组
*/
public static getStorage(key: string, isObject = false) {
key = this.storageKey + key;
let temp = null;
if (PlatformManager.releaseType === releaseType.applet_ziJie) {
temp = <any>tt.getStorageSync(key);
}else{
temp = <any>sys.localStorage.getItem(key);
if (!temp || temp.toString() == "NaN" || temp.toString() == "null") {
temp = null;
}else if( isObject ){
temp = JSON.parse(temp);
}else if ( !isNaN(temp) ) {
temp = parseInt(temp);
}
}
return temp;
};
};
window.PlatformManager = PlatformManager;
/** 发布平台类型 */
export var releaseType = Enum({
/** 测试 */
test_TEST: 1,
/** 微伞 h5 */
h5_weiSan: 2,
/** 通用 h5 */
h5_common: 3,
/** 字节跳动 小程序*/
applet_ziJie: 4,
applet_wechat: 5 ,
/** 谷歌 AppPlay*/
APP_google: 10,
/** IOS appStore */
APP_ios: 11,
});
/** 发布类型 h5 安卓 IOS 小程序 */
export enum osType{
h5 = 1,
android = 2,
ios = 3,
applet = 4,
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "4369c8b0-61d8-446e-bb87-570f94477bf4",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,126 @@
import { _decorator, Director, director, instantiate, Node, NodePool, Prefab } from 'cc';
const { ccclass, property } = _decorator;
export class PoolManager {
private static _instance: PoolManager = new PoolManager();
private constructor() { }
public static get _ins() {
return this._instance;
}
private prefabMap: Map<string, Prefab> = new Map();
private poolDic: Map<string, NodePool> = new Map();
/**
* 初始化
* @param resArr 预制体数组
* 如无出现BUG无须主动调用
*/
init(prefabs: Prefab[]) {
if (!prefabs || prefabs.length === 0) return;
// 清空之前的记录
this.prefabMap.clear();
// 使用 Map 存储,提高查询效率
prefabs.forEach(prefab => {
if (prefab && prefab.name) {
this.prefabMap.set(prefab.name, prefab);
}
});
}
/**
* 根据名称获取预制体
* @param url 预制体的res/Prefab/的路径 或者 resArr拖动的名字
*/
getNode(url: string) {
let prefab: Prefab = null;
if (this.prefabMap.has(url)) {
prefab = this.prefabMap.get(url);
}
if (!prefab) {
if (this.poolDic.has(url)) {
if (this.poolDic.get(url).size() > 0) {
const node = this.poolDic.get(url).get();
return node;
} else {
const node = new Node(url);
return node;
}
} else {
this.poolDic.set(url, new NodePool(url));
const node = new Node(url);
return node;
}
} else {
if (!this.poolDic.has(url)) {
const node = instantiate(prefab);
this.poolDic.set(url, new NodePool(url));
console.warn("First Init Pool: " + url);
return node;
} else {
const Pool = this.poolDic.get(url);
if (Pool.size() > 0) {
const node = Pool.get();
return node;
} else {
const node = instantiate(prefab);
return node;
}
}
}
}
/**
* 回收节点
* @param node 节点
* @param isRigiBody 是否是刚体
*/
recycleNode(node: Node, isRigiBody: boolean = false) {
const url = node.name;
if (isRigiBody) {
if (this.poolDic.has(url)) {
director.once(Director.EVENT_AFTER_PHYSICS, () => {
this.poolDic.get(url).put(node);
})
} else {
this.poolDic.set(url, new NodePool(url));
director.once(Director.EVENT_AFTER_PHYSICS, () => {
this.poolDic.get(url).put(node);
})
}
} else {
if (this.poolDic.has(url)) {
this.poolDic.get(url).put(node);
} else {
this.poolDic.set(url, new NodePool(url));
this.poolDic.get(url).put(node);
}
}
}
/**
* 清空所有节点池
*/
clearAllPool() {
for (let pool of this.poolDic.values()) {
pool.clear();
}
this.poolDic.clear();
}
/**
* 获取节点池字典
*/
getPoolDic() {
return this.poolDic;
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "ea012293-8105-4f8a-a2f4-2be50875c717",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,123 @@
import { Component, director , find, Node} from "cc";
import { Tools } from "../common/Tools";
import { weiSan } from "../common/weiSanTools";
export abstract class UIManager extends Component {
/** 存放UI的字典 */
public static UIDic: Map<string, any> = new Map();
/**
* 打开一个UI页面
* @param panelName UIConfig配置里面的名字
* @param param 打开UI时传递的参数
* @param isRemoveOther 是否删除所有的UI
* @returns
*/
public static OpenUI(panelName: string, isRemoveOther: boolean = false, ...param: any): void {
let config;
if (UIConfig[panelName]) {
config = UIConfig[panelName];
}
if (config == null) {
weiSan.error("未找到该UI的配置信息:" + panelName);
return null;
}
if (!this.UIDic.has(panelName)) {
if (isRemoveOther == true) {
this.removeAllUI();
}
this.CreateUI(config, ...param);
} else {
weiSan.warn("已经打开过UI:" + panelName);
}
};
/**
* 关闭一个UI页面
* @param panelName UIConfig配置里面的名字
* @param param 关闭UI时传递的参数
*/
public static CloseUI(panelName: string, ...param: any): void {
let panel;
panel = this.UIDic.get(panelName);
if (panel) {
this.UIDic.delete(panelName);
if(panel.name == ""){ return; }
let component = panel.getComponent(panel.config.com);
if (component && component.closeUI) {
component.closeUI(...param);
}
} else {
weiSan.warn("已经关闭过UI:" + panelName);
}
};
/**
* 获取UI的Node
* @param {*} panelName UI配置里面的名字
*/
public static GetUI(panelName): Node {
let panel = this.UIDic.get(panelName);
if (panel != null) {
return panel;
} else {
weiSan.log("没有打开UI:" + panelName);
return null;
}
};
/**
* 获取UI上的脚本
* @param {*} panelName UI的名字
*/
public static GetUIForComponent(panelName) {
let panel = this.UIDic.get(panelName);
if (panel != null) {
return panel.getComponent(panel.config.com);
} else {
weiSan.warn("没有打开UI:" + panelName);
return null;
}
};
/**
* 创建一个UI
* @param config UI配置config
* @param param 传递参数
* @returns
*/
public static CreateUI(config: any, ...param: any): void {
if (this.UIDic.get(config.name) != null) { return; }
// let parent = director.getScene().getChildByName();
let parent = find("Canvas");
Tools.newPrefab(config.resUrl, parent , null, (node: any) => {
node.config = config;
let component = node.getComponent(config.com);
if (component && component.openUI) {
component.openUI(...param);
component.uiName = config.name;
}
// this.UIDic[config.name] = node;
this.UIDic.set(config.name, node);
});
};
/**
* 移除所有存放在字典里的UI
*/
public static removeAllUI(): void {
this.UIDic.forEach( (value:any,key:any) => {
this.CloseUI( key.toString() );
} );
};
/** 从字典中移除所有UI */
public static removeUIDic() {
this.UIDic.clear();
};
public abstract openUI(...data: any);
public abstract closeUI(...data: any);
public abstract uiName:string;
protected onDestroy(): void {
UIManager.UIDic.delete(this.uiName);
}
}
/** name UI的名字 resUrl预制体加载路径或者名字 com绑定脚本的名字 */
var UIConfig = <any>{
OverUI: { name: "OverUI", resUrl: "OverUI", com: "OverUI", zIndex: 99 },
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "fcdeb5f9-1b46-4a66-9692-5b16e61da895",
"files": [],
"subMetas": {},
"userData": {}
}