mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
提交
This commit is contained in:
parent
1e76e420b1
commit
1dbbc6c79b
Binary file not shown.
BIN
DataTables/Datas/战斗/战斗资源素材.xlsx
Normal file
BIN
DataTables/Datas/战斗/战斗资源素材.xlsx
Normal file
Binary file not shown.
@ -690,6 +690,39 @@ export class TOnHookLevel {
|
||||
}
|
||||
|
||||
|
||||
export namespace TB {
|
||||
export class TbBattleResource {
|
||||
|
||||
constructor(_json_: any) {
|
||||
if (_json_.id === undefined) { throw new Error() }
|
||||
this.id = _json_.id
|
||||
if (_json_.path === undefined) { throw new Error() }
|
||||
this.path = _json_.path
|
||||
if (_json_.type === undefined) { throw new Error() }
|
||||
this.type = _json_.type
|
||||
}
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
readonly id: number
|
||||
/**
|
||||
* 资源路径
|
||||
*/
|
||||
readonly path: string
|
||||
/**
|
||||
* 资源类型(0.Spine)
|
||||
*/
|
||||
readonly type: number
|
||||
|
||||
resolve(tables:Tables)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export class TbGGlobal{
|
||||
@ -1204,6 +1237,38 @@ export class TbGOnHookMap1{
|
||||
|
||||
|
||||
|
||||
export class TbBattleResource{
|
||||
private _dataMap: Map<number, TB.TbBattleResource>
|
||||
private _dataList: TB.TbBattleResource[]
|
||||
constructor(_json_: any) {
|
||||
this._dataMap = new Map<number, TB.TbBattleResource>()
|
||||
this._dataList = []
|
||||
for(var _json2_ of _json_) {
|
||||
let _v: TB.TbBattleResource
|
||||
_v = new TB.TbBattleResource(_json2_)
|
||||
this._dataList.push(_v)
|
||||
this._dataMap.set(_v.id, _v)
|
||||
}
|
||||
}
|
||||
|
||||
getDataMap(): Map<number, TB.TbBattleResource> { return this._dataMap; }
|
||||
getDataList(): TB.TbBattleResource[] { return this._dataList; }
|
||||
|
||||
get(key: number): TB.TbBattleResource | undefined { return this._dataMap.get(key); }
|
||||
|
||||
resolve(tables:Tables)
|
||||
{
|
||||
for(let data of this._dataList)
|
||||
{
|
||||
data.resolve(tables)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
type JsonLoader = (file: string) => any
|
||||
|
||||
export class Tables {
|
||||
@ -1239,6 +1304,8 @@ export class Tables {
|
||||
get TbGOnHookMaps(): TbGOnHookMaps { return this._TbGOnHookMaps;}
|
||||
private _TbGOnHookMap1: TbGOnHookMap1
|
||||
get TbGOnHookMap1(): TbGOnHookMap1 { return this._TbGOnHookMap1;}
|
||||
private _TbBattleResource: TbBattleResource
|
||||
get TbBattleResource(): TbBattleResource { return this._TbBattleResource;}
|
||||
|
||||
constructor(loader: JsonLoader) {
|
||||
this._TbGGlobal = new TbGGlobal(loader('tbgglobal'))
|
||||
@ -1257,6 +1324,7 @@ export class Tables {
|
||||
this._TbGRoleBaseAttribute = new TbGRoleBaseAttribute(loader('tbgrolebaseattribute'))
|
||||
this._TbGOnHookMaps = new TbGOnHookMaps(loader('tbgonhookmaps'))
|
||||
this._TbGOnHookMap1 = new TbGOnHookMap1(loader('tbgonhookmap1'))
|
||||
this._TbBattleResource = new TbBattleResource(loader('tbbattleresource'))
|
||||
|
||||
this._TbGGlobal.resolve(this)
|
||||
this._TbGRole.resolve(this)
|
||||
@ -1274,5 +1342,6 @@ export class Tables {
|
||||
this._TbGRoleBaseAttribute.resolve(this)
|
||||
this._TbGOnHookMaps.resolve(this)
|
||||
this._TbGOnHookMap1.resolve(this)
|
||||
this._TbBattleResource.resolve(this)
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
[]
|
@ -18,13 +18,15 @@ import JLoaderSystem from "../../extensions/ngame/assets/ngame/system/JLoaderSys
|
||||
import { sp } from "cc";
|
||||
import { SpriteFrame } from "cc";
|
||||
import Loading from "../../extensions/ngame/assets/ngame/util/Loading";
|
||||
import { Tables } from "../resources/config/data/schema";
|
||||
import { TB, Tables } from "../resources/config/data/schema";
|
||||
import { JsonAsset } from "cc";
|
||||
import { GAction } from "./consts/GAction";
|
||||
import { StorageData, StorageEnum } from "./consts/GData";
|
||||
import { JAPI, JAPIConfig } from "../../extensions/ngame/assets/ngame/util/JAPI";
|
||||
import { AppData } from "./AppData";
|
||||
import AppAction from "./AppAction";
|
||||
import { Asset } from "cc";
|
||||
import { Component } from "cc";
|
||||
|
||||
// let APIPath = `http://localhost:8080`
|
||||
// let WsPath = `ws://localhost:8080/websocket`
|
||||
@ -144,6 +146,10 @@ export class JLoaderBattle extends JLoaderSystem{
|
||||
static loading = "JLoaderBattle";
|
||||
static loadingInit = "JLoaderBattle_Init";
|
||||
|
||||
//资源
|
||||
resources:{[id:number]:Asset} = {};
|
||||
foreverResources:number[] = []; //永久资源Id
|
||||
|
||||
roleSpine:{[id:number]:sp.SkeletonData} = {}; //角色Spine
|
||||
roleResImage:{[id:number]:SpriteFrame} = {}; //角色战斗素材图片
|
||||
roleResSpine:{[id:number]:sp.SkeletonData} = {}; //角色战斗素材Spine
|
||||
@ -205,6 +211,80 @@ export class JLoaderBattle extends JLoaderSystem{
|
||||
|
||||
}
|
||||
|
||||
//加载永久资源
|
||||
async loadForeverResources(...ress:TB.TbBattleResource[]){
|
||||
|
||||
for (const res of ress) {
|
||||
await this.loadForeverResource(res);
|
||||
}
|
||||
|
||||
}
|
||||
//加载永久资源
|
||||
loadForeverResource(res:TB.TbBattleResource){
|
||||
return (new Promise<void>(r => {
|
||||
this.bundle.load(res.path,(error,data) => {
|
||||
if(this.foreverResources.indexOf(res.id) < 0){
|
||||
//添加永久资源
|
||||
this.resources[res.id] = data;
|
||||
data.addRef();
|
||||
}
|
||||
r();
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
//加载组件资源
|
||||
async loadComponentResource<T extends Asset>(res:TB.TbBattleResource,comp:Component):Promise<T>{
|
||||
return (new Promise<T>(r => {
|
||||
this.bundle.load(res.path,(error,data) => {
|
||||
if(!this.resources[res.id])
|
||||
this.resources[res.id] = data;
|
||||
//添加资源次数
|
||||
data.addRef();
|
||||
//添加销毁资源引用
|
||||
let onDestroy = comp["onDestroy"];
|
||||
comp["onDestroy"] = () => {
|
||||
if(onDestroy)
|
||||
onDestroy.bind(comp)();
|
||||
data.decRef();
|
||||
this.onUpdateResources();
|
||||
}
|
||||
r(data as T);
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
//销毁永久资源
|
||||
clearForeverResources(...ress:TB.TbBattleResource[]){
|
||||
this.foreverResources.forEach(id => {
|
||||
if(this.resources[id]){
|
||||
this.resources[id].decRef();
|
||||
}
|
||||
});
|
||||
this.foreverResources = [];
|
||||
this.onUpdateResources();
|
||||
}
|
||||
|
||||
//更新资源(过滤没有用的资源)
|
||||
onUpdateResources(){
|
||||
for (const key in this.resources) {
|
||||
if (Object.prototype.hasOwnProperty.call(this.resources, key)) {
|
||||
const data = this.resources[key];
|
||||
if(!data.isValid) this.resources[key] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//获取资源
|
||||
getData<T extends Asset>(resId:number):T{
|
||||
|
||||
let res = this.resources[resId]
|
||||
if(!res) console.info(`[JLoaderBattle] 未加载资源${resId}`);
|
||||
|
||||
return res as T;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const app = {
|
||||
|
@ -0,0 +1,55 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
package cfg.TB;
|
||||
|
||||
import luban.*;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
|
||||
public final class TbBattleResource extends AbstractBean {
|
||||
public TbBattleResource(JsonObject _buf) {
|
||||
id = _buf.get("id").getAsInt();
|
||||
path = _buf.get("path").getAsString();
|
||||
type = _buf.get("type").getAsInt();
|
||||
}
|
||||
|
||||
public static TbBattleResource deserialize(JsonObject _buf) {
|
||||
return new cfg.TB.TbBattleResource(_buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
public final int id;
|
||||
/**
|
||||
* 资源路径
|
||||
*/
|
||||
public final String path;
|
||||
/**
|
||||
* 资源类型(0.Spine)
|
||||
*/
|
||||
public final int type;
|
||||
|
||||
public static final int __ID__ = 509266580;
|
||||
|
||||
@Override
|
||||
public int getTypeId() { return __ID__; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{ "
|
||||
+ "(format_field_name __code_style field.name):" + id + ","
|
||||
+ "(format_field_name __code_style field.name):" + path + ","
|
||||
+ "(format_field_name __code_style field.name):" + type + ","
|
||||
+ "}";
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,8 @@ public final class Tables
|
||||
public cfg.TbGOnHookMaps getTbGOnHookMaps() { return _tbgonhookmaps; }
|
||||
private final cfg.TbGOnHookMap1 _tbgonhookmap1;
|
||||
public cfg.TbGOnHookMap1 getTbGOnHookMap1() { return _tbgonhookmap1; }
|
||||
private final cfg.TbBattleResource _tbbattleresource;
|
||||
public cfg.TbBattleResource getTbBattleResource() { return _tbbattleresource; }
|
||||
|
||||
public Tables(IJsonLoader loader) throws java.io.IOException {
|
||||
_tbgglobal = new cfg.TbGGlobal(loader.load("tbgglobal"));
|
||||
@ -69,6 +71,7 @@ public final class Tables
|
||||
_tbgrolebaseattribute = new cfg.TbGRoleBaseAttribute(loader.load("tbgrolebaseattribute"));
|
||||
_tbgonhookmaps = new cfg.TbGOnHookMaps(loader.load("tbgonhookmaps"));
|
||||
_tbgonhookmap1 = new cfg.TbGOnHookMap1(loader.load("tbgonhookmap1"));
|
||||
_tbbattleresource = new cfg.TbBattleResource(loader.load("tbbattleresource"));
|
||||
}
|
||||
}
|
||||
|
||||
|
37
JisolGameServer/Main/src/main/java/cfg/TbBattleResource.java
Normal file
37
JisolGameServer/Main/src/main/java/cfg/TbBattleResource.java
Normal file
@ -0,0 +1,37 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
package cfg;
|
||||
|
||||
import luban.*;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
|
||||
public final class TbBattleResource {
|
||||
private final java.util.HashMap<Integer, cfg.TB.TbBattleResource> _dataMap;
|
||||
private final java.util.ArrayList<cfg.TB.TbBattleResource> _dataList;
|
||||
|
||||
public TbBattleResource(JsonElement _buf) {
|
||||
_dataMap = new java.util.HashMap<Integer, cfg.TB.TbBattleResource>();
|
||||
_dataList = new java.util.ArrayList<cfg.TB.TbBattleResource>();
|
||||
|
||||
for (com.google.gson.JsonElement _e_ : _buf.getAsJsonArray()) {
|
||||
cfg.TB.TbBattleResource _v;
|
||||
_v = cfg.TB.TbBattleResource.deserialize(_e_.getAsJsonObject());
|
||||
_dataList.add(_v);
|
||||
_dataMap.put(_v.id, _v);
|
||||
}
|
||||
}
|
||||
|
||||
public java.util.HashMap<Integer, cfg.TB.TbBattleResource> getDataMap() { return _dataMap; }
|
||||
public java.util.ArrayList<cfg.TB.TbBattleResource> getDataList() { return _dataList; }
|
||||
|
||||
public cfg.TB.TbBattleResource get(int key) { return _dataMap.get(key); }
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
[]
|
Loading…
x
Reference in New Issue
Block a user