mirror of
https://gitee.com/dgflash/oops-plugin-framework.git
synced 2026-05-08 03:16:49 +08:00
优化代码
This commit is contained in:
@@ -8,7 +8,7 @@ import { ecs } from "../libs/ecs/ECS";
|
||||
import { ECSRootSystem } from "../libs/ecs/ECSSystem";
|
||||
import { LanguageManager } from "../libs/gui/language/Language";
|
||||
import { HttpRequest } from "../libs/network/HttpRequest";
|
||||
import { config } from "../module/config/Config";
|
||||
import { Config } from "../module/config/Config";
|
||||
import { AudioManager } from "./common/audio/AudioManager";
|
||||
import { MessageManager } from "./common/event/MessageManager";
|
||||
import { ResLoader } from "./common/loader/ResLoader";
|
||||
@@ -25,7 +25,7 @@ export var version: string = "1.1.3";
|
||||
export class oops {
|
||||
/** ----------核心模块---------- */
|
||||
/** 游戏配置 */
|
||||
static config = config;
|
||||
static config = new Config();
|
||||
/** 日志管理 */
|
||||
static log = Logger;
|
||||
/** 全局消息 */
|
||||
|
||||
@@ -4,8 +4,11 @@
|
||||
* @LastEditors: dgflash
|
||||
* @LastEditTime: 2022-11-01 15:44:57
|
||||
*/
|
||||
import { Component, director, game, Game, log, Node, sys, view, _decorator } from "cc";
|
||||
import { Component, director, game, Game, JsonAsset, log, Node, sys, view, _decorator } from "cc";
|
||||
import { LanguageManager } from "../libs/gui/language/Language";
|
||||
import { BuildTimeConstants } from "../module/config/BuildTimeConstants";
|
||||
import { GameConfig } from "../module/config/GameConfig";
|
||||
import { GameQueryConfig } from "../module/config/GameQueryConfig";
|
||||
import { AudioManager } from "./common/audio/AudioManager";
|
||||
import { EventMessage } from "./common/event/EventMessage";
|
||||
import { TimerManager } from "./common/manager/TimerManager";
|
||||
@@ -35,7 +38,18 @@ export class Root extends Component {
|
||||
onLoad() {
|
||||
console.log(`Oops Framework v${version}`);
|
||||
this.enabled = false;
|
||||
oops.config.init(() => {
|
||||
|
||||
let config_name = "config/config";
|
||||
oops.res.load(config_name, JsonAsset, () => {
|
||||
var config = oops.res.get(config_name);
|
||||
oops.config.btc = new BuildTimeConstants();
|
||||
oops.config.query = new GameQueryConfig();
|
||||
oops.config.game = new GameConfig(config);
|
||||
oops.http.server = oops.config.game.httpServer; // Http 服务器地址
|
||||
oops.http.timeout = oops.config.game.httpTimeout; // Http 请求超时时间
|
||||
oops.storage.init(oops.config.game.localDataKey, oops.config.game.localDataIv); // 初始化本地存储加密
|
||||
game.frameRate = oops.config.game.frameRate; // 初始化每秒传输帧数
|
||||
|
||||
this.enabled = true;
|
||||
this.init();
|
||||
this.run();
|
||||
|
||||
@@ -284,10 +284,4 @@ oops.res.loadDir("game", onProgressCallback, onCompleteCallback);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源管理模块
|
||||
* @deprecated 下个版本废弃,请使用 oops.res
|
||||
*/
|
||||
export var resLoader = new ResLoader();
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
import { Component, sp, _decorator } from 'cc';
|
||||
import { resLoader } from '../../../core/common/loader/ResLoader';
|
||||
import { oops } from '../../../core/Oops';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 动画播放完隐藏特效 */
|
||||
@@ -28,7 +28,7 @@ export class SpineFinishedRelease extends Component {
|
||||
this.spine.setCompleteListener(this.onSpineComplete.bind(this));
|
||||
|
||||
if (this.resPath) {
|
||||
resLoader.load(this.resPath, sp.SkeletonData, (err: Error | null, sd: sp.SkeletonData) => {
|
||||
oops.res.load(this.resPath, sp.SkeletonData, (err: Error | null, sd: sp.SkeletonData) => {
|
||||
if (err) {
|
||||
console.error(`加载【${this.resPath}】的 SPINE 资源不存在`);
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Animation, AnimationClip, EventTouch, _decorator } from "cc";
|
||||
import { resLoader } from "../../../core/common/loader/ResLoader";
|
||||
import { oops } from "../../../core/Oops";
|
||||
import ButtonSimple from "./ButtonSimple";
|
||||
|
||||
const { ccclass, property, menu } = _decorator;
|
||||
@@ -17,8 +17,8 @@ export default class ButtonEffect extends ButtonSimple {
|
||||
onLoad() {
|
||||
this.anim = this.node.addComponent(Animation);
|
||||
|
||||
var ac_start = resLoader.get("common/anim/button_scale_start", AnimationClip)!;
|
||||
var ac_end = resLoader.get("common/anim/button_scale_end", AnimationClip)!;
|
||||
var ac_start = oops.res.get("common/anim/button_scale_start", AnimationClip)!;
|
||||
var ac_end = oops.res.get("common/anim/button_scale_end", AnimationClip)!;
|
||||
this.anim.defaultClip = ac_start;
|
||||
this.anim.createState(ac_start, ac_start?.name);
|
||||
this.anim.createState(ac_end, ac_end?.name);
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
* @LastEditTime: 2022-11-01 15:47:16
|
||||
*/
|
||||
|
||||
import { game, JsonAsset } from "cc";
|
||||
import { oops } from "../../core/Oops";
|
||||
import { BuildTimeConstants } from "./BuildTimeConstants";
|
||||
import { GameConfig } from "./GameConfig";
|
||||
import { GameQueryConfig } from "./GameQueryConfig";
|
||||
@@ -21,32 +19,4 @@ export class Config {
|
||||
|
||||
/** 浏览器查询参数 */
|
||||
public query!: GameQueryConfig;
|
||||
|
||||
/** 初始化游戏配置 */
|
||||
public init(callback: Function) {
|
||||
let config_name = "config/config";
|
||||
oops.res.load(config_name, JsonAsset, () => {
|
||||
var config = oops.res.get(config_name);
|
||||
this.btc = new BuildTimeConstants();
|
||||
this.query = new GameQueryConfig();
|
||||
this.game = new GameConfig(config);
|
||||
|
||||
// 初始化每秒传输帧数
|
||||
game.frameRate = this.game.frameRate;
|
||||
// Http 服务器地址
|
||||
oops.http.server = this.game.httpServer;
|
||||
// Http 请求超时时间
|
||||
oops.http.timeout = this.game.httpTimeout;
|
||||
// 初始化本地存储加密
|
||||
oops.storage.init(this.game.localDataKey, this.game.localDataIv);
|
||||
|
||||
callback();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 游戏配置静态访问类
|
||||
* @deprecated 下个版本废弃,请使用 oops.config
|
||||
*/
|
||||
export const config = new Config()
|
||||
}
|
||||
Reference in New Issue
Block a user