mirror of
https://gitee.com/dgflash/oops-framework.git
synced 2026-06-03 19:09:36 +08:00
修复打包时,多语言模块的循环引用问题
This commit is contained in:
@@ -8,33 +8,33 @@
|
||||
"__original-animation-1.cconb",
|
||||
"__original-animation-2.cconb",
|
||||
"__original-animation-3.cconb",
|
||||
"__original-animation-5.cconb",
|
||||
"__original-animation-4.cconb",
|
||||
"__original-animation-6.cconb",
|
||||
"__original-animation-5.cconb",
|
||||
"__original-animation-7.cconb",
|
||||
"__original-animation-6.cconb",
|
||||
"__original-animation-8.cconb",
|
||||
"__original-animation-11.cconb",
|
||||
"__original-animation-10.cconb",
|
||||
"__original-animation-9.cconb",
|
||||
"__original-animation-10.cconb",
|
||||
"__original-animation-11.cconb",
|
||||
"__original-animation-12.cconb",
|
||||
"__original-animation-13.cconb",
|
||||
"__original-animation-14.cconb",
|
||||
"__original-animation-15.cconb",
|
||||
"__original-animation-16.cconb",
|
||||
"__original-animation-17.cconb",
|
||||
"__original-animation-18.cconb",
|
||||
"__original-animation-19.cconb",
|
||||
"__original-animation-16.cconb",
|
||||
"__original-animation-20.cconb",
|
||||
"__original-animation-21.cconb",
|
||||
"__original-animation-24.cconb",
|
||||
"__original-animation-22.cconb",
|
||||
"__original-animation-23.cconb",
|
||||
"__original-animation-24.cconb",
|
||||
"__original-animation-25.cconb",
|
||||
"__original-animation-26.cconb",
|
||||
"__original-animation-27.cconb",
|
||||
"__original-animation-30.cconb",
|
||||
"__original-animation-28.cconb",
|
||||
"__original-animation-29.cconb",
|
||||
"__original-animation-30.cconb",
|
||||
"__original-animation-31.cconb",
|
||||
"__original-animation-32.cconb"
|
||||
],
|
||||
|
||||
@@ -3371,7 +3371,7 @@
|
||||
"_priority": 1073741824,
|
||||
"_fov": 45,
|
||||
"_fovAxis": 0,
|
||||
"_orthoHeight": 401.67364016736406,
|
||||
"_orthoHeight": 455.9197324414716,
|
||||
"_near": 1,
|
||||
"_far": 2000,
|
||||
"_color": {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { AudioManager } from "./common/audio/AudioManager";
|
||||
import { TimerManager } from "./common/manager/TimerManager";
|
||||
import { SqlUtil } from "./common/storage/SqlUtil";
|
||||
import { storage } from "./common/storage/SqlUtil";
|
||||
import { GameManager } from "./game/GameManager";
|
||||
import { LanguageManager } from "./gui/language/Language";
|
||||
import { LayerManager } from "./gui/layer/LayerManager";
|
||||
import { HttpRequest } from "./network/HttpRequest";
|
||||
import { Root } from "./Root";
|
||||
|
||||
export class engine {
|
||||
export class oops {
|
||||
/** 多语言模块 */
|
||||
public static language: LanguageManager;
|
||||
/** 游戏时间管理 */
|
||||
@@ -21,15 +21,15 @@ export class engine {
|
||||
/** HTTP */
|
||||
public static http: HttpRequest;
|
||||
/** 本地存储 */
|
||||
public static storage = SqlUtil;
|
||||
public static storage = storage;
|
||||
|
||||
/** 在Root.ts中初始化引导模块 */
|
||||
private static init(root: Root) {
|
||||
engine.language = new LanguageManager()
|
||||
engine.timer = new TimerManager(root);
|
||||
engine.audio = AudioManager.instance;
|
||||
engine.http = new HttpRequest();
|
||||
engine.gui = new LayerManager(root.gui!);
|
||||
engine.game = root.addComponent(GameManager)!;
|
||||
oops.language = new LanguageManager();
|
||||
oops.timer = new TimerManager(root);
|
||||
oops.audio = AudioManager.instance;
|
||||
oops.http = new HttpRequest();
|
||||
oops.gui = new LayerManager(root.gui!);
|
||||
oops.game = root.addComponent(GameManager)!;
|
||||
}
|
||||
}
|
||||
9
assets/script/core/Oops.ts.meta
Normal file
9
assets/script/core/Oops.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "cbae5c33-7d26-46cd-932e-c9e01eb527e0",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import { RootSystem } from "../game/common/ecs/RootSystem";
|
||||
import { config } from "../game/common/config/Config";
|
||||
import { EngineMessage } from "./common/event/EngineMessage";
|
||||
import { Message } from "./common/event/MessageManager";
|
||||
import { engine } from "./Engine";
|
||||
import { oops } from "./Oops";
|
||||
import { GUI } from "./gui/GUI";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -34,7 +34,7 @@ export class Root extends Component {
|
||||
this.init();
|
||||
|
||||
//@ts-ignore
|
||||
engine.init(this);
|
||||
oops.init(this);
|
||||
|
||||
// 加载游戏配置
|
||||
config.init(this.run.bind(this));
|
||||
@@ -58,8 +58,8 @@ export class Root extends Component {
|
||||
// 游戏显示事件
|
||||
game.on(Game.EVENT_SHOW, () => {
|
||||
log("Game.EVENT_SHOW");
|
||||
engine.timer.load(); // 平台不需要在退出时精准计算时间,直接暂时游戏时间
|
||||
engine.audio.resumeAll();
|
||||
oops.timer.load(); // 平台不需要在退出时精准计算时间,直接暂时游戏时间
|
||||
oops.audio.resumeAll();
|
||||
director.resume();
|
||||
game.resume();
|
||||
Message.dispatchEvent(EngineMessage.GAME_ENTER);
|
||||
@@ -68,8 +68,8 @@ export class Root extends Component {
|
||||
// 游戏隐藏事件
|
||||
game.on(Game.EVENT_HIDE, () => {
|
||||
log("Game.EVENT_HIDE");
|
||||
engine.timer.save(); // 平台不需要在退出时精准计算时间,直接暂时游戏时间
|
||||
engine.audio.pauseAll();
|
||||
oops.timer.save(); // 平台不需要在退出时精准计算时间,直接暂时游戏时间
|
||||
oops.audio.pauseAll();
|
||||
director.pause();
|
||||
game.pause();
|
||||
Message.dispatchEvent(EngineMessage.GAME_EXIT);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component, game, Node } from "cc";
|
||||
import { engine } from "../../Engine";
|
||||
import { storage } from "../storage/SqlUtil";
|
||||
import { AudioEffect } from "./AudioEffect";
|
||||
import { AudioMusic } from "./AudioMusic";
|
||||
|
||||
@@ -38,7 +38,7 @@ export class AudioManager extends Component {
|
||||
private _localStorageTag: string = ""; // 本地存储标签名
|
||||
|
||||
private init() {
|
||||
let data = engine.storage.get(this._localStorageTag);
|
||||
let data = storage.get(this._localStorageTag);
|
||||
if (data) {
|
||||
try {
|
||||
this.local_data = JSON.parse(data);
|
||||
@@ -155,6 +155,6 @@ export class AudioManager extends Component {
|
||||
this.local_data.switch_effect = this._switch_effect;
|
||||
|
||||
let data = JSON.stringify(this.local_data);
|
||||
engine.storage.set(this._localStorageTag, data);
|
||||
storage.set(this._localStorageTag, data);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import { PREVIEW } from "cc/env";
|
||||
import { EncryptUtil } from "./EncryptUtil";
|
||||
import { md5 } from "./Md5";
|
||||
|
||||
export module SqlUtil {
|
||||
export module storage {
|
||||
let _key: string | null = null;
|
||||
let _iv: string | null = null;
|
||||
let _id: number = -1;
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "9f0f8674-5ea3-45dd-98bb-dd163a68fa03",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"moduleId": "project:///assets/script/core/Engine.js",
|
||||
"importerSettings": 4,
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Label, _decorator } from "cc";
|
||||
import { EDITOR } from "cc/env";
|
||||
import { engine } from "../../Engine";
|
||||
import { oops } from "../../Oops";
|
||||
|
||||
const { ccclass, property, menu } = _decorator;
|
||||
|
||||
@@ -116,12 +116,12 @@ export default class LabelTime extends Label {
|
||||
start() {
|
||||
this.format();
|
||||
if (!EDITOR)
|
||||
this.timeId = engine.timer.registerObject(this, "countDown", this.onSecond, this.onComplete);
|
||||
this.timeId = oops.timer.registerObject(this, "countDown", this.onSecond, this.onComplete);
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
if (!EDITOR)
|
||||
engine.timer.unRegisterObject(this.timeId);
|
||||
oops.timer.unRegisterObject(this.timeId);
|
||||
}
|
||||
|
||||
private onSecond() {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { error, warn } from "cc";
|
||||
import { EventDispatcher } from "../../common/event/EventDispatcher";
|
||||
import { Logger } from "../../common/log/Logger";
|
||||
import { LanguageLabel } from "./LanguageLabel";
|
||||
import LanguagePack from "./LanguagePack";
|
||||
import { LanguageData } from "./LanguageData";
|
||||
import { LanguagePack } from "./LanguagePack";
|
||||
|
||||
export enum LanguageEvent {
|
||||
/** 语种变化事件 */
|
||||
@@ -13,12 +13,8 @@ export enum LanguageEvent {
|
||||
const DEFAULT_LANGUAGE = "zh";
|
||||
|
||||
export class LanguageManager extends EventDispatcher {
|
||||
/** Label修改之前的回调 */
|
||||
public beforeChangeLabel: ((comp: LanguageLabel, content: string, dataID: string) => void) | null = null;
|
||||
|
||||
private _current: string = ""; // 当前语言
|
||||
private _support: Array<string> = ["zh", "en", "tr"]; // 支持的语言
|
||||
private _languagePack: LanguagePack = new LanguagePack(); // 语言包
|
||||
private _languagePack: LanguagePack = new LanguagePack(); // 语言包
|
||||
|
||||
/** 设置多语言系统支持哪些语种 */
|
||||
public set supportLanguages(supportLanguages: Array<string>) {
|
||||
@@ -29,7 +25,7 @@ export class LanguageManager extends EventDispatcher {
|
||||
* 获取当前语种
|
||||
*/
|
||||
public get current(): string {
|
||||
return this._current;
|
||||
return LanguageData.current;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,7 +44,7 @@ export class LanguageManager extends EventDispatcher {
|
||||
*/
|
||||
public getNextLang(): string {
|
||||
let supportLangs = this.languages;
|
||||
let index = supportLangs.indexOf(this._current);
|
||||
let index = supportLangs.indexOf(LanguageData.current);
|
||||
let newLanguage = supportLangs[(index + 1) % supportLangs.length];
|
||||
return newLanguage;
|
||||
}
|
||||
@@ -67,7 +63,7 @@ export class LanguageManager extends EventDispatcher {
|
||||
warn("当前不支持该语种" + language + " 将自动切换到 zh 语种!");
|
||||
language = DEFAULT_LANGUAGE;
|
||||
}
|
||||
if (language === this._current) {
|
||||
if (language === LanguageData.current) {
|
||||
callback(false);
|
||||
return;
|
||||
}
|
||||
@@ -80,7 +76,7 @@ export class LanguageManager extends EventDispatcher {
|
||||
}
|
||||
|
||||
Logger.logConfig(`当前语言为【${language}】`);
|
||||
this._current = language;
|
||||
LanguageData.current = language;
|
||||
this._languagePack.updateLanguage(language);
|
||||
this.dispatchEvent(LanguageEvent.CHANGE, lang);
|
||||
callback(true);
|
||||
@@ -102,7 +98,7 @@ export class LanguageManager extends EventDispatcher {
|
||||
* @param arr
|
||||
*/
|
||||
public getLangByID(labId: string): string {
|
||||
return this._languagePack.getLangByID(labId);
|
||||
return LanguageData.getLangByID(labId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
10
assets/script/core/gui/language/LanguageData.ts
Normal file
10
assets/script/core/gui/language/LanguageData.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export class LanguageData {
|
||||
/** 当前语言 */
|
||||
static current: string = "";
|
||||
/** 语言配置 */
|
||||
static data: any = {}
|
||||
|
||||
public static getLangByID(labId: string): string {
|
||||
return LanguageData.data[labId] || "";
|
||||
}
|
||||
}
|
||||
9
assets/script/core/gui/language/LanguageData.ts.meta
Normal file
9
assets/script/core/gui/language/LanguageData.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "27fb3b23-0fcd-4994-83f6-2854d2594a78",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { CCString, Component, error, Label, warn, _decorator } from "cc";
|
||||
import { EDITOR } from "cc/env";
|
||||
import { engine } from "../../Engine";
|
||||
import { LanguageData } from "./LanguageData";
|
||||
|
||||
const { ccclass, property, menu } = _decorator;
|
||||
|
||||
@@ -49,10 +49,7 @@ export class LanguageLabel extends Component {
|
||||
}
|
||||
|
||||
get string(): string {
|
||||
let _string = engine.language.getLangByID(this._dataID);
|
||||
if (engine.language.beforeChangeLabel) {
|
||||
engine.language.beforeChangeLabel(this, _string, this._dataID);
|
||||
}
|
||||
let _string = LanguageData.getLangByID(this._dataID);
|
||||
if (_string && this._params.length > 0) {
|
||||
this._params.forEach((item: LangLabelParamsItem) => {
|
||||
_string = _string.replace(`%{${item.key}}`, item.value)
|
||||
@@ -132,7 +129,7 @@ export class LanguageLabel extends Component {
|
||||
break;
|
||||
}
|
||||
|
||||
spcomp.fontFamily = this.getLabelFont(engine.language.current);
|
||||
spcomp.fontFamily = this.getLabelFont(LanguageData.current);
|
||||
spcomp.string = this.string;
|
||||
}
|
||||
while (false);
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { director, error, JsonAsset, warn } from "cc";
|
||||
import { resLoader } from "../../common/loader/ResLoader";
|
||||
import { Logger } from "../../common/log/Logger";
|
||||
import { LanguageData } from "./LanguageData";
|
||||
import { LanguageLabel } from "./LanguageLabel";
|
||||
import { LanguageSprite } from "./LanguageSprite";
|
||||
|
||||
export default class LanguagePack {
|
||||
private _languageLabels: any = {};
|
||||
|
||||
export class LanguagePack {
|
||||
// 默认资源文件目录
|
||||
private _langjsonPath: string = "lang_json";
|
||||
private _langTexturePath: string = "lang_texture";
|
||||
@@ -32,7 +31,7 @@ export default class LanguagePack {
|
||||
public updateLanguage(lang: string) {
|
||||
let lanjson = resLoader.get(`${this._langjsonPath}/${lang}`, JsonAsset);
|
||||
if (lanjson && lanjson.json) {
|
||||
this._languageLabels = lanjson.json;
|
||||
LanguageData.data = lanjson.json;
|
||||
let rootNodes = director.getScene()!.children;
|
||||
for (let i = 0; i < rootNodes.length; ++i) {
|
||||
// 更新所有的LanguageLabel节点
|
||||
@@ -52,14 +51,6 @@ export default class LanguagePack {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据dataID,获取对应语言的字符
|
||||
* @param uuid
|
||||
*/
|
||||
public getLangByID(labId: string): string {
|
||||
return this._languageLabels[labId] || "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载对应语言包资源
|
||||
* @param lang 语言标识
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Component, Size, Sprite, SpriteFrame, UITransform, _decorator } from "cc";
|
||||
import { resLoader } from "../../common/loader/ResLoader";
|
||||
import { Logger } from "../../common/log/Logger";
|
||||
import { engine } from "../../Engine";
|
||||
import { LanguageData } from "./LanguageData";
|
||||
|
||||
const { ccclass, property, menu } = _decorator;
|
||||
|
||||
@@ -19,7 +19,7 @@ export class LanguageSprite extends Component {
|
||||
private isRawSize: boolean = true;
|
||||
|
||||
start() {
|
||||
this.language = engine.language.current;
|
||||
this.language = LanguageData.current;
|
||||
}
|
||||
|
||||
set language(lang: string) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component, EventTouch, _decorator } from "cc";
|
||||
import { engine } from "../../Engine";
|
||||
import { oops } from "../../Oops";
|
||||
import { LanguageLabel } from "../language/LanguageLabel";
|
||||
|
||||
const { ccclass, property, menu } = _decorator;
|
||||
@@ -92,7 +92,7 @@ export default class CommonPrompt extends Component {
|
||||
}
|
||||
|
||||
private close() {
|
||||
engine.gui.removeByNode(this.node);
|
||||
oops.gui.removeByNode(this.node);
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import { Node, tween, Vec3 } from "cc";
|
||||
import { UIID } from "../../../game/common/config/GameUIConfig";
|
||||
import { engine } from "../../Engine";
|
||||
import { oops } from "../../Oops";
|
||||
import { PopViewParams } from "../layer/Defines";
|
||||
|
||||
class TipsManager {
|
||||
@@ -15,26 +15,26 @@ class TipsManager {
|
||||
/** 网络恢复 */
|
||||
public networkRecovery() {
|
||||
if (this._timeId) {
|
||||
engine.timer.unschedule(this._timeId);
|
||||
oops.timer.unschedule(this._timeId);
|
||||
this._timeId = "";
|
||||
}
|
||||
engine.gui.remove(UIID.Netinstable);
|
||||
oops.gui.remove(UIID.Netinstable);
|
||||
}
|
||||
/** 打开网络不稳定提示 */
|
||||
public netInstableOpen() {
|
||||
if (!engine.gui.has(UIID.Netinstable)) {
|
||||
engine.gui.open(UIID.Netinstable);
|
||||
if (!oops.gui.has(UIID.Netinstable)) {
|
||||
oops.gui.open(UIID.Netinstable);
|
||||
}
|
||||
}
|
||||
public netInstableClose() {
|
||||
engine.gui.remove(UIID.Netinstable);
|
||||
oops.gui.remove(UIID.Netinstable);
|
||||
}
|
||||
/** 网络延时 */
|
||||
public networkLatency(time: number) {
|
||||
if (this._timeId) {
|
||||
engine.timer.unschedule(this._timeId);
|
||||
oops.timer.unschedule(this._timeId);
|
||||
}
|
||||
this._timeId = engine.timer.scheduleOnce(this.netInstableOpen, time);
|
||||
this._timeId = oops.timer.scheduleOnce(this.netInstableOpen, time);
|
||||
}
|
||||
|
||||
public test(callback?: Function) {
|
||||
@@ -51,7 +51,7 @@ class TipsManager {
|
||||
},
|
||||
needCancel: true
|
||||
};
|
||||
engine.gui.open(UIID.Window, operate, this.getPopCommonEffect());
|
||||
oops.gui.open(UIID.Window, operate, this.getPopCommonEffect());
|
||||
}
|
||||
|
||||
public alert(content: string, cb?: Function, title?: string, okWord?: string) {
|
||||
@@ -64,7 +64,7 @@ class TipsManager {
|
||||
},
|
||||
needCancel: false
|
||||
};
|
||||
engine.gui.open(UIID.Window, operate, tips.getPopCommonEffect());
|
||||
oops.gui.open(UIID.Window, operate, tips.getPopCommonEffect());
|
||||
}
|
||||
|
||||
public confirm(content: string, cb: Function, okWord: string = "common_prompt_ok") {
|
||||
@@ -81,7 +81,7 @@ class TipsManager {
|
||||
},
|
||||
needCancel: true
|
||||
};
|
||||
engine.gui.open(UIID.Window, operate, tips.getPopCommonEffect());
|
||||
oops.gui.open(UIID.Window, operate, tips.getPopCommonEffect());
|
||||
}
|
||||
|
||||
/** 弹窗动画 */
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
*/
|
||||
|
||||
import { Message } from "../../../core/common/event/MessageManager";
|
||||
import { SqlUtil } from "../../../core/common/storage/SqlUtil";
|
||||
import { engine } from "../../../core/Engine";
|
||||
import { storage } from "../../../core/common/storage/SqlUtil";
|
||||
import { oops } from "../../../core/Oops";
|
||||
import { ecs } from "../../../core/libs/ECS";
|
||||
import { VM } from "../../../core/libs/model-view/ViewModel";
|
||||
import { GameEvent } from "../../common/config/GameEvent";
|
||||
@@ -96,7 +96,7 @@ export class AccountNetDataSystem extends ecs.ComblockSystem implements ecs.IEnt
|
||||
|
||||
// 角色动画显示对象
|
||||
role.load();
|
||||
role.RoleView.node.parent = engine.gui.game;
|
||||
role.RoleView.node.parent = oops.gui.game;
|
||||
role.RoleView.node.setPosition(0, -300, 0);
|
||||
|
||||
e.AccountModel.role = role;
|
||||
@@ -104,7 +104,7 @@ export class AccountNetDataSystem extends ecs.ComblockSystem implements ecs.IEnt
|
||||
|
||||
/** 设置本地存储的用户标识 */
|
||||
private setLocalStorage(uid: number) {
|
||||
SqlUtil.setUser(uid);
|
||||
SqlUtil.set("account", uid);
|
||||
storage.setUser(uid);
|
||||
storage.set("account", uid);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import { game, JsonAsset } from "cc";
|
||||
import { resLoader } from "../../../core/common/loader/ResLoader";
|
||||
import { engine } from "../../../core/Engine";
|
||||
import { oops } from "../../../core/Oops";
|
||||
import { BuildTimeConstants } from "./BuildTimeConstants";
|
||||
import { GameConfig } from "./GameConfig";
|
||||
import { GameQueryConfig } from "./GameQueryConfig";
|
||||
@@ -35,13 +35,13 @@ export class Config {
|
||||
// 初始化每秒传输帧数
|
||||
game.frameRate = this.game.frameRate;
|
||||
// Http 服务器地址
|
||||
engine.http.server = this.game.httpServer;
|
||||
oops.http.server = this.game.httpServer;
|
||||
// Http 请求超时时间
|
||||
engine.http.timeout = this.game.httpTimeout;
|
||||
oops.http.timeout = this.game.httpTimeout;
|
||||
// 初始化本地存储加密
|
||||
engine.storage.init(this.game.localDataKey, this.game.localDataIv);
|
||||
oops.storage.init(this.game.localDataKey, this.game.localDataIv);
|
||||
// 初始化界面窗口配置
|
||||
engine.gui.init(UIConfigData);
|
||||
oops.gui.init(UIConfigData);
|
||||
|
||||
callback();
|
||||
})
|
||||
|
||||
@@ -59,6 +59,7 @@ export class GameConfig {
|
||||
get languagePathTexture(): string {
|
||||
return this._data.language.path.texture || "language/texture";
|
||||
}
|
||||
|
||||
|
||||
private _data: any = null;
|
||||
constructor(config: any) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
import { Component, EventTouch, Prefab, _decorator } from "cc";
|
||||
import { resLoader } from "../../core/common/loader/ResLoader";
|
||||
import { engine } from "../../core/Engine";
|
||||
import { oops } from "../../core/Oops";
|
||||
import { tips } from "../../core/gui/prompt/TipsManager";
|
||||
import { ecs } from "../../core/libs/ECS";
|
||||
import { ViewUtil } from "../../core/utils/ViewUtil";
|
||||
@@ -59,20 +59,20 @@ export class Demo extends Component {
|
||||
|
||||
/** 打开角色界面 */
|
||||
private btn_open_role_info(event: EventTouch, data: any) {
|
||||
engine.gui.open(UIID.Demo_Role_Info);
|
||||
oops.gui.open(UIID.Demo_Role_Info);
|
||||
}
|
||||
|
||||
/** 多语言切换 */
|
||||
private btn_language(event: EventTouch, data: any) {
|
||||
console.log(engine.language.getLangByID("notify_show"));
|
||||
console.log(oops.language.getLangByID("notify_show"));
|
||||
|
||||
if (this.lang == false) {
|
||||
this.lang = true;
|
||||
engine.language.setLanguage("zh", () => { });
|
||||
oops.language.setLanguage("zh", () => { });
|
||||
}
|
||||
else {
|
||||
this.lang = false;
|
||||
engine.language.setLanguage("en", () => { });
|
||||
oops.language.setLanguage("en", () => { });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ export class Demo extends Component {
|
||||
|
||||
/** 漂浮提示框 */
|
||||
private btn_notify_show(event: EventTouch, data: any) {
|
||||
engine.gui.toast("common_prompt_content");
|
||||
oops.gui.toast("common_prompt_content");
|
||||
}
|
||||
|
||||
/** 加载提示 */
|
||||
@@ -101,12 +101,12 @@ export class Demo extends Component {
|
||||
|
||||
/** 背景音乐 */
|
||||
private btn_audio_open1(event: EventTouch, data: any) {
|
||||
engine.audio.musicVolume = 0.5;
|
||||
engine.audio.playMusic("audios/nocturne");
|
||||
oops.audio.musicVolume = 0.5;
|
||||
oops.audio.playMusic("audios/nocturne");
|
||||
}
|
||||
|
||||
/** 背景音效 */
|
||||
private btn_audio_open2(event: EventTouch, data: any) {
|
||||
engine.audio.playEffect("audios/Gravel");
|
||||
oops.audio.playEffect("audios/Gravel");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import { Node } from "cc";
|
||||
import { resLoader } from "../../core/common/loader/ResLoader";
|
||||
import { AsyncQueue, NextFunction } from "../../core/common/queue/AsyncQueue";
|
||||
import { engine } from "../../core/Engine";
|
||||
import { oops } from "../../core/Oops";
|
||||
import { UICallbacks } from "../../core/gui/layer/Defines";
|
||||
import { ecs } from "../../core/libs/ECS";
|
||||
import { config } from "../common/config/Config";
|
||||
@@ -46,7 +46,7 @@ export class Initialize extends ecs.Entity {
|
||||
// if (config.query.channelId) SDKPlatform.setChannelId(config.query.channelId);
|
||||
|
||||
// 加载多语言对应字体
|
||||
resLoader.load("language/font/" + engine.language.current, next);
|
||||
resLoader.load("language/font/" + oops.language.current, next);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -54,18 +54,18 @@ export class Initialize extends ecs.Entity {
|
||||
private loadLanguage(queue: AsyncQueue) {
|
||||
queue.push((next: NextFunction, params: any, args: any) => {
|
||||
// 设置默认语言
|
||||
let lan = engine.storage.get("language");
|
||||
let lan = oops.storage.get("language");
|
||||
if (lan == null) {
|
||||
// lan = SDKPlatform.getLanguage();
|
||||
lan = "zh";
|
||||
engine.storage.set("language", lan!);
|
||||
oops.storage.set("language", lan!);
|
||||
}
|
||||
|
||||
// 设置语言包路径
|
||||
engine.language.setAssetsPath(config.game.languagePathJson, config.game.languagePathTexture);
|
||||
oops.language.setAssetsPath(config.game.languagePathJson, config.game.languagePathTexture);
|
||||
|
||||
// 加载语言包资源
|
||||
engine.language.setLanguage(lan!, next);
|
||||
oops.language.setLanguage(lan!, next);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ export class Initialize extends ecs.Entity {
|
||||
};
|
||||
|
||||
// 界面管理 - 打开游戏内容资源加载进度提示界面
|
||||
engine.gui.open(UIID.Loading, null, uic);
|
||||
oops.gui.open(UIID.Loading, null, uic);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
import { _decorator } from "cc";
|
||||
import { resLoader } from "../../../core/common/loader/ResLoader";
|
||||
import { engine } from "../../../core/Engine";
|
||||
import { oops } from "../../../core/Oops";
|
||||
import { ecs } from "../../../core/libs/ECS";
|
||||
import { JsonUtil } from "../../../core/utils/JsonUtil";
|
||||
import { Account } from "../../account/Account";
|
||||
@@ -39,16 +39,16 @@ export class LoadingViewComp extends CCVMParentComp {
|
||||
|
||||
reset(): void {
|
||||
// 获取用户信息的多语言提示文本
|
||||
this.data.prompt = engine.language.getLangByID("loading_load_player");
|
||||
this.data.prompt = oops.language.getLangByID("loading_load_player");
|
||||
|
||||
// 关闭加载界面
|
||||
engine.gui.remove(UIID.Loading);
|
||||
oops.gui.remove(UIID.Loading);
|
||||
|
||||
// 释放加载界面资源
|
||||
resLoader.releaseDir("loading");
|
||||
|
||||
// 打开游戏主界面(自定义逻辑)
|
||||
engine.gui.open(UIID.Demo);
|
||||
oops.gui.open(UIID.Demo);
|
||||
}
|
||||
|
||||
start() {
|
||||
@@ -79,7 +79,7 @@ export class LoadingViewComp extends CCVMParentComp {
|
||||
/** 加载游戏本地JSON数据(自定义内容) */
|
||||
private loadCustom() {
|
||||
// 加载游戏本地JSON数据的多语言提示文本
|
||||
this.data.prompt = engine.language.getLangByID("loading_load_json");
|
||||
this.data.prompt = oops.language.getLangByID("loading_load_json");
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
await JsonUtil.loadAsync(RoleJobModelComp.TableName);
|
||||
@@ -91,7 +91,7 @@ export class LoadingViewComp extends CCVMParentComp {
|
||||
/** 加载初始游戏内容资源 */
|
||||
private loadGameRes() {
|
||||
// 加载初始游戏内容资源的多语言提示文本
|
||||
this.data.prompt = engine.language.getLangByID("loading_load_game");
|
||||
this.data.prompt = oops.language.getLangByID("loading_load_game");
|
||||
|
||||
resLoader.loadDir("game", this.onProgressCallback.bind(this), this.onCompleteCallback.bind(this));
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import { AnimationEventHandler } from "./animator/AnimationEventHandler";
|
||||
import { RoleStateAttack } from "./animator/RoleStateAttack";
|
||||
import { RoleStateDead } from "./animator/RoleStateDead";
|
||||
import { RoleStateHit } from "./animator/RoleStateHit";
|
||||
import { RoleViewComp } from "./RoleViewComp";
|
||||
|
||||
const { ccclass, property, requireComponent, disallowMultiple } = _decorator;
|
||||
|
||||
@@ -36,15 +35,11 @@ export class RoleViewAnimator extends AnimatorSpine {
|
||||
onAttackComplete: Function = null!;
|
||||
/** 受击动作完成 */
|
||||
onHitActionComplete: Function = null!;
|
||||
/** 角色对象 */
|
||||
role: Role = null!;
|
||||
|
||||
/** 武器动画名 */
|
||||
private weaponAnimName: string = null!;
|
||||
/** 角色对象 */
|
||||
private role: Role = null!;
|
||||
|
||||
onLoad() {
|
||||
this.role = this.node.parent!.parent!.getComponent(RoleViewComp)!.ent as Role;
|
||||
}
|
||||
|
||||
start() {
|
||||
super.start();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import { EventTouch, Node, sp, UITransform, v3, _decorator } from "cc";
|
||||
import { resLoader } from "../../../core/common/loader/ResLoader";
|
||||
import { engine } from "../../../core/Engine";
|
||||
import { oops } from "../../../core/Oops";
|
||||
import { ecs } from "../../../core/libs/ECS";
|
||||
import { config } from "../../common/config/Config";
|
||||
import { CCComp } from "../../common/ecs/CCComp";
|
||||
@@ -30,6 +30,7 @@ export class RoleViewComp extends CCComp {
|
||||
onLoad() {
|
||||
this.node.active = false;
|
||||
this.animator = this.spine!.getComponent(RoleViewAnimator)!;
|
||||
this.animator.role = this.ent as Role;
|
||||
}
|
||||
|
||||
load() {
|
||||
@@ -45,7 +46,7 @@ export class RoleViewComp extends CCComp {
|
||||
this.node.active = true;
|
||||
|
||||
// 移动控制
|
||||
engine.gui.root.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
|
||||
oops.gui.root.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { EventTouch, Node, _decorator } from "cc";
|
||||
import { engine } from "../../../core/Engine";
|
||||
import { oops } from "../../../core/Oops";
|
||||
import { ecs } from "../../../core/libs/ECS";
|
||||
import { UIID } from "../../common/config/GameUIConfig";
|
||||
import { CCComp } from "../../common/ecs/CCComp";
|
||||
@@ -22,7 +22,7 @@ export class RoleViewInfoComp extends CCComp {
|
||||
role.upgrade();
|
||||
break;
|
||||
case "btn_close":
|
||||
engine.gui.remove(UIID.Demo_Role_Info);
|
||||
oops.gui.remove(UIID.Demo_Role_Info);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
import { AnimatorStateLogic } from "../../../../core/libs/animator/core/AnimatorStateLogic";
|
||||
import { Role } from "../../Role";
|
||||
import { RoleViewComp } from "../RoleViewComp";
|
||||
import { AnimationEventHandler } from "./AnimationEventHandler";
|
||||
|
||||
/** 受击状态逻辑 */
|
||||
@@ -31,9 +30,6 @@ export class RoleStateDead extends AnimatorStateLogic {
|
||||
private onDead() {
|
||||
var onHitActionComplete = this.role.RoleView.animator.onHitActionComplete;
|
||||
onHitActionComplete && onHitActionComplete();
|
||||
|
||||
// 删除角色显示对象
|
||||
this.role.remove(RoleViewComp);
|
||||
}
|
||||
|
||||
public onEntry() {
|
||||
|
||||
Reference in New Issue
Block a user