diff --git a/assets/resources/game/heros/ha1.prefab b/assets/resources/game/heros/ha1.prefab index 694e3290..8075ad27 100644 --- a/assets/resources/game/heros/ha1.prefab +++ b/assets/resources/game/heros/ha1.prefab @@ -56,13 +56,10 @@ }, { "__id__": 65 - }, - { - "__id__": 67 } ], "_prefab": { - "__id__": 69 + "__id__": 67 }, "_lpos": { "__type__": "cc.Vec3", @@ -958,24 +955,6 @@ "__type__": "cc.CompPrefabInfo", "fileId": "ae2ywFEqlJ26Sq7z7AtGgk" }, - { - "__type__": "7eb34NR6XVEf78HCi5eAKLm", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 1 - }, - "_enabled": true, - "__prefab": { - "__id__": 60 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "654wWWbWpMeYe/ywRBGTMP" - }, { "__type__": "cc.RigidBody2D", "_name": "", @@ -986,7 +965,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 62 + "__id__": 60 }, "enabledContactListener": true, "bullet": false, @@ -1020,7 +999,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 64 + "__id__": 62 }, "tag": 0, "_group": 4, @@ -1054,7 +1033,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 66 + "__id__": 64 }, "_id": "" }, @@ -1072,7 +1051,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 68 + "__id__": 66 }, "_id": "" }, diff --git a/assets/resources/game/heros/hc1.prefab b/assets/resources/game/heros/hc1.prefab index 52e8e9b6..a5e30bde 100644 --- a/assets/resources/game/heros/hc1.prefab +++ b/assets/resources/game/heros/hc1.prefab @@ -56,13 +56,10 @@ }, { "__id__": 65 - }, - { - "__id__": 67 } ], "_prefab": { - "__id__": 69 + "__id__": 67 }, "_lpos": { "__type__": "cc.Vec3", @@ -958,24 +955,6 @@ "__type__": "cc.CompPrefabInfo", "fileId": "ae2ywFEqlJ26Sq7z7AtGgk" }, - { - "__type__": "7eb34NR6XVEf78HCi5eAKLm", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 1 - }, - "_enabled": true, - "__prefab": { - "__id__": 60 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "654wWWbWpMeYe/ywRBGTMP" - }, { "__type__": "cc.RigidBody2D", "_name": "", @@ -986,7 +965,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 62 + "__id__": 60 }, "enabledContactListener": true, "bullet": false, @@ -1020,7 +999,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 64 + "__id__": 62 }, "tag": 0, "_group": 4, @@ -1054,7 +1033,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 66 + "__id__": 64 }, "_id": "" }, @@ -1072,7 +1051,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 68 + "__id__": 66 }, "_id": "" }, diff --git a/assets/resources/game/heros/hh1.prefab b/assets/resources/game/heros/hh1.prefab index 10bb7d6f..8ab036db 100644 --- a/assets/resources/game/heros/hh1.prefab +++ b/assets/resources/game/heros/hh1.prefab @@ -56,13 +56,10 @@ }, { "__id__": 65 - }, - { - "__id__": 67 } ], "_prefab": { - "__id__": 69 + "__id__": 67 }, "_lpos": { "__type__": "cc.Vec3", @@ -958,24 +955,6 @@ "__type__": "cc.CompPrefabInfo", "fileId": "ae2ywFEqlJ26Sq7z7AtGgk" }, - { - "__type__": "7eb34NR6XVEf78HCi5eAKLm", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 1 - }, - "_enabled": true, - "__prefab": { - "__id__": 60 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "654wWWbWpMeYe/ywRBGTMP" - }, { "__type__": "cc.RigidBody2D", "_name": "", @@ -986,7 +965,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 62 + "__id__": 60 }, "enabledContactListener": true, "bullet": false, @@ -1020,7 +999,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 64 + "__id__": 62 }, "tag": 0, "_group": 4, @@ -1054,7 +1033,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 66 + "__id__": 64 }, "_id": "" }, @@ -1072,7 +1051,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 68 + "__id__": 66 }, "_id": "" }, diff --git a/assets/resources/game/heros/hk1.prefab b/assets/resources/game/heros/hk1.prefab index c372c991..89c33425 100644 --- a/assets/resources/game/heros/hk1.prefab +++ b/assets/resources/game/heros/hk1.prefab @@ -56,13 +56,10 @@ }, { "__id__": 65 - }, - { - "__id__": 67 } ], "_prefab": { - "__id__": 69 + "__id__": 67 }, "_lpos": { "__type__": "cc.Vec3", @@ -958,24 +955,6 @@ "__type__": "cc.CompPrefabInfo", "fileId": "ae2ywFEqlJ26Sq7z7AtGgk" }, - { - "__type__": "7eb34NR6XVEf78HCi5eAKLm", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 1 - }, - "_enabled": true, - "__prefab": { - "__id__": 60 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "654wWWbWpMeYe/ywRBGTMP" - }, { "__type__": "cc.RigidBody2D", "_name": "", @@ -986,7 +965,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 62 + "__id__": 60 }, "enabledContactListener": true, "bullet": false, @@ -1020,7 +999,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 64 + "__id__": 62 }, "tag": 0, "_group": 4, @@ -1054,7 +1033,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 66 + "__id__": 64 }, "_id": "" }, @@ -1072,7 +1051,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 68 + "__id__": 66 }, "_id": "" }, diff --git a/assets/resources/game/heros/hm1.prefab b/assets/resources/game/heros/hm1.prefab index c3e71aa9..0414a9ce 100644 --- a/assets/resources/game/heros/hm1.prefab +++ b/assets/resources/game/heros/hm1.prefab @@ -56,13 +56,10 @@ }, { "__id__": 65 - }, - { - "__id__": 67 } ], "_prefab": { - "__id__": 69 + "__id__": 67 }, "_lpos": { "__type__": "cc.Vec3", @@ -958,24 +955,6 @@ "__type__": "cc.CompPrefabInfo", "fileId": "ae2ywFEqlJ26Sq7z7AtGgk" }, - { - "__type__": "7eb34NR6XVEf78HCi5eAKLm", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 1 - }, - "_enabled": true, - "__prefab": { - "__id__": 60 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "654wWWbWpMeYe/ywRBGTMP" - }, { "__type__": "cc.RigidBody2D", "_name": "", @@ -986,7 +965,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 62 + "__id__": 60 }, "enabledContactListener": true, "bullet": false, @@ -1020,7 +999,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 64 + "__id__": 62 }, "tag": 0, "_group": 4, @@ -1054,7 +1033,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 66 + "__id__": 64 }, "_id": "" }, @@ -1072,7 +1051,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 68 + "__id__": 66 }, "_id": "" }, diff --git a/assets/resources/game/heros/hm2.prefab b/assets/resources/game/heros/hm2.prefab index 1536f2af..91ba1610 100644 --- a/assets/resources/game/heros/hm2.prefab +++ b/assets/resources/game/heros/hm2.prefab @@ -56,13 +56,10 @@ }, { "__id__": 65 - }, - { - "__id__": 67 } ], "_prefab": { - "__id__": 69 + "__id__": 67 }, "_lpos": { "__type__": "cc.Vec3", @@ -958,24 +955,6 @@ "__type__": "cc.CompPrefabInfo", "fileId": "ae2ywFEqlJ26Sq7z7AtGgk" }, - { - "__type__": "7eb34NR6XVEf78HCi5eAKLm", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 1 - }, - "_enabled": true, - "__prefab": { - "__id__": 60 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "654wWWbWpMeYe/ywRBGTMP" - }, { "__type__": "cc.RigidBody2D", "_name": "", @@ -986,7 +965,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 62 + "__id__": 60 }, "enabledContactListener": true, "bullet": false, @@ -1020,7 +999,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 64 + "__id__": 62 }, "tag": 0, "_group": 4, @@ -1054,7 +1033,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 66 + "__id__": 64 }, "_id": "" }, @@ -1072,7 +1051,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 68 + "__id__": 66 }, "_id": "" }, diff --git a/assets/resources/game/heros/hz1.prefab b/assets/resources/game/heros/hz1.prefab index ffecaaa2..deb1a4fe 100644 --- a/assets/resources/game/heros/hz1.prefab +++ b/assets/resources/game/heros/hz1.prefab @@ -56,13 +56,10 @@ }, { "__id__": 65 - }, - { - "__id__": 67 } ], "_prefab": { - "__id__": 69 + "__id__": 67 }, "_lpos": { "__type__": "cc.Vec3", @@ -958,24 +955,6 @@ "__type__": "cc.CompPrefabInfo", "fileId": "ae2ywFEqlJ26Sq7z7AtGgk" }, - { - "__type__": "7eb34NR6XVEf78HCi5eAKLm", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 1 - }, - "_enabled": true, - "__prefab": { - "__id__": 60 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "654wWWbWpMeYe/ywRBGTMP" - }, { "__type__": "cc.RigidBody2D", "_name": "", @@ -986,7 +965,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 62 + "__id__": 60 }, "enabledContactListener": true, "bullet": false, @@ -1020,7 +999,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 64 + "__id__": 62 }, "tag": 0, "_group": 4, @@ -1054,7 +1033,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 66 + "__id__": 64 }, "_id": "" }, @@ -1072,7 +1051,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 68 + "__id__": 66 }, "_id": "" }, diff --git a/assets/resources/game/heros/mo1.prefab b/assets/resources/game/heros/mo1.prefab index e803a559..2ca8a4f5 100644 --- a/assets/resources/game/heros/mo1.prefab +++ b/assets/resources/game/heros/mo1.prefab @@ -56,13 +56,10 @@ }, { "__id__": 65 - }, - { - "__id__": 67 } ], "_prefab": { - "__id__": 69 + "__id__": 67 }, "_lpos": { "__type__": "cc.Vec3", @@ -955,24 +952,6 @@ "__type__": "cc.CompPrefabInfo", "fileId": "ae2ywFEqlJ26Sq7z7AtGgk" }, - { - "__type__": "7eb34NR6XVEf78HCi5eAKLm", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 1 - }, - "_enabled": true, - "__prefab": { - "__id__": 60 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "654wWWbWpMeYe/ywRBGTMP" - }, { "__type__": "cc.RigidBody2D", "_name": "", @@ -983,7 +962,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 62 + "__id__": 60 }, "enabledContactListener": true, "bullet": false, @@ -1017,7 +996,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 64 + "__id__": 62 }, "tag": 0, "_group": 4, @@ -1051,7 +1030,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 66 + "__id__": 64 }, "_id": "" }, @@ -1069,7 +1048,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 68 + "__id__": 66 }, "_id": "" }, diff --git a/assets/resources/game/heros/mo2.prefab b/assets/resources/game/heros/mo2.prefab index a928057a..e776a54d 100644 --- a/assets/resources/game/heros/mo2.prefab +++ b/assets/resources/game/heros/mo2.prefab @@ -56,13 +56,10 @@ }, { "__id__": 65 - }, - { - "__id__": 67 } ], "_prefab": { - "__id__": 69 + "__id__": 67 }, "_lpos": { "__type__": "cc.Vec3", @@ -958,24 +955,6 @@ "__type__": "cc.CompPrefabInfo", "fileId": "ae2ywFEqlJ26Sq7z7AtGgk" }, - { - "__type__": "7eb34NR6XVEf78HCi5eAKLm", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 1 - }, - "_enabled": true, - "__prefab": { - "__id__": 60 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "654wWWbWpMeYe/ywRBGTMP" - }, { "__type__": "cc.RigidBody2D", "_name": "", @@ -986,7 +965,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 62 + "__id__": 60 }, "enabledContactListener": true, "bullet": false, @@ -1020,7 +999,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 64 + "__id__": 62 }, "tag": 0, "_group": 4, @@ -1054,7 +1033,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 66 + "__id__": 64 }, "_id": "" }, @@ -1072,7 +1051,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 68 + "__id__": 66 }, "_id": "" }, diff --git a/assets/resources/game/heros/mo3.prefab b/assets/resources/game/heros/mo3.prefab index 7f41db01..a39801bd 100644 --- a/assets/resources/game/heros/mo3.prefab +++ b/assets/resources/game/heros/mo3.prefab @@ -56,13 +56,10 @@ }, { "__id__": 65 - }, - { - "__id__": 67 } ], "_prefab": { - "__id__": 69 + "__id__": 67 }, "_lpos": { "__type__": "cc.Vec3", @@ -958,24 +955,6 @@ "__type__": "cc.CompPrefabInfo", "fileId": "ae2ywFEqlJ26Sq7z7AtGgk" }, - { - "__type__": "7eb34NR6XVEf78HCi5eAKLm", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 1 - }, - "_enabled": true, - "__prefab": { - "__id__": 60 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "654wWWbWpMeYe/ywRBGTMP" - }, { "__type__": "cc.RigidBody2D", "_name": "", @@ -986,7 +965,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 62 + "__id__": 60 }, "enabledContactListener": true, "bullet": false, @@ -1020,7 +999,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 64 + "__id__": 62 }, "tag": 0, "_group": 4, @@ -1054,7 +1033,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 66 + "__id__": 64 }, "_id": "" }, @@ -1072,7 +1051,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 68 + "__id__": 66 }, "_id": "" }, diff --git a/assets/resources/game/heros/mo4.prefab b/assets/resources/game/heros/mo4.prefab index 31e33922..dc4a7bda 100644 --- a/assets/resources/game/heros/mo4.prefab +++ b/assets/resources/game/heros/mo4.prefab @@ -56,13 +56,10 @@ }, { "__id__": 65 - }, - { - "__id__": 67 } ], "_prefab": { - "__id__": 69 + "__id__": 67 }, "_lpos": { "__type__": "cc.Vec3", @@ -958,24 +955,6 @@ "__type__": "cc.CompPrefabInfo", "fileId": "ae2ywFEqlJ26Sq7z7AtGgk" }, - { - "__type__": "7eb34NR6XVEf78HCi5eAKLm", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 1 - }, - "_enabled": true, - "__prefab": { - "__id__": 60 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "654wWWbWpMeYe/ywRBGTMP" - }, { "__type__": "cc.RigidBody2D", "_name": "", @@ -986,7 +965,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 62 + "__id__": 60 }, "enabledContactListener": true, "bullet": false, @@ -1020,7 +999,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 64 + "__id__": 62 }, "tag": 0, "_group": 4, @@ -1054,7 +1033,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 66 + "__id__": 64 }, "_id": "" }, @@ -1072,7 +1051,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 68 + "__id__": 66 }, "_id": "" }, diff --git a/assets/script/game/hero/BuffComp.ts b/assets/script/game/hero/BuffComp.ts deleted file mode 100644 index 075cfddb..00000000 --- a/assets/script/game/hero/BuffComp.ts +++ /dev/null @@ -1,212 +0,0 @@ -import { _decorator, Component, instantiate, Label, Node, Prefab, ProgressBar, tween, UITransform, v3, Vec3 } from 'cc'; -import { oops } from 'db://oops-framework/core/Oops'; -import { ecs } from 'db://oops-framework/libs/ecs/ECS'; -import { Tooltip } from '../skill/Tooltip'; -import { timedCom } from '../skill/timedCom'; -import { smc } from '../common/SingletonModuleComp'; -import { Timer } from 'db://oops-framework/core/common/timer/Timer'; -const { ccclass, property } = _decorator; - -@ccclass('BuffComp') -export class BuffComp extends Component { - top_node:any=null; - ap_node:any=null; - cd_node:any=null; - def_node:any=null; - hp_node:any=null; - crit_node:any=null; - ap_cd:number=0; - cd_cd:number=0; - def_cd:number=0; - hp_cd:number=0; - crit_cd:number=0; - - deap_cd:number=0; - decd_cd:number=0; - dedef_cd:number=0; - dehp_cd:number=0; - decrit_cd:number=0; - - buff_cd:number=0; - wind_cd:number=0; - speek_time:number=0; - - timer:Timer=new Timer(2); - buff_keys:any[]=["by1","by2","by3"] - key_index:number=0; - protected onLoad(): void { - } - start() { - this.info_init() - } - - info_init(){ - this.top_node = this.node.getChildByName("top"); - let hp_y=this.node.getComponent(UITransform).height - this.top_node.setPosition(0,hp_y,0) - - // this.top_node.getChildByName("hp").active=(this.node.getComponent(HeroViewComp).fac == 1 ? true : false) - - // this.vmdata_update() - } - - to_update_vmdata(){ - // this.vmdata_update(false) - } - update(deltaTime: number) { - if(smc.mission.pause) return - - - // if(this.timer.update(deltaTime)){ - // this.timer.reset() - // this.key_index++ - // if(this.key_index>=this.buff_keys.length) this.key_index=0 - // } - - // this.in_speek(deltaTime) - // this.vmdata_update() - } - - show_shield(shield:number=0,shield_max:number=0){ - let shield_progress= shield/shield_max; - this.node.getChildByName("shielded").active=shield > 0 - this.node.getChildByName("top").getChildByName("shield").active=shield > 0 - this.node.getChildByName("top").getChildByName("shield").getComponent(ProgressBar).progress = shield_progress; - this.scheduleOnce(()=>{ - this.node.getChildByName("top").getChildByName("shield").getChildByName("pb").getComponent(ProgressBar).progress = shield_progress; - },0.15) - } - - - hp_show(hp:number,hp_max:number){ - // if(this.node.getComponent(HeroViewComp).fac == 0) return - let hp_progress= hp/hp_max; - this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar).progress = hp_progress; - this.scheduleOnce(()=>{ - this.node.getChildByName("top").getChildByName("hp").getChildByName("hpb").getComponent(ProgressBar).progress = hp_progress; - },0.15) - // this.node.getChildByName("top").getChildByName("hp").active = (hp == hp_max) ? false : true; - } - - mp_show(mp:number,mp_max:number){ - this.node.getChildByName("top").getChildByName("pow").getComponent(ProgressBar).progress = mp/mp_max; - this.scheduleOnce(()=>{ - this.node.getChildByName("top").getChildByName("pow").getChildByName("mpb").getComponent(ProgressBar).progress = mp/mp_max; - },0.15) - } - - update_info_lv(){ - - } - - show_wind(t:number=1){ - this.wind_cd = t; - - } - - - - lv_up(){ - var path = "game/skill/buff/buff_lvup"; - var prefab: Prefab = oops.res.get(path, Prefab)!; - var node = instantiate(prefab); - node.parent = this.node; - } - ap_up(){ - var path = "game/skill/buff/buff_apup"; - var prefab: Prefab = oops.res.get(path, Prefab)!; - var node = instantiate(prefab); - node.parent = this.node; - } - - show_do_buff(name:string){ - var path = "game/skill/buff/"+name; - var prefab: Prefab = oops.res.get(path, Prefab)!; - var node = instantiate(prefab); - let pos = v3(this.node.position.x,this.node.position.y+20,this.node.position.z); - node.parent = this.node.parent; - node.setPosition(pos); - } - dead(){ - var path = "game/skill/buff/dead"; - var prefab: Prefab = oops.res.get(path, Prefab)!; - var node = instantiate(prefab); - node.parent = this.node.parent; - node.setScale(node.scale.x*0.5,node.scale.y*0.5) - let pos = v3(this.node.position.x,this.node.position.y+30,this.node.position.z); - node.setPosition(pos); - } - in_atked(anm:string="atked",scale:number=1) { - var path = "game/skill/boom/"+anm; - var prefab: Prefab = oops.res.get(path, Prefab)!; - var node = instantiate(prefab); - node.setScale(node.scale.x*scale,node.scale.y) - node.setPosition(this.node.position.x,this.node.position.y+30,this.node.position.z) - node.parent = this.node.parent; - } - in_iced(t:number=1,ap:number=0) { - var path = "game/skill/buff/buff_iced"; - var prefab: Prefab = oops.res.get(path, Prefab)!; - var node = instantiate(prefab); - node.getComponent(timedCom).time = t; - node.getComponent(timedCom).ap = ap; - node.parent = this.node; - } - in_fired(t:number=1,ap:number=0) { - // var path = "game/skills/fired"; - // var prefab: Prefab = oops.res.get(path, Prefab)!; - // var node = instantiate(prefab); - // node.getComponent(timedCom).time = t; - // node.getComponent(timedCom).ap = ap; - // node.parent = this.node; - } - in_yun(t:number=1,ap:number=0) { - var path = "game/skill/buff/buff_yun"; - var prefab: Prefab = oops.res.get(path, Prefab)!; - var node = instantiate(prefab); - let height=this.node.getComponent(UITransform).height - node.setPosition(v3(0,height)); - node.getComponent(timedCom).time = t; - node.getComponent(timedCom).ap = ap; - node.parent = this.node; - } - to_speek(words:string,time:number=0.5){ - this.speek_time=0.5 - this.node.getChildByName("tooltip").active=true - this.node.getChildByName("tooltip").getChildByName("words").getComponent(Label)!.string = words - } - in_speek(dt: number){ - if(this.speek_time <= 0){ - return; - } - this.speek_time -= dt; - if(this.speek_time <= 0){ - this.speek_time = 0; - this.node.getChildByName("tooltip").getChildByName("words").getComponent(Label)!.string = ""; - this.node.getChildByName("tooltip").active=false; - } - } - tooltip(type:number=1,value:string="",s_uuid:number=1001,y:number=90){ - // console.log("tooltip",type); - let tip =ecs.getEntity(Tooltip); - let pos = v3(0,10); - pos.y=pos.y+y; - tip.load(pos,type,value,s_uuid,this.node); - } - hp_tip(type:number=1,value:string="",s_uuid:number=1001,y:number=90){ - let tip =ecs.getEntity(Tooltip); - let x=this.node.position.x; - let ny=this.node.getComponent(UITransform).height+20; - let pos = v3(x,ny,0); - tip.load(pos,type,value,s_uuid,this.node.parent); - } - heathed(){ - var path = "game/skill/buff/heathed"; - var prefab: Prefab = oops.res.get(path, Prefab)!; - var node = instantiate(prefab); - node.parent = this.node; - } - -} - - diff --git a/assets/script/game/hero/Hero.ts b/assets/script/game/hero/Hero.ts index 3138e6d7..0cda9824 100644 --- a/assets/script/game/hero/Hero.ts +++ b/assets/script/game/hero/Hero.ts @@ -2,7 +2,7 @@ import { instantiate, Node, Prefab, Vec3 ,v3,resources,SpriteFrame,Sprite,Sprite import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { smc } from "../common/SingletonModuleComp"; -import { HeroModelComp } from "./HeroModelComp"; +import { HeroAttrsComp } from "./HeroAttrsComp"; import { HeroViewComp } from "./HeroViewComp"; import { BoxSet, FacSet } from "../common/config/BoxSet"; import { HeroInfo, HeroPos, HType } from "../common/config/heroSet"; @@ -17,13 +17,13 @@ import { EBusComp } from "./EBusComp"; @ecs.register(`Hero`) export class Hero extends ecs.Entity { - HeroModel!: HeroModelComp; + HeroModel!: HeroAttrsComp; View!: HeroViewComp; BattleMove!: BattleMoveComp; protected init() { this.addComponents( BattleMoveComp, - HeroModelComp, + HeroAttrsComp, TalComp, EBusComp, ); @@ -31,7 +31,7 @@ export class Hero extends ecs.Entity { destroy(): void { this.remove(HeroViewComp); - this.remove(HeroModelComp); + this.remove(HeroAttrsComp); this.remove(TalComp); this.remove(EBusComp); super.destroy(); @@ -53,7 +53,7 @@ export class Hero extends ecs.Entity { node.setPosition(pos) // console.log("hero load",pos) var hv = node.getComponent(HeroViewComp)!; - const model = this.get(HeroModelComp); + const model = this.get(HeroAttrsComp); let hero = HeroInfo[uuid]; // 共用英雄数据 // 设置 View 层属性(表现相关) @@ -127,16 +127,16 @@ export class HeroLifecycleSystem extends ecs.ComblockSystem implements ecs.IEntityEnterSystem, ecs.IEntityRemoveSystem { filter() { - return ecs.allOf(HeroModelComp); + return ecs.allOf(HeroAttrsComp); } entityEnter(e: ecs.Entity): void { // 英雄实体创建时的特殊处理 - console.log(`英雄进入世界: ${e.get(HeroModelComp).hero_name}`); + console.log(`英雄进入世界: ${e.get(HeroAttrsComp).hero_name}`); } entityRemove(e: ecs.Entity): void { // 英雄实体销毁时的清理工作 - console.log(`英雄离开世界: ${e.get(HeroModelComp).hero_name}`); + console.log(`英雄离开世界: ${e.get(HeroAttrsComp).hero_name}`); } } \ No newline at end of file diff --git a/assets/script/game/hero/HeroAtk.ts b/assets/script/game/hero/HeroAtk.ts new file mode 100644 index 00000000..63f28e20 --- /dev/null +++ b/assets/script/game/hero/HeroAtk.ts @@ -0,0 +1,235 @@ +import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; +import { FacSet } from "../common/config/BoxSet"; +import { Attrs } from "../common/config/HeroAttrs"; +import { FightSet } from "../common/config/Mission"; +import { SkillSet } from "../common/config/SkillSet"; +import { HeroAttrsComp } from "./HeroAttrsComp"; + +/** 业务层对象 */ +@ecs.register('HeroAtk') +export class HeroAtkComp extends ecs.Comp { + /** 业务层组件移除时,重置所有数据为默认值 */ + reset() { + + } +} + +/** 业务层业务逻辑处理对象 */ +export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate, ecs.IEntityEnterSystem { + + private debugMode: boolean = false; // 是否启用调试模式 + + /** + * 过滤器:只处理拥有 HeroAttrsComp 的实体 + */ + filter(): ecs.IMatcher { + return ecs.allOf(HeroAttrsComp); + } + + /** + * 实体首次进入系统时调用(每个实体只调用一次) + */ + entityEnter(e: ecs.Entity): void { + const model = e.get(HeroAttrsComp); + if (!model) return; + + console.log(`[HeroBattleSystem] 英雄进入战斗系统: ${model.hero_name} (uuid: ${model.hero_uuid})`); + } + + /** + * 处理角色被攻击 + * @param target 被攻击的目标实体 + * @param remainingDamage 基础伤害值 + * @param attackerAttrs 攻击者的属性 + * @param skillId 技能ID + * @returns 实际造成的伤害 + */ + public doAttack(target: ecs.Entity, remainingDamage: number, attackerAttrs: any, skillId: number): number { + const targetModel = target.get(HeroAttrsComp); + if (!targetModel || targetModel.is_dead) return 0; + + // 获取技能配置 + const skillConf = SkillSet[skillId]; + + // 触发被攻击事件 + this.onAttacked(target); + + // 闪避判定 + if (this.checkDodge(targetModel)) { + return 0; + } + + // 暴击判定 + const isCrit = this.checkCrit(attackerAttrs[Attrs.CRITICAL]); + let damage = remainingDamage; + + if (isCrit) { + damage = Math.floor(damage * (1 + (FightSet.CRIT_DAMAGE + attackerAttrs[Attrs.CRITICAL_DMG]) / 100)); + } + + // 伤害计算(考虑易伤等debuff) + damage = this.calculateDamage(targetModel, damage); + + // 护盾吸收 + damage = this.absorbShield(targetModel, damage); + + if (damage <= 0) return 0; + + // 应用伤害 + targetModel.hp -= damage; + targetModel.atked_count++; + + // 检查死亡 + if (targetModel.hp <= 0) { + this.doDead(target); + } + + if (this.debugMode) { + console.log(`[HeroBattleSystem] ${targetModel.hero_name} 受到 ${damage} 点伤害 (暴击: ${isCrit})`); + } + + return damage; + } + + /** + * 处理角色死亡 + */ + private doDead(entity: ecs.Entity): void { + const model = entity.get(HeroAttrsComp); + if (!model || model.is_dead) return; + + model.is_dead = true; + + // 触发死亡事件 + this.onDeath(entity); + + if (this.debugMode) { + console.log(`[HeroBattleSystem] ${model.hero_name} 死亡`); + } + } + + /** + * 闪避判定 + */ + private checkDodge(model: HeroAttrsComp): boolean { + if (model.Attrs[Attrs.DODGE] > 0) { + const random = Math.random() * 100; + if (random < model.Attrs[Attrs.DODGE]) { + if (this.debugMode) { + console.log(`[HeroBattleSystem] ${model.hero_name} 闪避了攻击`); + } + return true; + } + } + return false; + } + + /** + * 暴击判定 + */ + private checkCrit(critRate: number): boolean { + if (critRate > 0) { + const random = Math.random() * 100; + return random < critRate; + } + return false; + } + + /** + * 伤害计算(考虑易伤等debuff) + */ + private calculateDamage(model: HeroAttrsComp, baseDamage: number): number { + // 这里可以添加易伤等debuff的计算逻辑 + // 例如:如果目标有易伤buff,增加受到的伤害 + return baseDamage; + } + + /** + * 护盾吸收伤害 + */ + private absorbShield(model: HeroAttrsComp, damage: number): number { + if (model.shield <= 0) return damage; + + if (model.shield >= damage) { + model.shield -= damage; + if (model.shield <= 0) { + model.shield = 0; + model.Attrs[Attrs.SHIELD_MAX] = 0; + } + return 0; + } else { + const remainingDamage = damage - model.shield; + model.shield = 0; + model.Attrs[Attrs.SHIELD_MAX] = 0; + return remainingDamage; + } + } + + /** + * 被攻击时触发的事件 + */ + private onAttacked(entity: ecs.Entity): void { + const model = entity.get(HeroAttrsComp); + if (!model || model.is_dead) return; + + // 这里可以添加被攻击时的特殊处理逻辑 + if (model.fac === FacSet.MON) return; + + // 例如:触发某些天赋效果、反击逻辑等 + } + + /** + * 死亡时触发的事件 + */ + private onDeath(entity: ecs.Entity): void { + const model = entity.get(HeroAttrsComp); + if (!model) return; + + if (model.fac === FacSet.MON) { + // 怪物死亡处理 + this.scheduleDrop(entity); + } else if (model.fac === FacSet.HERO) { + // 英雄死亡处理 + this.scheduleHeroDeath(entity); + } + } + + /** + * 延迟执行掉落逻辑 + */ + private scheduleDrop(entity: ecs.Entity): void { + // 这里可以添加掉落逻辑 + // 例如:延迟一段时间后生成掉落物品 + } + + /** + * 延迟执行英雄死亡逻辑 + */ + private scheduleHeroDeath(entity: ecs.Entity): void { + // 这里可以添加英雄死亡的特殊处理 + // 例如:触发游戏结束、复活机制等 + } + + /** + * 启用调试模式 + */ + enableDebug() { + this.debugMode = true; + } + + /** + * 禁用调试模式 + */ + disableDebug() { + this.debugMode = false; + } + + /** + * 系统更新(每帧调用) + * 可以在这里添加需要每帧处理的战斗逻辑 + */ + update(e: ecs.Entity): void { + // 这里可以添加需要每帧处理的战斗逻辑 + // 例如:持续伤害、战斗状态检查等 + } +} \ No newline at end of file diff --git a/assets/script/game/hero/MonModelComp.ts.meta b/assets/script/game/hero/HeroAtk.ts.meta similarity index 70% rename from assets/script/game/hero/MonModelComp.ts.meta rename to assets/script/game/hero/HeroAtk.ts.meta index 61963d2c..07ba222c 100644 --- a/assets/script/game/hero/MonModelComp.ts.meta +++ b/assets/script/game/hero/HeroAtk.ts.meta @@ -2,7 +2,7 @@ "ver": "4.0.24", "importer": "typescript", "imported": true, - "uuid": "118ca580-773a-458b-8544-ab6c3cb2b376", + "uuid": "85d8a2e5-f2a1-49b0-9439-fe9e1e98b7d9", "files": [], "subMetas": {}, "userData": {} diff --git a/assets/script/game/hero/HeroModelComp.ts b/assets/script/game/hero/HeroAttrsComp.ts similarity index 68% rename from assets/script/game/hero/HeroModelComp.ts rename to assets/script/game/hero/HeroAttrsComp.ts index 4b263c22..dd032649 100644 --- a/assets/script/game/hero/HeroModelComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -2,14 +2,12 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec import { Attrs, AttrsType, BType, NeAttrs } from "../common/config/HeroAttrs"; import { BuffConf, SkillSet } from "../common/config/SkillSet"; import { HeroInfo, AttrSet, HeroUpSet } from "../common/config/heroSet"; -import { MonModelComp } from "./MonModelComp"; -import { FacSet } from "../common/config/BoxSet"; -import { FightSet } from "../common/config/Mission"; +import { EBusComp } from "./EBusComp"; -@ecs.register('HeroModel') -export class HeroModelComp extends ecs.Comp { - +@ecs.register('HeroAttrs') +export class HeroAttrsComp extends ecs.Comp { + Ebus:any=null! // ==================== 角色基础信息 ==================== hero_uuid: number = 1001; hero_name: string = "hero"; @@ -55,7 +53,9 @@ export class HeroModelComp extends ecs.Comp { // ==================== 技能配置 ==================== skills: any = []; - + start(){ + this.Ebus=this.ent.get(EBusComp); + } // ==================== BUFF 系统初始化 ==================== /** * 初始化角色的 buff debuff @@ -384,7 +384,7 @@ export class HeroModelComp extends ecs.Comp { * ==================== 英雄属性更新系统 ==================== * * 按照 ECS 设计理念: - * - Component(HeroModelComp):存储数据 + * - Component(HeroAttrsComp):存储数据 * - System(HeroAttrSystem):处理业务逻辑 * * 系统职责: @@ -393,7 +393,7 @@ export class HeroModelComp extends ecs.Comp { * 3. 限制属性值在合理范围内 * * 使用方式: - * 在 RootSystem 中注册此系统,它会自动每帧更新所有拥有 HeroModelComp 的实体 + * 在 RootSystem 中注册此系统,它会自动每帧更新所有拥有 HeroAttrsComp 的实体 */ export class HeroAttrSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate, ecs.IEntityEnterSystem, ecs.ISystemFirstUpdate { @@ -404,17 +404,17 @@ export class HeroAttrSystem extends ecs.ComblockSystem private debugMode: boolean = false; // 是否启用调试模式 /** - * 过滤器:只处理拥有 HeroModelComp 的实体 + * 过滤器:只处理拥有 HeroAttrsComp 的实体 */ filter(): ecs.IMatcher { - return ecs.allOf(HeroModelComp); + return ecs.allOf(HeroAttrsComp); } /** * 实体首次进入系统时调用(每个实体只调用一次) */ entityEnter(e: ecs.Entity): void { - const model = e.get(HeroModelComp); + const model = e.get(HeroAttrsComp); if (!model) return; console.log(`[HeroAttrSystem] 英雄进入系统: ${model.hero_name} (uuid: ${model.hero_uuid})`); @@ -436,7 +436,7 @@ export class HeroAttrSystem extends ecs.ComblockSystem * - 这是正确的设计,不是 bug */ update(e: ecs.Entity): void { - const model = e.get(HeroModelComp); + const model = e.get(HeroAttrsComp); if (!model || model.is_dead) return; // 统计:记录本帧处理的实体数 @@ -485,240 +485,3 @@ export class HeroAttrSystem extends ecs.ComblockSystem this.debugMode = false; } } - -/** - * ==================== 英雄战斗系统 ==================== - * - * 按照 ECS 设计理念: - * - Component(HeroModelComp):存储数据 - * - System(HeroBattleSystem):处理战斗业务逻辑 - * - * 系统职责: - * 1. 处理角色被攻击逻辑(伤害计算、暴击判定、闪避判定) - * 2. 处理护盾吸收逻辑 - * 3. 处理角色死亡逻辑 - * 4. 处理战斗状态管理 - * - * 使用方式: - * 在 RootSystem 中注册此系统,它会自动处理所有拥有 HeroModelComp 的实体的战斗逻辑 - */ -export class HeroBattleSystem extends ecs.ComblockSystem - implements ecs.ISystemUpdate, ecs.IEntityEnterSystem { - - private debugMode: boolean = false; // 是否启用调试模式 - - /** - * 过滤器:只处理拥有 HeroModelComp 的实体 - */ - filter(): ecs.IMatcher { - return ecs.allOf(HeroModelComp); - } - - /** - * 实体首次进入系统时调用(每个实体只调用一次) - */ - entityEnter(e: ecs.Entity): void { - const model = e.get(HeroModelComp); - if (!model) return; - - console.log(`[HeroBattleSystem] 英雄进入战斗系统: ${model.hero_name} (uuid: ${model.hero_uuid})`); - } - - /** - * 处理角色被攻击 - * @param target 被攻击的目标实体 - * @param remainingDamage 基础伤害值 - * @param attackerAttrs 攻击者的属性 - * @param skillId 技能ID - * @returns 实际造成的伤害 - */ - public doAttack(target: ecs.Entity, remainingDamage: number, attackerAttrs: any, skillId: number): number { - const targetModel = target.get(HeroModelComp); - if (!targetModel || targetModel.is_dead) return 0; - - // 获取技能配置 - const skillConf = SkillSet[skillId]; - - // 触发被攻击事件 - this.onAttacked(target); - - // 闪避判定 - if (this.checkDodge(targetModel)) { - return 0; - } - - // 暴击判定 - const isCrit = this.checkCrit(attackerAttrs[Attrs.CRITICAL]); - let damage = remainingDamage; - - if (isCrit) { - damage = Math.floor(damage * (1 + (FightSet.CRIT_DAMAGE + attackerAttrs[Attrs.CRITICAL_DMG]) / 100)); - } - - // 伤害计算(考虑易伤等debuff) - damage = this.calculateDamage(targetModel, damage); - - // 护盾吸收 - damage = this.absorbShield(targetModel, damage); - - if (damage <= 0) return 0; - - // 应用伤害 - targetModel.hp -= damage; - targetModel.atked_count++; - - // 检查死亡 - if (targetModel.hp <= 0) { - this.doDead(target); - } - - if (this.debugMode) { - console.log(`[HeroBattleSystem] ${targetModel.hero_name} 受到 ${damage} 点伤害 (暴击: ${isCrit})`); - } - - return damage; - } - - /** - * 处理角色死亡 - */ - private doDead(entity: ecs.Entity): void { - const model = entity.get(HeroModelComp); - if (!model || model.is_dead) return; - - model.is_dead = true; - - // 触发死亡事件 - this.onDeath(entity); - - if (this.debugMode) { - console.log(`[HeroBattleSystem] ${model.hero_name} 死亡`); - } - } - - /** - * 闪避判定 - */ - private checkDodge(model: HeroModelComp): boolean { - if (model.Attrs[Attrs.DODGE] > 0) { - const random = Math.random() * 100; - if (random < model.Attrs[Attrs.DODGE]) { - if (this.debugMode) { - console.log(`[HeroBattleSystem] ${model.hero_name} 闪避了攻击`); - } - return true; - } - } - return false; - } - - /** - * 暴击判定 - */ - private checkCrit(critRate: number): boolean { - if (critRate > 0) { - const random = Math.random() * 100; - return random < critRate; - } - return false; - } - - /** - * 伤害计算(考虑易伤等debuff) - */ - private calculateDamage(model: HeroModelComp, baseDamage: number): number { - // 这里可以添加易伤等debuff的计算逻辑 - // 例如:如果目标有易伤buff,增加受到的伤害 - return baseDamage; - } - - /** - * 护盾吸收伤害 - */ - private absorbShield(model: HeroModelComp, damage: number): number { - if (model.shield <= 0) return damage; - - if (model.shield >= damage) { - model.shield -= damage; - if (model.shield <= 0) { - model.shield = 0; - model.Attrs[Attrs.SHIELD_MAX] = 0; - } - return 0; - } else { - const remainingDamage = damage - model.shield; - model.shield = 0; - model.Attrs[Attrs.SHIELD_MAX] = 0; - return remainingDamage; - } - } - - /** - * 被攻击时触发的事件 - */ - private onAttacked(entity: ecs.Entity): void { - const model = entity.get(HeroModelComp); - if (!model || model.is_dead) return; - - // 这里可以添加被攻击时的特殊处理逻辑 - if (model.fac === FacSet.MON) return; - - // 例如:触发某些天赋效果、反击逻辑等 - } - - /** - * 死亡时触发的事件 - */ - private onDeath(entity: ecs.Entity): void { - const model = entity.get(HeroModelComp); - if (!model) return; - - if (model.fac === FacSet.MON) { - // 怪物死亡处理 - this.scheduleDrop(entity); - } else if (model.fac === FacSet.HERO) { - // 英雄死亡处理 - this.scheduleHeroDeath(entity); - } - } - - /** - * 延迟执行掉落逻辑 - */ - private scheduleDrop(entity: ecs.Entity): void { - // 这里可以添加掉落逻辑 - // 例如:延迟一段时间后生成掉落物品 - } - - /** - * 延迟执行英雄死亡逻辑 - */ - private scheduleHeroDeath(entity: ecs.Entity): void { - // 这里可以添加英雄死亡的特殊处理 - // 例如:触发游戏结束、复活机制等 - } - - /** - * 启用调试模式 - */ - enableDebug() { - this.debugMode = true; - } - - /** - * 禁用调试模式 - */ - disableDebug() { - this.debugMode = false; - } - - /** - * 系统更新(每帧调用) - * 可以在这里添加需要每帧处理的战斗逻辑 - */ - update(e: ecs.Entity): void { - // 这里可以添加需要每帧处理的战斗逻辑 - // 例如:持续伤害、战斗状态检查等 - } -} - diff --git a/assets/script/game/hero/BuffComp.ts.meta b/assets/script/game/hero/HeroAttrsComp.ts.meta similarity index 70% rename from assets/script/game/hero/BuffComp.ts.meta rename to assets/script/game/hero/HeroAttrsComp.ts.meta index bcf711cf..3150c41e 100644 --- a/assets/script/game/hero/BuffComp.ts.meta +++ b/assets/script/game/hero/HeroAttrsComp.ts.meta @@ -2,7 +2,7 @@ "ver": "4.0.24", "importer": "typescript", "imported": true, - "uuid": "7eb34351-e975-447f-bf07-0a2e5e00a2e6", + "uuid": "2b2c4ea3-3baf-4136-aca4-9a6a09d29e99", "files": [], "subMetas": {}, "userData": {} diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index d43b011b..f188d1f9 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -1,4 +1,4 @@ -import { Vec3, _decorator , v3,Collider2D,Contact2DType,Label ,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite, math, clamp, Game, tween, Color, BoxCollider2D} from "cc"; +import { Vec3, _decorator , v3,Collider2D,Contact2DType,Label ,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite, math, clamp, Game, tween, Color, BoxCollider2D, UITransform} 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 { HeroSpine } from "./HeroSpine"; @@ -6,7 +6,6 @@ import { BoxSet, FacSet } from "../common/config/BoxSet"; import { smc } from "../common/SingletonModuleComp"; import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer"; import { SkillSet,BuffConf,} from "../common/config/SkillSet"; -import { BuffComp } from "./BuffComp"; import { oops } from "db://oops-framework/core/Oops"; import { GameEvent } from "../common/config/GameEvent"; import { FightSet, TooltipTypes } from "../common/config/Mission"; @@ -14,7 +13,12 @@ import { RandomManager } from "db://oops-framework/core/common/random/RandomMana import { AttrSet, HeroInfo, HeroUpSet } from "../common/config/heroSet"; import { Attrs, AttrsType, BType, NeAttrs } from "../common/config/HeroAttrs"; import { TalComp } from "./TalComp"; -import { HeroModelComp, HeroBattleSystem } from "./HeroModelComp"; +import { HeroAttrsComp } from "./HeroAttrsComp"; +import { EBusComp } from "./EBusComp"; +import { HeroAtkSystem } from "./HeroAtk"; +import { Tooltip } from "../skill/Tooltip"; +import { timedCom } from "../skill/timedCom"; + const { ccclass, property } = _decorator; /** 角色显示组件 */ @@ -27,18 +31,18 @@ export interface BuffInfo { @ecs.register('HeroView', false) // 定义ECS 组件 export class HeroViewComp extends CCComp { // ==================== View 层属性(表现相关)==================== - BUFFCOMP:BuffComp=null! - TALCOMP:any=null! + EBus:any=null! as: HeroSpine = null! status:String = "idle" scale: number = 1; // 显示方向 box_group:number = BoxSet.HERO; // 碰撞组 - is_stop:boolean = false; - is_atking:boolean = false; + + // ==================== UI 节点引用 ==================== + private top_node: Node = null!; - // ==================== 直接访问 HeroModelComp ==================== + // ==================== 直接访问 HeroAttrsComp ==================== private get model() { - return this.ent.get(HeroModelComp); + return this.ent.get(HeroAttrsComp); } private damageQueue: Array<{ @@ -51,6 +55,7 @@ export class HeroViewComp extends CCComp { private damageInterval: number = 0.01; // 伤害数字显示间隔 onLoad() { this.as = this.getComponent(HeroSpine); + this.EBus=this.ent.get(EBusComp); //console.log("[HeroViewComp]:hero view comp ",this.FIGHTCON) this.on(GameEvent.FightEnd,this.do_fight_end,this) const collider = this.node.getComponent(BoxCollider2D); @@ -63,91 +68,30 @@ export class HeroViewComp extends CCComp { /** 视图层逻辑代码分离演示 */ start () { this.as.idle() - this.BUFFCOMP=this.node.getComponent(BuffComp); - this.TALCOMP=this.ent.get(TalComp); - // console.log("[HeroViewComp]:heroview"+this.hero_name,this.Attrs) + + // 初始化 UI 节点 + this.initUINodes(); + /** 方向 */ this.node.setScale(this.scale,1); - this.node.getChildByName("top").setScale(this.scale,1); - if(this.is_boss){ - this.node.getChildByName("top").position=v3(this.node.position.x,this.node.position.y+100,0) + this.top_node.setScale(this.scale,1); + if(this.model.is_boss){ + this.top_node.position=v3(this.node.position.x,this.node.position.y+100,0) } /* 显示角色血*/ - this.node.getChildByName("top").getChildByName("hp").active = true; - this.node.getChildByName("top").getChildByName("pow").active = true; + this.top_node.getChildByName("hp").active = true; + this.top_node.getChildByName("pow").active = true; + } + + /** 初始化 UI 节点引用 */ + private initUINodes() { + this.top_node = this.node.getChildByName("top"); + let hp_y = this.node.getComponent(UITransform).height; + this.top_node.setPosition(0, hp_y, 0); } - // ==================== BUFF 系统方法直接调用 ==================== - /** - * 初始化角色的 buff debuff(直接调用 Model) - */ - initAttrs() { - if (this.model) { - this.model.initAttrs(); - } - } + - /** - * 添加 buff 效果(直接调用 Model) - */ - addBuff(buffConf: BuffConf) { - if (this.model) { - this.model.addBuff(buffConf); - } - } - - - // 属性计算方法已迁移到 Model,这里不再需要 - - /** - * 更新临时 buff/debuff(直接调用 Model) - */ - updateTemporaryBuffsDebuffs(dt: number) { - if (this.model) { - this.model.updateTemporaryBuffsDebuffs(dt); - } - } - - /** - * 清空buff(直接调用 Model) - */ - clearBuffs(attrIndex?: number, isBuff: boolean = true): void { - if (this.model) { - this.model.clearBuffs(attrIndex, isBuff); - } - } - - /** - * 清理单个NeAttr(直接调用 Model) - */ - clearNeAttr(neAttrIndex: number): void { - if (this.model) { - this.model.clearNeAttr(neAttrIndex); - } - } - - /** - * 清理所有NeAttrs(直接调用 Model) - */ - clearAllNeAttrs(): void { - if (this.model) { - this.model.clearAllNeAttrs(); - } - } - - /** - * 检查是否眩晕(直接调用 Model) - */ - public isStun(): boolean { - return this.model?.isStun() ?? false; - } - - /** - * 检查是否冰冻(直接调用 Model) - */ - public isFrost(): boolean { - return this.model?.isFrost() ?? false; - } /** * View 层每帧更新 @@ -161,9 +105,132 @@ export class HeroViewComp extends CCComp { this.processDamageQueue(); // 伤害数字显示队列 // ✅ 更新显示(数据由 HeroAttrSystem 更新) - this.BUFFCOMP.hp_show(this.hp, this.Attrs[Attrs.HP_MAX]); - this.BUFFCOMP.mp_show(this.mp, this.Attrs[Attrs.MP_MAX]); - this.BUFFCOMP.show_shield(this.shield, this.Attrs[Attrs.SHIELD_MAX]); + this.hp_show(this.model.hp, this.model.Attrs[Attrs.HP_MAX]); + this.mp_show(this.model.mp, this.model.Attrs[Attrs.MP_MAX]); + this.show_shield(this.model.shield, this.model.Attrs[Attrs.SHIELD_MAX]); + } + + + /** 显示护盾 */ + private show_shield(shield: number = 0, shield_max: number = 0) { + let shield_progress = shield / shield_max; + this.node.getChildByName("shielded").active = shield > 0; + this.top_node.getChildByName("shield").active = shield > 0; + this.top_node.getChildByName("shield").getComponent(ProgressBar).progress = shield_progress; + this.scheduleOnce(() => { + this.top_node.getChildByName("shield").getChildByName("pb").getComponent(ProgressBar).progress = shield_progress; + }, 0.15); + } + + /** 显示血量 */ + private hp_show(hp: number, hp_max: number) { + let hp_progress = hp / hp_max; + this.top_node.getChildByName("hp").getComponent(ProgressBar).progress = hp_progress; + this.scheduleOnce(() => { + this.top_node.getChildByName("hp").getChildByName("hpb").getComponent(ProgressBar).progress = hp_progress; + }, 0.15); + } + + /** 显示魔法值 */ + private mp_show(mp: number, mp_max: number) { + this.top_node.getChildByName("pow").getComponent(ProgressBar).progress = mp / mp_max; + this.scheduleOnce(() => { + this.top_node.getChildByName("pow").getChildByName("mpb").getComponent(ProgressBar).progress = mp / mp_max; + }, 0.15); + } + + /** 升级特效 */ + private lv_up() { + var path = "game/skill/buff/buff_lvup"; + var prefab: Prefab = oops.res.get(path, Prefab)!; + var node = instantiate(prefab); + node.parent = this.node; + } + + /** 攻击力提升特效 */ + private ap_up() { + var path = "game/skill/buff/buff_apup"; + var prefab: Prefab = oops.res.get(path, Prefab)!; + var node = instantiate(prefab); + node.parent = this.node; + } + + /** 显示 Buff 特效 */ + private show_do_buff(name: string) { + var path = "game/skill/buff/" + name; + var prefab: Prefab = oops.res.get(path, Prefab)!; + var node = instantiate(prefab); + let pos = v3(this.node.position.x, this.node.position.y + 20, this.node.position.z); + node.parent = this.node.parent; + node.setPosition(pos); + } + + /** 死亡特效 */ + private dead() { + var path = "game/skill/buff/dead"; + var prefab: Prefab = oops.res.get(path, Prefab)!; + var node = instantiate(prefab); + node.parent = this.node.parent; + node.setScale(node.scale.x * 0.5, node.scale.y * 0.5); + let pos = v3(this.node.position.x, this.node.position.y + 30, this.node.position.z); + node.setPosition(pos); + } + + /** 受击特效 */ + private in_atked(anm: string = "atked", scale: number = 1) { + var path = "game/skill/boom/" + anm; + var prefab: Prefab = oops.res.get(path, Prefab)!; + var node = instantiate(prefab); + node.setScale(node.scale.x * scale, node.scale.y); + node.setPosition(this.node.position.x, this.node.position.y + 30, this.node.position.z); + node.parent = this.node.parent; + } + + /** 冰冻特效 */ + private in_iced(t: number = 1, ap: number = 0) { + var path = "game/skill/buff/buff_iced"; + var prefab: Prefab = oops.res.get(path, Prefab)!; + var node = instantiate(prefab); + node.getComponent(timedCom).time = t; + node.getComponent(timedCom).ap = ap; + node.parent = this.node; + } + + /** 眩晕特效 */ + private in_yun(t: number = 1, ap: number = 0) { + var path = "game/skill/buff/buff_yun"; + var prefab: Prefab = oops.res.get(path, Prefab)!; + var node = instantiate(prefab); + let height = this.node.getComponent(UITransform).height; + node.setPosition(v3(0, height)); + node.getComponent(timedCom).time = t; + node.getComponent(timedCom).ap = ap; + node.parent = this.node; + } + + /** 技能提示 */ + private tooltip(type: number = 1, value: string = "", s_uuid: number = 1001, y: number = 90) { + let tip = ecs.getEntity(Tooltip); + let pos = v3(0, 10); + pos.y = pos.y + y; + tip.load(pos, type, value, s_uuid, this.node); + } + + /** 血量提示(伤害数字) */ + private hp_tip(type: number = 1, value: string = "", s_uuid: number = 1001, y: number = 90) { + let tip = ecs.getEntity(Tooltip); + let x = this.node.position.x; + let ny = this.node.getComponent(UITransform).height + 20; + let pos = v3(x, ny, 0); + tip.load(pos, type, value, s_uuid, this.node.parent); + } + + /** 治疗特效 */ + private heathed() { + var path = "game/skill/buff/heathed"; + var prefab: Prefab = oops.res.get(path, Prefab)!; + var node = instantiate(prefab); + node.parent = this.node; } // 注意:BaseUp 逻辑已移到 HeroAttrSystem.update() @@ -188,13 +255,13 @@ export class HeroViewComp extends CCComp { } add_shield(shield:number){ // 护盾数据更新由 Model 层处理,这里只负责视图表现 - if(this.shield>0) this.BUFFCOMP.show_shield(this.shield,this.Attrs[Attrs.SHIELD_MAX]) + if(this.model.shield>0) this.show_shield(this.model.shield, this.model.Attrs[Attrs.SHIELD_MAX]); } - health(hp: number = 0,is_num:boolean=true) { + health(hp: number = 0, is_num:boolean=true) { // 生命值更新由 Model 层处理,这里只负责视图表现 - this.BUFFCOMP.heathed(); - this.BUFFCOMP.show_heal(hp); + this.heathed(); + this.hp_show(hp, this.model.Attrs[Attrs.HP_MAX]); } @@ -202,25 +269,21 @@ export class HeroViewComp extends CCComp { in_stop (dt: number) { } - count_atk_count(){ //主将攻击 - if(this.fac==FacSet.MON) return - this.atk_count+=1 - } + do_dead(){ // 死亡逻辑主要由 HeroBattleSystem 处理 // 这里只保留视图层的表现逻辑 - if(this.is_count_dead) return - this.is_count_dead=true + if(this.model.is_count_dead) return - if(this.fac==FacSet.MON){ + if(this.model.fac==FacSet.MON){ this.scheduleOnce(()=>{ this.do_drop() },0.1) } - if(this.fac==FacSet.HERO){ + if(this.model.fac==FacSet.HERO){ this.scheduleOnce(()=>{ - oops.message.dispatchEvent(GameEvent.HeroDead,{hero_uuid:this.hero_uuid}) + oops.message.dispatchEvent(GameEvent.HeroDead,{hero_uuid:this.model.hero_uuid}) },0.1) } } @@ -230,7 +293,6 @@ export class HeroViewComp extends CCComp { do_atked(remainingDamage:number,CAttrs:any,s_uuid:number){ // 使用战斗系统处理攻击逻辑 - const battleSystem = this.ent.ecs.getSystem(HeroBattleSystem); if (!battleSystem) { console.error("[HeroViewComp] HeroBattleSystem 未找到"); return; @@ -246,12 +308,12 @@ export class HeroViewComp extends CCComp { } //后退 back(){ - if(this.fac==FacSet.MON) { + if(this.model.fac==FacSet.MON) { let tx=this.node.position.x+5 if(tx > 320) tx=320 tween(this.node).to(0.1, { position:v3(tx,this.node.position.y,0)}).start() } - if(this.fac==FacSet.HERO) { + if(this.model.fac==FacSet.HERO) { let tx=this.node.position.x-5 if(tx < -320) tx=-320 tween(this.node).to(0.1, { position:v3(tx,this.node.position.y,0)}).start() @@ -260,11 +322,11 @@ export class HeroViewComp extends CCComp { // 伤害计算和战斗逻辑已迁移到 HeroBattleSystem do_dead_trigger(){ //死亡特殊处理 - if(this.is_dead||this.fac==FacSet.MON) return + if(this.model.is_dead||this.model.fac==FacSet.MON) return } do_atked_trigger(){ //受伤特殊处理 - if(this.is_dead||this.fac==FacSet.MON) return + if(this.model.is_dead||this.model.fac==FacSet.MON) return } @@ -275,24 +337,18 @@ export class HeroViewComp extends CCComp { } }).start() } - // to_alive(){ - // this.is_dead=false - // this.currentHp=this.currentHpMax*(100+this.hp_buff)/100 - // this.BUFFCOMP.vmdata_update(true) - // this.node.setPosition(HeroPos[this.fight_pos].pos) - // this.BUFFCOMP.heathed() - // } + to_console(value:any,value2:any=null,value3:any=null){ //console.log("["+this.scale+this.hero_name+']'+value,value2,value3) } reset() { - this.is_dead = false; + this.model.is_dead = false; const collider = this.getComponent(Collider2D); if (collider) { collider.off(Contact2DType.BEGIN_CONTACT); - } + } this.scheduleOnce(() => { this.node.destroy(); }, 0.1); @@ -303,7 +359,7 @@ export class HeroViewComp extends CCComp { switch(skill.act){ case "max": this.as.max() - this.BUFFCOMP.tooltip(TooltipTypes.skill,skill.name,skill_id) + this.tooltip(TooltipTypes.skill, skill.name, skill_id) break case "atk": this.as.atk() @@ -339,16 +395,13 @@ export class HeroViewComp extends CCComp { } /** 立即显示伤害效果 */ - private showDamageImmediate(damage: number, isCrit: boolean,anm:string="atked") { - this.BUFFCOMP.hp_show(this.hp,this.Attrs[Attrs.HP_MAX]) - this.BUFFCOMP.in_atked(anm,this.fac==FacSet.HERO?1:-1) - this.atked_count++; + private showDamageImmediate(damage: number, isCrit: boolean, anm:string="atked") { + this.hp_show(this.model.hp, this.model.Attrs[Attrs.HP_MAX]); + this.in_atked(anm, this.model.fac==FacSet.HERO?1:-1); if (isCrit) { - this.BUFFCOMP.hp_tip(TooltipTypes.crit, damage.toFixed(0), damage); - // //console.log("暴击伤害 + damage); + this.hp_tip(TooltipTypes.crit, damage.toFixed(0), damage); } else { - this.BUFFCOMP.hp_tip(TooltipTypes.life, damage.toFixed(0), damage); - // //console.log("普通伤害:" + damage); + this.hp_tip(TooltipTypes.life, damage.toFixed(0), damage); } } } diff --git a/assets/script/game/hero/Mon.ts b/assets/script/game/hero/Mon.ts index d254b685..03b3c3d4 100644 --- a/assets/script/game/hero/Mon.ts +++ b/assets/script/game/hero/Mon.ts @@ -4,7 +4,7 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec import { smc } from "../common/SingletonModuleComp"; import { BoxSet, FacSet } from "../common/config/BoxSet"; import { HeroInfo } from "../common/config/heroSet"; -import { MonModelComp } from "./MonModelComp"; +import { MonAttrsComp } from "./MonAttrsComp"; import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp"; import { SkillConComp } from "./SkillConComp"; import { BuffConf, SkillSet } from "../common/config/SkillSet"; @@ -12,26 +12,26 @@ import { getNeAttrs, getAttrs ,Attrs} from "../common/config/HeroAttrs"; import { TalComp } from "./TalComp"; import { getMonAttr, MonType } from "../map/RogueConfig"; import { EBusComp } from "./EBusComp"; -import { MonViewComp } from "./MonViewComp"; +import { HeroViewComp } from "./HeroViewComp"; /** 角色实体 */ @ecs.register(`Monster`) export class Monster extends ecs.Entity { - HeroModel!: MonModelComp; - HeroView!: MonViewComp; + HeroModel!: MonAttrsComp; + HeroView!: HeroViewComp; BattleMove!: BattleMoveComp; protected init() { this.addComponents( BattleMoveComp, - MonModelComp, + MonAttrsComp, TalComp, EBusComp, ); } destroy(): void { - this.remove(MonViewComp); - this.remove(MonModelComp); + this.remove(HeroViewComp); + this.remove(MonAttrsComp); this.remove(TalComp); this.remove(EBusComp); super.destroy(); @@ -52,8 +52,8 @@ export class Monster extends ecs.Entity { node.setPosition(pos) - var view = node.getComponent(MonViewComp)!; - const model = this.get(MonModelComp); + var view = node.getComponent(HeroViewComp)!; + const model = this.get(MonAttrsComp); let hero = HeroInfo[uuid]; // 共用英雄数据 // 设置 View 层属性(表现相关) view.scale = scale; @@ -116,16 +116,16 @@ export class MonLifecycleSystem extends ecs.ComblockSystem implements ecs.IEntityEnterSystem, ecs.IEntityRemoveSystem { filter() { - return ecs.allOf(MonModelComp); + return ecs.allOf(MonAttrsComp); } entityEnter(e: ecs.Entity): void { // 英雄实体创建时的特殊处理 - console.log(`怪物进入世界: ${e.get(MonModelComp).hero_name}`); + console.log(`怪物进入世界: ${e.get(MonAttrsComp).hero_name}`); } entityRemove(e: ecs.Entity): void { // 英雄实体销毁时的清理工作 - console.log(`怪物离开世界: ${e.get(MonModelComp).hero_name}`); + console.log(`怪物离开世界: ${e.get(MonAttrsComp).hero_name}`); } } \ No newline at end of file diff --git a/assets/script/game/hero/MonModelComp.ts b/assets/script/game/hero/MonAttrsComp.ts similarity index 95% rename from assets/script/game/hero/MonModelComp.ts rename to assets/script/game/hero/MonAttrsComp.ts index 8136a895..015afd18 100644 --- a/assets/script/game/hero/MonModelComp.ts +++ b/assets/script/game/hero/MonAttrsComp.ts @@ -13,10 +13,10 @@ import { HeroInfo, AttrSet } from "../common/config/heroSet"; * 怪物属性数据模型 - 存储纯数据,不含表现逻辑 * 简化版本:只保留临时buff系统,移除持久型buff * - * 注意:HeroModelComp 中有详细的 ECS 架构分析,迁移方案见那个文件 + * 注意:HeroAttrsComp 中有详细的 ECS 架构分析,迁移方案见那个文件 */ -@ecs.register('MonModel') -export class MonModelComp extends ecs.Comp { +@ecs.register('MonAttrsComp') +export class MonAttrsComp extends ecs.Comp { // ==================== 角色基础信息 ==================== hero_uuid: number = 1001; @@ -64,7 +64,7 @@ export class MonModelComp extends ecs.Comp { recalculateSingleAttr(attrIndex: number) { const baseValues: Record = { - [Attrs.HP_MAX]: this.base_hp, [Attrs.MP_MAX]: this.base_mp, [Attrs.DEF]: this.base_def, + [Attrs.HP_MAX]: this.hp, [Attrs.MP_MAX]: this.mp, [Attrs.DEF]: this.def, [Attrs.AP]: this.base_ap, [Attrs.MAP]: this.base_map, [Attrs.SPEED]: this.base_speed, [Attrs.SHIELD_MAX]: 0 }; const baseVal = baseValues[attrIndex] !== undefined ? baseValues[attrIndex] : 0; @@ -187,11 +187,11 @@ export class MonAttrSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate { filter(): ecs.IMatcher { - return ecs.allOf(MonModelComp); + return ecs.allOf(MonAttrsComp); } update(e: ecs.Entity): void { - const model = e.get(MonModelComp); + const model = e.get(MonAttrsComp); if (!model || model.is_dead) return; // 怪物的属性更新逻辑(可以与英雄不同) diff --git a/assets/script/game/hero/HeroModelComp.ts.meta b/assets/script/game/hero/MonAttrsComp.ts.meta similarity index 70% rename from assets/script/game/hero/HeroModelComp.ts.meta rename to assets/script/game/hero/MonAttrsComp.ts.meta index 64d4d15e..0c855ae4 100644 --- a/assets/script/game/hero/HeroModelComp.ts.meta +++ b/assets/script/game/hero/MonAttrsComp.ts.meta @@ -2,7 +2,7 @@ "ver": "4.0.24", "importer": "typescript", "imported": true, - "uuid": "c9121e83-b457-492d-aa56-2119d79a3360", + "uuid": "b2b785de-2ec9-49ca-a015-b56c5fe19a50", "files": [], "subMetas": {}, "userData": {} diff --git a/assets/script/game/hero/SkillConComp.ts b/assets/script/game/hero/SkillConComp.ts index b360cc2a..8b6d6c3b 100644 --- a/assets/script/game/hero/SkillConComp.ts +++ b/assets/script/game/hero/SkillConComp.ts @@ -6,8 +6,8 @@ import { GameEvent } from '../common/config/GameEvent'; import { FacSet } from '../common/config/BoxSet'; import { smc } from '../common/SingletonModuleComp'; import { CCComp } from 'db://oops-framework/module/common/CCComp'; -import { MonModelComp } from './MonModelComp'; -import { HeroModelComp } from './HeroModelComp'; +import { MonAttrsComp } from './MonAttrsComp'; +import { HeroAttrsComp } from './HeroAttrsComp'; import { SkillEnt } from '../skill/SkillEnt'; import { Attrs } from '../common/config/HeroAttrs'; import { TalComp } from './TalComp'; @@ -18,7 +18,6 @@ const { ccclass, property } = _decorator; export class SkillConComp extends CCComp { HeroView:any=null; HeroEntity:any=null; - TALCOMP:any=null; skill_cd=0 private _timers: { [key: string]: any } = {}; init(): void { @@ -26,7 +25,6 @@ export class SkillConComp extends CCComp { } onLoad(){ this.HeroView=this.node.getComponent(HeroViewComp) - this.TALCOMP=this.node.getComponent(TalComp) } start() { this.HeroEntity=this.HeroView.ent @@ -109,9 +107,9 @@ export class SkillConComp extends CCComp { check_target(){ if(this.HeroView.fac==FacSet.HERO){ - return ecs.query(ecs.allOf(MonModelComp)) + return ecs.query(ecs.allOf(MonAttrsComp)) }else{ - return ecs.query(ecs.allOf(HeroModelComp)) + return ecs.query(ecs.allOf(HeroAttrsComp)) } } get_front(entities:any){ diff --git a/assets/script/game/map/MissionMonComp.ts b/assets/script/game/map/MissionMonComp.ts index a2b1eb23..eb9ba3ca 100644 --- a/assets/script/game/map/MissionMonComp.ts +++ b/assets/script/game/map/MissionMonComp.ts @@ -7,9 +7,7 @@ import { smc } from "../common/SingletonModuleComp"; import { GameEvent } from "../common/config/GameEvent"; // 导入肉鸽配置 import { MonType, EventType, getStageMonConfigs} from "./RogueConfig"; -import { MonModelComp } from "../hero/MonModelComp"; import { BuffConf } from "../common/config/SkillSet"; - const { ccclass, property } = _decorator; /** 视图层对象 */