局内技能 初步

This commit is contained in:
2024-11-19 16:51:40 +08:00
parent 968dbdcc04
commit d930cb1b81
18 changed files with 966 additions and 1331 deletions

View File

@@ -1,7 +1,7 @@
[
{
"__type__": "cc.Prefab",
"_name": "cskill",
"_name": "mskill",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
@@ -13,7 +13,7 @@
},
{
"__type__": "cc.Node",
"_name": "cskill",
"_name": "mskill",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
@@ -22,70 +22,26 @@
"__id__": 2
},
{
"__id__": 10
"__id__": 8
}
],
"_active": true,
"_components": [
{
"__id__": 14
},
{
"__id__": 16
}
],
"_prefab": {
},
{
"__id__": 18
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 0.5,
"y": 0.5,
"z": 1
},
"_mobility": 0,
"_layer": 1,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "skill",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
},
{
"__id__": 5
},
{
"__id__": 7
"__id__": 20
}
],
"_prefab": {
"__id__": 9
"__id__": 22
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -107,7 +63,57 @@
"z": 1
},
"_mobility": 0,
"_layer": 1,
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "icon",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
},
{
"__id__": 5
}
],
"_prefab": {
"__id__": 7
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
@@ -130,8 +136,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 102,
"height": 106
"width": 72,
"height": 75
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -142,7 +148,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "b5fEMhH0dKibjzzPHF0aOs"
"fileId": "7aXcN081JI2alKGYRKpfpV"
},
{
"__type__": "cc.Sprite",
@@ -172,7 +178,7 @@
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
"_sizeMode": 1,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
@@ -187,36 +193,7 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "b3BlM2kPhHS6sICuwzYueB"
},
{
"__type__": "cc.Animation",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 8
},
"playOnLoad": true,
"_clips": [
{
"__uuid__": "2be0841b-b660-40c6-a0d9-fa346b8d4a83",
"__expectedType__": "cc.AnimationClip"
}
],
"_defaultClip": {
"__uuid__": "2be0841b-b660-40c6-a0d9-fa346b8d4a83",
"__expectedType__": "cc.AnimationClip"
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "a0BzbhYAROvZlvm0xYALvJ"
"fileId": "9cs0MQwGRJl4svNJK/f2/x"
},
{
"__type__": "cc.PrefabInfo",
@@ -226,14 +203,14 @@
"asset": {
"__id__": 0
},
"fileId": "1ecYrrQP9HyoMDN+sneaND",
"fileId": "a0hwtaZtFLSrxUJFKE6ij0",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_name": "time",
"_name": "cd",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
@@ -243,27 +220,27 @@
"_active": true,
"_components": [
{
"__id__": 11
"__id__": 9
},
{
"__id__": 13
"__id__": 11
}
],
"_prefab": {
"__id__": 15
"__id__": 13
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": -54.944,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
"z": 0.7071067811865475,
"w": 0.7071067811865476
},
"_lscale": {
"__type__": "cc.Vec3",
@@ -272,12 +249,12 @@
"z": 1
},
"_mobility": 0,
"_layer": 1,
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
"z": 90
},
"_id": ""
},
@@ -287,16 +264,16 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 10
"__id__": 8
},
"_enabled": true,
"__prefab": {
"__id__": 12
"__id__": 10
},
"_contentSize": {
"__type__": "cc.Size",
"width": 26.24609375,
"height": 54.4
"width": 89,
"height": 90
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -307,19 +284,19 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "464TV9SztO6YISNtFhpsHF"
"fileId": "29HRVP3rlJjJN03KS/Qaj3"
},
{
"__type__": "cc.Label",
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 10
"__id__": 8
},
"_enabled": true,
"__prefab": {
"__id__": 14
"__id__": 12
},
"_customMaterial": null,
"_srcBlendFactor": 2,
@@ -329,53 +306,30 @@
"r": 255,
"g": 255,
"b": 255,
"a": 255
"a": 105
},
"_string": "5",
"_horizontalAlign": 1,
"_verticalAlign": 1,
"_actualFontSize": 40,
"_fontSize": 40,
"_fontFamily": "Arial",
"_lineHeight": 40,
"_overflow": 0,
"_enableWrapText": true,
"_font": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_isItalic": false,
"_isBold": false,
"_isUnderline": false,
"_underlineHeight": 2,
"_cacheMode": 0,
"_enableOutline": true,
"_outlineColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
"_spriteFrame": {
"__uuid__": "f87f53f9-2fba-4a5b-968a-79a593311ab2@cec89",
"__expectedType__": "cc.SpriteFrame"
},
"_outlineWidth": 2,
"_enableShadow": false,
"_shadowColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_shadowOffset": {
"_type": 3,
"_fillType": 2,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 2,
"y": 2
"x": 0.5,
"y": 0.5
},
"_shadowBlur": 2,
"_fillStart": 0,
"_fillRange": 1,
"_isTrimmedMode": true,
"_useGrayscale": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "d0RRL1Gp9M0qu6XX+NQUIS"
"fileId": "93Ul1oQ+xIiZpg+gxedB+D"
},
{
"__type__": "cc.PrefabInfo",
@@ -385,7 +339,7 @@
"asset": {
"__id__": 0
},
"fileId": "e68MLVqX9HUIHPwQY/ofCT",
"fileId": "75g2fW6exDe5hMWN7UMZ33",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
@@ -398,14 +352,14 @@
"node": {
"__id__": 1
},
"_enabled": false,
"_enabled": true,
"__prefab": {
"__id__": 17
"__id__": 15
},
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"height": 100
"width": 90,
"height": 90
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -416,7 +370,92 @@
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "14OhXRCixNOaApgow/hFbp"
"fileId": "84Ard7qDdFL7OPr15j/5zB"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 17
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 250,
"g": 0,
"b": 0,
"a": 255
},
"_spriteFrame": null,
"_type": 1,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "acXHR6iZtAP7pxuZwEfHv8"
},
{
"__type__": "cc.ProgressBar",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 19
},
"_barSprite": {
"__id__": 11
},
"_mode": 2,
"_totalLength": 1,
"_progress": 1,
"_reverse": false,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "a8E/M8cZNMh7zmcVGsBXx9"
},
{
"__type__": "87082d0X2RDEq1y6hJbSlgm",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 21
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "26mc6tdD1FK4ibdzSJrtik"
},
{
"__type__": "cc.PrefabInfo",
@@ -426,7 +465,7 @@
"asset": {
"__id__": 0
},
"fileId": "fdklpBwCBM/qJ4WFlQF3kT",
"fileId": "75xfkWpURP0b3lC6f/G9hT",
"instance": null,
"targetOverrides": null
}

View File

@@ -2,12 +2,12 @@
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "78c5dfd6-2154-4fe3-b7ff-506decefde37",
"uuid": "9ebd334d-ddc9-4c34-8997-bb10152b1061",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "cskill"
"syncNodeName": "mskill"
}
}

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -1140,7 +1140,7 @@
"_color": {
"__type__": "cc.Color",
"r": 231,
"g": 139,
"g": 22,
"b": 22,
"a": 255
},
@@ -1164,12 +1164,12 @@
"_enableOutline": true,
"_outlineColor": {
"__type__": "cc.Color",
"r": 244,
"r": 250,
"g": 255,
"b": 122,
"b": 128,
"a": 255
},
"_outlineWidth": 7,
"_outlineWidth": 5,
"_enableShadow": false,
"_shadowColor": {
"__type__": "cc.Color",

File diff suppressed because it is too large Load Diff

View File

@@ -64,7 +64,9 @@ export const SkillSet={
8001:{uuid: 8001,path: "8001",type: 1,tg:3,angle:true,level: 1,name: "飞刀",sp_name:"sword1",info:"释放一个魔法球攻击敌人",
dis:1,count:1,in:0,run:0,ap:0,hp:0,shield:0,sd:0,cd:0,bsd:0,bcd:0,sk_uuid:8001,sk_count:0,speed:600,},
}
export const CSkills={
1001:{uuid: 1001,path: "1001",type: 1,tg:3,angle:true,level: 1,name: "火球术",sp_name:"fire",info:"释放一个火球术攻击敌人",
dis:1,count:1,in:0,run:0,ap:10,hp:0,shield:0,sd:10,cd:3,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:600, },
}

View File

@@ -24,6 +24,7 @@ import { BossList, MissionNum, MonsetList } from "../common/config/MissionSet";
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
import { HCard } from "./HCard";
import { HCardComp } from "./HCardComp";
import { MSkill } from "../skills/MSkill";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@@ -97,6 +98,7 @@ export class MissionComp extends CCComp {
// this.shuaxin(dt)
}
mission_start(){
/* todo 关卡设定完善*/
this.total=smc.vm_data.mission.m_less=smc.vm_data.mission.m_alive=smc.vm_data.mission.total;
this.hero_total=2
let num =RandomManager.instance.getRandomByObjectList(MissionNum,1)
@@ -116,6 +118,12 @@ export class MissionComp extends CCComp {
smc.vm_data.mission.mb_exp=0 //敌方远程经验石
smc.vm_data.mission.mc_exp=0 //敌方辅助经验石
smc.vm_data.mission.md_exp=0 //敌方特殊经验石
this.call_mskill()
}
call_mskill(){
let msk=ecs.getEntity<MSkill>(MSkill)
let praent = this.node.getChildByName("exp").getChildByName("a_exp").getChildByName("skill")
msk.load(1001,1,praent)
}
mission_end(){
smc.vm_data.mission.play=false

View File

@@ -1,100 +0,0 @@
import { Prefab,instantiate,Vec3,v3 ,SpriteAtlas,resources,Sprite,Node} from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CSkillComp } from "./CSkillComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { smc } from "../common/SingletonModuleComp";
import { SkillSet } from "../common/config/SkillSet";
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
/** CSkill 模块 */
@ecs.register(`CSkill`)
export class CSkill extends ecs.Entity {
CSkillView!: CSkillComp;
/** 实始添加的数据层组件 */
protected init() {
}
/** 模块资源释放 */
destroy() {
this.remove(CSkillComp);
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
super.destroy();
}
start(){
}
/** 加载角色 */
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001) {
// var path = "game/monster/"+prefab_path;
// console.log("load skill",this)
var path = "game/heros/cskill";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
var scene = smc.map.MapView.scene;
node.parent = scene.entityLayer!.node!;
node.getChildByName("skill").setScale(node.getChildByName("skill").scale.x*scale, node.getChildByName("skill").scale.y, node.getChildByName("skill").scale.z);
// let cskills = ecs.query(ecs.allOf(CSkillComp))
if(SkillSet[uuid].type >= 90){
pos = this.add_buff()
}else{
pos = this.add_skill()
}
// console.log("load skill",pos,smc.player_buffs)
node.setPosition(pos.x*scale,pos.y,pos.z)
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
const url = 'game/heros/skill';
resources.load(url, SpriteAtlas, (err: any, atlas) => {
const sprite = node.getChildByName("skill").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(smc.skills[uuid].path);
});
this.skill_init(uuid,node,pos)
oops.message.dispatchEvent("cskill_load",this)
}
add_buff(){
let pos = v3(0,0,0)
for (let index = 0; index < 4; index++) {
if(smc.player_buffs[index].eid == 0){
pos.x=smc.player_buffs[index].x
pos.y=smc.player_buffs[index].y
smc.player_buffs[index].eid=this.eid
break
}
}
return pos
}
add_skill(){
let pos = v3(0,0,0)
for (let index = 4; index < 8; index++) {
if(smc.player_buffs[index].eid == 0){
pos.x=smc.player_buffs[index].x
pos.y=smc.player_buffs[index].y
smc.player_buffs[index].eid=this.eid
break
}
}
return pos
}
skill_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
var mv = node.getComponent(CSkillComp)
mv.scale = 1;
mv.skill_uuid = uuid;
mv.atk=smc.skills[uuid].atk;
this.add(mv);
}
}
/** CSkill 模块业务逻辑系统组件,如无业务逻辑处理可删除此对象 */
export class EcsCSkillSystem extends ecs.System {
constructor() {
super();
// this.add(new ecs.ComblockSystem());
}
}

View File

@@ -1,169 +0,0 @@
import { _decorator,v3,Vec3 ,Label} from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
import { Skill } from "../skills/Skill";
import { SkillSet } from "../common/config/SkillSet";
import { BoxSet, GameSet } from "../common/config/BoxSet";
import { smc } from "../common/SingletonModuleComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
import { MonModelComp } from "../mon/MonModelComp";
import { HeroModelComp } from "../hero/HeroModelComp";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('CSkillComp')
@ecs.register('CSkill', false)
export class CSkillComp extends CCComp {
//持续时间
private sd:Timer = new Timer(5)
private cd:Timer = new Timer(1)
private is_destroy:boolean = false;
time:number = 0;
scale:number = 1;
speed:number = 0;
dis:number = 0;
atk:number = 0;
skill_uuid:number = 1001;
/** 视图层逻辑代码分离演示 */
start() {
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
this.sd =new Timer(smc.skills[this.skill_uuid].sd)
this.cd = new Timer(smc.skills[this.skill_uuid].cd)
this.time =smc.skills[this.skill_uuid].sd
this.node.getChildByName("time").getComponent(Label).string = this.time.toString()
}
protected update(dt: number): void {
if (this.sd.update(dt)) {
if (this.is_destroy) {
return
}
this.to_destroy()
}
if (this.cd.update(dt)) {
this.time -=1
this.node.getChildByName("time").getComponent(Label).string = this.time.toString()
if(smc.skills[this.skill_uuid].type == 1){
this.shoot()
}
if(smc.skills[this.skill_uuid].type > 90){
this.add_buff()
}
}
}
shoot() {
let skill = ecs.getEntity<Skill>(Skill);
let pos = v3(0,0)
let t_pos = v3(0,0)
let angle = 0
let m_pos=v3(0,0)
let monsters:any = ecs.query(ecs.allOf(MonModelComp));
if (monsters.length > 0) {
m_pos = monsters[0].MonView.node.position
}else{
m_pos = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE)
}
t_pos = v3(m_pos.x-this.node.position.x,m_pos.y-this.node.position.y) // 目标增量
let dx=m_pos.x-this.node.position.x
let dy=m_pos.y-this.node.position.y
let dir=v3(dx,dy,0)
let randian=Math.atan2(dir.y,dir.x)
angle = randian * (180 / Math.PI);
let scale = this.scale
let atk = smc.skills[this.skill_uuid].atk+this.atk;
skill.load(pos,scale,this.node,this.skill_uuid,atk,t_pos);
}
add_buff(){
// 1 远距离攻击,碰撞后 结束
// 2 远距离攻击,碰撞后 持续,直到技能结束
// 3 远距离攻击,碰撞后 持续,带击退功能
// 4 双技能技能1技能结束后触发2技能
// 5: 特殊技能,触发特殊弹窗选项
// 9 buff物品
// 91: 单体buff物品加最少血临时
// 92单体buff物品随机临时
// 93: 群体buff物品
// 94role 临时buff
// 95role 永久buff
let uuid= this.skill_uuid;
let atk:number=0
let args:any = {
atk:atk*GameSet.ATK_TO_ATK_RATIO,
hp:atk*GameSet.ATK_TO_HP_RATIO,
shield:atk*GameSet.ATK_TO_SHIELD_RATIO,
}
let heros:any = ecs.query(ecs.allOf(HeroModelComp));
let least_hp:number=999999
let t_hero:any= null
if (heros.length > 0) {
if(SkillSet[uuid].type==92){ //随机添加buff
let i = RandomManager.instance.getRandomInt(0,heros.length-1,3)
this.do_add_buff(heros[i],uuid,args)
}else{
for (let i = 0; i < heros.length; i++) {
let hero = heros[i];
if(SkillSet[uuid].type==91){ //血量最少单体
if(hero.HeroView.hp < least_hp){
least_hp = hero.HeroView.hp
t_hero = hero
}
}else{ //群体
this.do_add_buff(hero,uuid,args)
}
}
if(t_hero){ //血量最少单体
this.do_add_buff(t_hero,uuid,args)
}
}
}
// oops.message.dispatchEvent("add_buff",{uuid:this.skill_uuid,eid:0,group:BoxSet.HERO})
}
do_add_buff(target:any,uuid:number,args:any) {
let buff = SkillSet[uuid]
if(buff.hp > 0 ){
target.HeroView.add_hp(buff.hp+args.hp)
}
if(buff.atk > 0 ){
target.HeroView.add_atk(buff.atk+args.atk,buff.bsd)
}
if(buff.shield > 0 ){
target.HeroView.add_shield(buff.shield+args.shield,buff.bsd)
}
}
/** 全局消息逻辑处理 */
// private onHandler(event: string, args: any) {
// switch (event) {
// case ModuleEvent.Cmd:
// break;
// }
// }
to_destroy() {
this.is_destroy = true
this.remove_buff()
if (this.node.isValid) {
this.ent.destroy()
}
}
remove_buff(){
for (let index = 0; index < 8; index++) {
if(smc.player_buffs[index].eid == this.ent.eid){
smc.player_buffs[index].eid=0
break
}
}
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.sd.reset()
this.cd.reset()
this.node.destroy();
}
}

View File

@@ -0,0 +1,30 @@
import { instantiate, Prefab } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { MSkillComp } from "./MSkillComp";
/** MSkill 模块 */
@ecs.register(`MSkill`)
export class MSkill extends ecs.Entity {
/** 实始添加的数据层组件 */
protected init() {
// this.addComponents<ecs.Comp>();
}
load(uuid:number=1001,index:number=-1,parent:any) {
let box_group= 0
var path = "game/skills/mskill";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
node.parent = parent
var msc = node.getComponent(MSkillComp)!;
this.add(msc)
}
/** 模块资源释放 */
destroy() {
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
super.destroy();
}
}

View File

@@ -2,7 +2,7 @@
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "b8d6919d-0a2d-41eb-8c10-5ea684508f48",
"uuid": "10489fd2-88db-4945-a7b2-b9f26aaceab2",
"files": [],
"subMetas": {},
"userData": {}

View File

@@ -0,0 +1,24 @@
import { _decorator } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('MSkillComp')
@ecs.register('MSkillComp', false)
export class MSkillComp extends CCComp {
/** 视图层逻辑代码分离演示 */
start() {
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
// this.on(ModuleEvent.Cmd, this.onHandler, this);
console.log("MSkillComp start");
}
/** 全局消息逻辑处理 */
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}

View File

@@ -2,7 +2,7 @@
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "80aaeefe-a9d9-42da-8086-62a77b582046",
"uuid": "87082774-5f64-4312-ad72-ea125b4a5826",
"files": [],
"subMetas": {},
"userData": {}