使用ecs系统进行重构
This commit is contained in:
9
assets/script/game/hero/Aheros.meta
Normal file
9
assets/script/game/hero/Aheros.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "29b69aa0-d30f-47bf-adb0-1c761bf4bec8",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
14
assets/script/game/hero/Aheros/BaseComp.ts
Normal file
14
assets/script/game/hero/Aheros/BaseComp.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('BaseComp')
|
||||
export class BaseComp extends Component {
|
||||
start() {
|
||||
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
9
assets/script/game/hero/Aheros/BaseComp.ts.meta
Normal file
9
assets/script/game/hero/Aheros/BaseComp.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "0a844c8e-978a-4c93-99ed-f4e6a7d53286",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
34
assets/script/game/hero/Aheros/Module.ts
Normal file
34
assets/script/game/hero/Aheros/Module.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
|
||||
/** Module 模块 */
|
||||
@ecs.register(`Module`)
|
||||
export class Module extends ecs.Entity {
|
||||
/** ---------- 数据层 ---------- */
|
||||
// ModuleModel!: ModuleModelComp;
|
||||
|
||||
/** ---------- 业务层 ---------- */
|
||||
// ModuleBll!: ModuleBllComp;
|
||||
|
||||
/** ---------- 视图层 ---------- */
|
||||
// ModuleView!: ModuleViewComp;
|
||||
|
||||
/** 实始添加的数据层组件 */
|
||||
protected init() {
|
||||
// this.addComponents<ecs.Comp>();
|
||||
}
|
||||
|
||||
/** 模块资源释放 */
|
||||
destroy() {
|
||||
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
/** Module 模块业务逻辑系统组件,如无业务逻辑处理可删除此对象 */
|
||||
export class EcsModuleSystem extends ecs.System {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
// this.add(new ecs.ComblockSystem());
|
||||
}
|
||||
}
|
||||
9
assets/script/game/hero/Aheros/Module.ts.meta
Normal file
9
assets/script/game/hero/Aheros/Module.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "013c01e2-3700-446a-824e-074584d7787b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -21,19 +21,14 @@ export class Hero extends ecs.Entity {
|
||||
HeroModel!: HeroModelComp;
|
||||
// 视图层
|
||||
HeroView!: HeroViewComp;
|
||||
|
||||
|
||||
protected init() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
this.remove(HeroViewComp);
|
||||
this.remove(MoveToComp);
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
/** 加载角色 */
|
||||
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,is_call:boolean=false,lv:number=1) {
|
||||
scale = 1
|
||||
@@ -50,7 +45,6 @@ export class Hero extends ecs.Entity {
|
||||
this.hero_init(uuid,node,scale,box_group,is_call,lv)
|
||||
oops.message.dispatchEvent("hero_load",this)
|
||||
}
|
||||
|
||||
hero_init(uuid:number=1001,node:Node,scale:number=1,box_group=BoxSet.HERO,is_call:boolean=false,lv:number=1){
|
||||
var hv = node.getComponent(HeroViewComp)!;
|
||||
// console.log("hero_init",buff)
|
||||
@@ -81,50 +75,38 @@ export class Hero extends ecs.Entity {
|
||||
let sklv=slv
|
||||
if(sklv >= 5) sklv=5;
|
||||
|
||||
hv.sk1 = hero.sk1[sklv];
|
||||
hv.sk2 = hero.sk2[sklv];
|
||||
hv.sk3 = hero.sk3[sklv];
|
||||
hv.akc = hero.akc[sklv];
|
||||
hv.uac = hero.uac[sklv];
|
||||
hv.crc = hero.crc[sklv];
|
||||
hv.dgc = hero.dgc[sklv];
|
||||
hv.akr = hero.akr[sklv];
|
||||
hv.uar = hero.uar[sklv];
|
||||
hv.crr = hero.crr[sklv];
|
||||
hv.dgr = hero.dgr[sklv];
|
||||
hv.rhp_max=hv.hp= hv.hp_max =(hero.hp+hero.hp_up*hv.lv)*(1+hero.shp_up/100*slv) ;
|
||||
hv.sk1 = hero.sk1[sklv]
|
||||
hv.sk2 = hero.sk2[sklv]
|
||||
hv.sk3 = hero.sk3[sklv]
|
||||
hv.akc = hero.akc[sklv]
|
||||
hv.uac = hero.uac[sklv]
|
||||
hv.crc = hero.crc[sklv]
|
||||
hv.dgc = hero.dgc[sklv]
|
||||
hv.akr = hero.akr[sklv]
|
||||
hv.uar = hero.uar[sklv]
|
||||
hv.crr = hero.crr[sklv]
|
||||
hv.dgr = hero.dgr[sklv]
|
||||
hv.rhp_max=hv.hp= hv.hp_max =(hero.hp+hero.hp_up*hv.lv)*(1+hero.shp_up/100*slv)
|
||||
hv.ap = (hero.ap+hero.ap_up*hv.lv) *(1+hero.sap_up/100*slv);
|
||||
hv.def= (hero.def+hero.def_up*hv.lv)*(1+hero.sdef_up/100*slv);
|
||||
hv.cd = hero.a_cd
|
||||
hv.crit = hero.crit; //暴击率
|
||||
hv.crit = hero.crit //暴击率
|
||||
hv.crit_add = hero.crit_add;//暴击伤害加成
|
||||
hv.dodge = hero.dodge; //闪避率
|
||||
hv.aexp=hero.aexp;
|
||||
hv.uaexp=hero.uaexp;
|
||||
hv.dodge = hero.dodge //闪避率
|
||||
hv.aexp=hero.aexp
|
||||
hv.uaexp=hero.uaexp
|
||||
hv.cexp=hero.cexp
|
||||
hv.doexp=hero.doexp
|
||||
hv.dexp=hero.dexp;
|
||||
|
||||
hv.dexp=hero.dexp
|
||||
this.add(hv);
|
||||
}
|
||||
set_ratio(uuid:number){
|
||||
let ratio=1;
|
||||
switch (HeroInfo[uuid].level) {
|
||||
case 2:
|
||||
ratio=1.05
|
||||
break;
|
||||
case 3:
|
||||
ratio=1.1
|
||||
break;
|
||||
case 4:
|
||||
ratio=1.15
|
||||
break;
|
||||
case 5:
|
||||
ratio=1.2
|
||||
break;
|
||||
default:
|
||||
ratio=1
|
||||
}
|
||||
return ratio;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Module 模块业务逻辑系统组件,如无业务逻辑处理可删除此对象 */
|
||||
export class EcsModuleSystem extends ecs.System {
|
||||
constructor() {
|
||||
super();
|
||||
// this.add(new ecs.ComblockSystem());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user