Compare commits
3 Commits
2d5653e0e4
...
04aa5f9c78
| Author | SHA1 | Date | |
|---|---|---|---|
| 04aa5f9c78 | |||
| c98f20ba1d | |||
| 1a45e91f1a |
@@ -20,28 +20,31 @@
|
|||||||
"_children": [
|
"_children": [
|
||||||
{
|
{
|
||||||
"__id__": 2
|
"__id__": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 8
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_active": true,
|
"_active": true,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
|
||||||
"__id__": 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"__id__": 10
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"__id__": 12
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"__id__": 14
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"__id__": 16
|
"__id__": 16
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 18
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 20
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 22
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 24
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_prefab": {
|
"_prefab": {
|
||||||
"__id__": 18
|
"__id__": 26
|
||||||
},
|
},
|
||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
@@ -208,6 +211,181 @@
|
|||||||
"targetOverrides": null,
|
"targetOverrides": null,
|
||||||
"nestedPrefabInstanceRoots": null
|
"nestedPrefabInstanceRoots": null
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Node",
|
||||||
|
"_name": "T",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"_parent": {
|
||||||
|
"__id__": 1
|
||||||
|
},
|
||||||
|
"_children": [],
|
||||||
|
"_active": true,
|
||||||
|
"_components": [
|
||||||
|
{
|
||||||
|
"__id__": 9
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 11
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 13
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_prefab": {
|
||||||
|
"__id__": 15
|
||||||
|
},
|
||||||
|
"_lpos": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 40,
|
||||||
|
"y": -50,
|
||||||
|
"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,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.UITransform",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"node": {
|
||||||
|
"__id__": 8
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 10
|
||||||
|
},
|
||||||
|
"_contentSize": {
|
||||||
|
"__type__": "cc.Size",
|
||||||
|
"width": 80,
|
||||||
|
"height": 100
|
||||||
|
},
|
||||||
|
"_anchorPoint": {
|
||||||
|
"__type__": "cc.Vec2",
|
||||||
|
"x": 0.5,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "8b9HY9QmBA5qB0sBawCFqZ"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Sprite",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"node": {
|
||||||
|
"__id__": 8
|
||||||
|
},
|
||||||
|
"_enabled": false,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 12
|
||||||
|
},
|
||||||
|
"_customMaterial": null,
|
||||||
|
"_srcBlendFactor": 2,
|
||||||
|
"_dstBlendFactor": 4,
|
||||||
|
"_color": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 255,
|
||||||
|
"g": 255,
|
||||||
|
"b": 255,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_spriteFrame": {
|
||||||
|
"__uuid__": "cb93c900-b440-4571-91d1-7da1636e3d73@46c83",
|
||||||
|
"__expectedType__": "cc.SpriteFrame"
|
||||||
|
},
|
||||||
|
"_type": 0,
|
||||||
|
"_fillType": 0,
|
||||||
|
"_sizeMode": 0,
|
||||||
|
"_fillCenter": {
|
||||||
|
"__type__": "cc.Vec2",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"_fillStart": 0,
|
||||||
|
"_fillRange": 0,
|
||||||
|
"_isTrimmedMode": true,
|
||||||
|
"_useGrayscale": false,
|
||||||
|
"_atlas": null,
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "e0lXniMh9C77aUoKhV9TG0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Widget",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"node": {
|
||||||
|
"__id__": 8
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 14
|
||||||
|
},
|
||||||
|
"_alignFlags": 45,
|
||||||
|
"_target": null,
|
||||||
|
"_left": 0,
|
||||||
|
"_right": 0,
|
||||||
|
"_top": 0,
|
||||||
|
"_bottom": 0,
|
||||||
|
"_horizontalCenter": 0,
|
||||||
|
"_verticalCenter": 0,
|
||||||
|
"_isAbsLeft": true,
|
||||||
|
"_isAbsRight": true,
|
||||||
|
"_isAbsTop": true,
|
||||||
|
"_isAbsBottom": true,
|
||||||
|
"_isAbsHorizontalCenter": true,
|
||||||
|
"_isAbsVerticalCenter": true,
|
||||||
|
"_originalWidth": 25,
|
||||||
|
"_originalHeight": 25,
|
||||||
|
"_alignMode": 2,
|
||||||
|
"_lockFlags": 0,
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "efBhSYnd1Kz6YztMYe2EVs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.PrefabInfo",
|
||||||
|
"root": {
|
||||||
|
"__id__": 1
|
||||||
|
},
|
||||||
|
"asset": {
|
||||||
|
"__id__": 0
|
||||||
|
},
|
||||||
|
"fileId": "0b1uG2sstDMZRfqgTMWTrz",
|
||||||
|
"instance": null,
|
||||||
|
"targetOverrides": null,
|
||||||
|
"nestedPrefabInstanceRoots": null
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.UITransform",
|
"__type__": "cc.UITransform",
|
||||||
"_name": "",
|
"_name": "",
|
||||||
@@ -218,17 +396,17 @@
|
|||||||
},
|
},
|
||||||
"_enabled": true,
|
"_enabled": true,
|
||||||
"__prefab": {
|
"__prefab": {
|
||||||
"__id__": 9
|
"__id__": 17
|
||||||
},
|
},
|
||||||
"_contentSize": {
|
"_contentSize": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
"width": 200,
|
"width": 80,
|
||||||
"height": 80
|
"height": 100
|
||||||
},
|
},
|
||||||
"_anchorPoint": {
|
"_anchorPoint": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
"x": 0.5,
|
"x": 0,
|
||||||
"y": 0
|
"y": 0.5
|
||||||
},
|
},
|
||||||
"_id": ""
|
"_id": ""
|
||||||
},
|
},
|
||||||
@@ -246,7 +424,7 @@
|
|||||||
},
|
},
|
||||||
"_enabled": true,
|
"_enabled": true,
|
||||||
"__prefab": {
|
"__prefab": {
|
||||||
"__id__": 11
|
"__id__": 19
|
||||||
},
|
},
|
||||||
"playOnLoad": true,
|
"playOnLoad": true,
|
||||||
"_clips": [
|
"_clips": [
|
||||||
@@ -275,7 +453,7 @@
|
|||||||
},
|
},
|
||||||
"_enabled": true,
|
"_enabled": true,
|
||||||
"__prefab": {
|
"__prefab": {
|
||||||
"__id__": 13
|
"__id__": 21
|
||||||
},
|
},
|
||||||
"atk_x": 0,
|
"atk_x": 0,
|
||||||
"atk_y": 0,
|
"atk_y": 0,
|
||||||
@@ -295,7 +473,7 @@
|
|||||||
},
|
},
|
||||||
"_enabled": true,
|
"_enabled": true,
|
||||||
"__prefab": {
|
"__prefab": {
|
||||||
"__id__": 15
|
"__id__": 23
|
||||||
},
|
},
|
||||||
"enabledContactListener": true,
|
"enabledContactListener": true,
|
||||||
"bullet": false,
|
"bullet": false,
|
||||||
@@ -327,9 +505,9 @@
|
|||||||
"node": {
|
"node": {
|
||||||
"__id__": 1
|
"__id__": 1
|
||||||
},
|
},
|
||||||
"_enabled": true,
|
"_enabled": false,
|
||||||
"__prefab": {
|
"__prefab": {
|
||||||
"__id__": 17
|
"__id__": 25
|
||||||
},
|
},
|
||||||
"tag": 0,
|
"tag": 0,
|
||||||
"_group": 1,
|
"_group": 1,
|
||||||
@@ -339,13 +517,13 @@
|
|||||||
"_restitution": 0,
|
"_restitution": 0,
|
||||||
"_offset": {
|
"_offset": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
"x": 0,
|
"x": 40,
|
||||||
"y": 40
|
"y": 0
|
||||||
},
|
},
|
||||||
"_size": {
|
"_size": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
"width": 200,
|
"width": 80,
|
||||||
"height": 80
|
"height": 100
|
||||||
},
|
},
|
||||||
"_id": ""
|
"_id": ""
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ const { ccclass, property } = _decorator;
|
|||||||
@ccclass('Main')
|
@ccclass('Main')
|
||||||
export class Main extends Root {
|
export class Main extends Root {
|
||||||
start() {
|
start() {
|
||||||
PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb
|
// PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb
|
||||||
// |EPhysics2DDrawFlags.Pair
|
// |EPhysics2DDrawFlags.Pair
|
||||||
|EPhysics2DDrawFlags.CenterOfMass
|
// |EPhysics2DDrawFlags.CenterOfMass
|
||||||
// |EPhysics2DDrawFlags.Joint
|
// |EPhysics2DDrawFlags.Joint
|
||||||
// |EPhysics2DDrawFlags.Shape;
|
// |EPhysics2DDrawFlags.Shape;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export default class HeroAnmComp extends Component{
|
|||||||
}
|
}
|
||||||
onAnimationFinished(type:Animation.EventType, state:AnimationState){
|
onAnimationFinished(type:Animation.EventType, state:AnimationState){
|
||||||
// console.log("[HeroAnmComp]: 动画播放完毕",state.name)
|
// console.log("[HeroAnmComp]: 动画播放完毕",state.name)
|
||||||
if(state.name!="idle"&&state.name!="move"){
|
if(state.name!="idle"&&state.name!="move"&&state.name!="dead"&&state.name!="stun"){
|
||||||
this.anmcon.play(this.default_anim)
|
this.anmcon.play(this.default_anim)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { HeroAttrsComp } from "./HeroAttrsComp";
|
|||||||
import { Tooltip } from "../skill/Tooltip";
|
import { Tooltip } from "../skill/Tooltip";
|
||||||
import { timedCom } from "../skill/timedCom";
|
import { timedCom } from "../skill/timedCom";
|
||||||
import { HeroInfo, HType } from "../common/config/heroSet";
|
import { HeroInfo, HType } from "../common/config/heroSet";
|
||||||
|
import { Timer } from "db://oops-framework/core/common/timer/Timer";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@@ -31,11 +32,18 @@ export class HeroViewComp extends CCComp {
|
|||||||
box_group:number = BoxSet.HERO; // 碰撞组
|
box_group:number = BoxSet.HERO; // 碰撞组
|
||||||
usePower:boolean = false;
|
usePower:boolean = false;
|
||||||
useMp:boolean = false;
|
useMp:boolean = false;
|
||||||
|
realDeadTime:number=10
|
||||||
|
deadCD:number=0
|
||||||
// ==================== UI 节点引用 ====================
|
// ==================== UI 节点引用 ====================
|
||||||
private top_node: Node = null!;
|
private top_node: Node = null!;
|
||||||
|
|
||||||
// ==================== 直接访问 HeroAttrsComp ====================
|
// ==================== 直接访问 HeroAttrsComp ====================
|
||||||
get model() {
|
get model() {
|
||||||
|
// 🔥 修复:添加安全检查,防止ent为null时的访问异常
|
||||||
|
if (!this.ent) {
|
||||||
|
console.warn("[HeroViewComp] ent is null, returning null for model");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return this.ent.get(HeroAttrsComp);
|
return this.ent.get(HeroAttrsComp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,9 +108,17 @@ export class HeroViewComp extends CCComp {
|
|||||||
update(dt: number){
|
update(dt: number){
|
||||||
if(!smc.mission.play || smc.mission.pause) return;
|
if(!smc.mission.play || smc.mission.pause) return;
|
||||||
|
|
||||||
// 添加安全检查,防止在实体销毁过程中访问null的model
|
// 🔥 修复:添加安全检查,防止在实体销毁过程中访问null的model
|
||||||
|
if(!this.ent) return;
|
||||||
if (!this.model) return;
|
if (!this.model) return;
|
||||||
if(this.model.is_dead) return;
|
if(this.model.is_dead){
|
||||||
|
this.deadCD+=dt
|
||||||
|
if(this.deadCD>=this.realDeadTime){
|
||||||
|
this.deadCD=0
|
||||||
|
this.realDead()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
} ;
|
||||||
// ✅ View 层职责:处理表现相关的逻辑
|
// ✅ View 层职责:处理表现相关的逻辑
|
||||||
this.processDamageQueue(); // 伤害数字显示队列
|
this.processDamageQueue(); // 伤害数字显示队列
|
||||||
|
|
||||||
@@ -250,6 +266,7 @@ export class HeroViewComp extends CCComp {
|
|||||||
/** 状态切换(动画) */
|
/** 状态切换(动画) */
|
||||||
status_change(type:string){
|
status_change(type:string){
|
||||||
this.status = type;
|
this.status = type;
|
||||||
|
if(this.model.is_dead) return
|
||||||
if(type === "idle"){
|
if(type === "idle"){
|
||||||
this.as.idle();
|
this.as.idle();
|
||||||
} else if(type === "move"){
|
} else if(type === "move"){
|
||||||
@@ -269,7 +286,14 @@ export class HeroViewComp extends CCComp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
alive(){
|
||||||
|
this.model.is_dead=false
|
||||||
|
this.as.do_buff();
|
||||||
|
this.status_change("idle");
|
||||||
|
this.model.hp =this.model.Attrs[Attrs.HP_MAX]*50/100;
|
||||||
|
this.top_node.active=false
|
||||||
|
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 死亡视图表现
|
* 死亡视图表现
|
||||||
* 由 HeroAtkSystem 调用,只负责视觉效果和事件通知
|
* 由 HeroAtkSystem 调用,只负责视觉效果和事件通知
|
||||||
@@ -281,29 +305,34 @@ export class HeroViewComp extends CCComp {
|
|||||||
// 防止重复触发
|
// 防止重复触发
|
||||||
if(this.model.is_count_dead) return;
|
if(this.model.is_count_dead) return;
|
||||||
this.model.is_count_dead = true; // 防止重复触发,必须存在防止重复调用
|
this.model.is_count_dead = true; // 防止重复触发,必须存在防止重复调用
|
||||||
|
this.top_node.active=false
|
||||||
// 播放死亡特效
|
// 播放死亡特效
|
||||||
this.as.dead();
|
this.as.dead();
|
||||||
|
|
||||||
// 根据阵营触发不同事件
|
|
||||||
if(this.model.fac === FacSet.MON){
|
}
|
||||||
// 怪物死亡:延迟触发掉落(暂时不发事件,等待实现)
|
realDead(){
|
||||||
// this.scheduleOnce(() => {
|
// 🔥 修复:添加model安全检查,防止实体销毁过程中的空指针异常
|
||||||
// oops.message.dispatchEvent(GameEvent.MonsterDead, {
|
if (!this.model) {
|
||||||
// hero_uuid: this.model.hero_uuid,
|
console.warn("[HeroViewComp] realDead called but model is null, skipping");
|
||||||
// position: this.node.position
|
return;
|
||||||
// });
|
}
|
||||||
// }, 0.2);
|
if(this.model.fac === FacSet.HERO){
|
||||||
} else if(this.model.fac === FacSet.HERO){
|
|
||||||
// 英雄死亡:延迟触发死亡事件
|
// 英雄死亡:延迟触发死亡事件
|
||||||
this.scheduleOnce(() => {
|
|
||||||
oops.message.dispatchEvent(GameEvent.HeroDead, {
|
oops.message.dispatchEvent(GameEvent.HeroDead, {
|
||||||
hero_uuid: this.model.hero_uuid
|
hero_uuid: this.model.hero_uuid
|
||||||
});
|
});
|
||||||
}, 0.2);
|
|
||||||
}
|
}
|
||||||
|
// 根据阵营触发不同事件
|
||||||
|
if(this.model.fac === FacSet.MON){
|
||||||
|
oops.message.dispatchEvent(GameEvent.MonDead, {
|
||||||
|
hero_uuid: this.model.hero_uuid,
|
||||||
|
position: this.node.position
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
this.ent.destroy();
|
||||||
|
|
||||||
|
}
|
||||||
do_atked(damage:number,isCrit:boolean,s_uuid:number){
|
do_atked(damage:number,isCrit:boolean,s_uuid:number){
|
||||||
if (damage <= 0) return;
|
if (damage <= 0) return;
|
||||||
// 视图层表现
|
// 视图层表现
|
||||||
@@ -358,15 +387,6 @@ export class HeroViewComp extends CCComp {
|
|||||||
// 调试用,生产环境已禁用
|
// 调试用,生产环境已禁用
|
||||||
}
|
}
|
||||||
|
|
||||||
reset() {
|
|
||||||
const collider = this.getComponent(Collider2D);
|
|
||||||
if (collider) {
|
|
||||||
collider.off(Contact2DType.BEGIN_CONTACT);
|
|
||||||
}
|
|
||||||
this.scheduleOnce(() => {
|
|
||||||
this.node.destroy();
|
|
||||||
}, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
playSkillEffect(skill_id:number) {
|
playSkillEffect(skill_id:number) {
|
||||||
let skill = SkillSet[skill_id]
|
let skill = SkillSet[skill_id]
|
||||||
@@ -421,4 +441,22 @@ export class HeroViewComp extends CCComp {
|
|||||||
this.hp_tip(TooltipTypes.life, damage.toFixed(0), damage);
|
this.hp_tip(TooltipTypes.life, damage.toFixed(0), damage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
reset() {
|
||||||
|
// 清理碰撞器事件监听
|
||||||
|
const collider = this.getComponent(Collider2D);
|
||||||
|
if (collider) {
|
||||||
|
collider.off(Contact2DType.BEGIN_CONTACT);
|
||||||
|
}
|
||||||
|
this.deadCD=0
|
||||||
|
|
||||||
|
// 清理伤害队列
|
||||||
|
this.damageQueue.length = 0;
|
||||||
|
this.isProcessingDamage = false;
|
||||||
|
|
||||||
|
// 延迟销毁节点
|
||||||
|
this.scheduleOnce(() => {
|
||||||
|
this.node.destroy();
|
||||||
|
}, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,8 @@ export class MissionMonCompComp extends CCComp {
|
|||||||
|
|
||||||
const monsConf = getStageMonConfigs(cStage);
|
const monsConf = getStageMonConfigs(cStage);
|
||||||
// console.log(`[MissionMonComp]:第${cStage}关 - ${stageType}类型,怪物数量: ${monsConf.length}`);
|
// console.log(`[MissionMonComp]:第${cStage}关 - ${stageType}类型,怪物数量: ${monsConf.length}`);
|
||||||
this.generateMonsters(monsConf);
|
const monsConfFiltered = monsConf.filter((mon: any, index) => index === 0);
|
||||||
|
this.generateMonsters(monsConfFiltered);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,9 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
|
|||||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||||
import { DTType, EType, RType, SkillConfig, SkillSet } from "../common/config/SkillSet";
|
import { DTType, EType, RType, SkillConfig, SkillSet } from "../common/config/SkillSet";
|
||||||
import { BoxSet, FacSet } from "../common/config/GameSet";
|
|
||||||
import { SDataCom } from "./SDataCom";
|
import { SDataCom } from "./SDataCom";
|
||||||
import { SMoveDataComp } from "./SMoveComp";
|
|
||||||
import { Attrs } from "../common/config/HeroAttrs";
|
import { Attrs } from "../common/config/HeroAttrs";
|
||||||
import { MonMoveComp } from "../hero/MonMove";
|
|
||||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||||
import { HeroMoveComp } from "../hero/HeroMove";
|
|
||||||
import { DamageQueueHelper } from "../hero/DamageQueueComp";
|
import { DamageQueueHelper } from "../hero/DamageQueueComp";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
@@ -29,16 +25,19 @@ export class SkillView extends CCComp {
|
|||||||
SConf:SkillConfig=null;
|
SConf:SkillConfig=null;
|
||||||
sData:SDataCom=null;
|
sData:SDataCom=null;
|
||||||
s_uuid:number=1001
|
s_uuid:number=1001
|
||||||
|
private collider: Collider2D = null; // 缓存碰撞体引用
|
||||||
|
private attackFrameCount: number = 0; // 攻击帧计数器
|
||||||
|
private maxAttackFrames: number = 1; // 最大攻击帧数,可配置
|
||||||
// 已命中目标追踪,防止重复伤害
|
// 已命中目标追踪,防止重复伤害
|
||||||
start() {
|
start() {
|
||||||
this.SConf = SkillSet[this.s_uuid]
|
this.SConf = SkillSet[this.s_uuid]
|
||||||
this.sData=this.ent.get(SDataCom)
|
this.sData=this.ent.get(SDataCom)
|
||||||
this.anim=this.node.getComponent(Animation)
|
this.anim=this.node.getComponent(Animation)
|
||||||
this.node.active = true;
|
this.node.active = true;
|
||||||
let collider = this.getComponent(Collider2D);
|
this.collider = this.getComponent(Collider2D);
|
||||||
if(collider) {
|
if(this.collider) {
|
||||||
collider.group = this.group;
|
this.collider.group = this.group;
|
||||||
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
this.collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||||
}
|
}
|
||||||
if(this.node.getComponent(Animation)){
|
if(this.node.getComponent(Animation)){
|
||||||
let anim = this.node.getComponent(Animation);
|
let anim = this.node.getComponent(Animation);
|
||||||
@@ -78,7 +77,15 @@ export class SkillView extends CCComp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// //动画帧事件 atk 触发
|
// //动画帧事件 atk 触发
|
||||||
// public atk(args:any){
|
public atk(args:any){
|
||||||
|
this.attackFrameCount++;
|
||||||
|
|
||||||
|
// 开启碰撞检测
|
||||||
|
if(this.collider) {
|
||||||
|
this.collider.enabled = true;
|
||||||
|
console.log(`[SkillView] [${this.SConf?.name}] 第${this.attackFrameCount}次攻击帧开启碰撞检测`);
|
||||||
|
}
|
||||||
|
|
||||||
// let dis=this.node.getComponent(UITransform).width/2
|
// let dis=this.node.getComponent(UITransform).width/2
|
||||||
// let enemys:any=[]
|
// let enemys:any=[]
|
||||||
// if( this.sData.fac==FacSet.HERO){
|
// if( this.sData.fac==FacSet.HERO){
|
||||||
@@ -123,12 +130,18 @@ export class SkillView extends CCComp {
|
|||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
}
|
||||||
//伤害应用
|
//伤害应用
|
||||||
apply_damage(target:HeroViewComp,is_range:boolean=false){
|
apply_damage(target:HeroViewComp,is_range:boolean=false){
|
||||||
if(target == null) return;
|
if(target == null) return;
|
||||||
if (!this.SConf) return;
|
if (!this.SConf) return;
|
||||||
|
|
||||||
|
// 对于非持续碰撞类型的技能,在造成伤害后立即关闭碰撞检测
|
||||||
|
// 这样可以避免同一帧内的重复伤害
|
||||||
|
if(this.SConf.EType !== EType.collision && this.collider) {
|
||||||
|
this.collider.enabled = false;
|
||||||
|
console.log(`[SkillView] [${this.SConf.name}] 伤害后关闭碰撞检测`);
|
||||||
|
}
|
||||||
// console.log(`[skillView] 伤害 [${this.group}][${this.sData.caster.ent.get(HeroAttrsComp).hero_name}][${this.sData.caster.ent.eid}]的 [${this.SConf.name}]对 [${target.box_group}][ ${target.ent.get(HeroAttrsComp).hero_name}][${target.ent.eid}]`);
|
// console.log(`[skillView] 伤害 [${this.group}][${this.sData.caster.ent.get(HeroAttrsComp).hero_name}][${this.sData.caster.ent.eid}]的 [${this.SConf.name}]对 [${target.box_group}][ ${target.ent.get(HeroAttrsComp).hero_name}][${target.ent.eid}]`);
|
||||||
// if(this.sData.hit_count > this.SConf.hit_num) return 不能超出 最大伤害数量
|
// if(this.sData.hit_count > this.SConf.hit_num) return 不能超出 最大伤害数量
|
||||||
// 使用伤害队列系统处理伤害
|
// 使用伤害队列系统处理伤害
|
||||||
@@ -152,10 +165,12 @@ export class SkillView extends CCComp {
|
|||||||
}
|
}
|
||||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||||
reset() {
|
reset() {
|
||||||
const collider = this.getComponent(Collider2D);
|
// 清理碰撞体事件监听
|
||||||
if (collider) {
|
if (this.collider) {
|
||||||
collider.off(Contact2DType.BEGIN_CONTACT);
|
this.collider.off(Contact2DType.BEGIN_CONTACT);
|
||||||
}
|
}
|
||||||
|
// 取消所有定时器
|
||||||
|
this.unscheduleAllCallbacks();
|
||||||
this.node.destroy();
|
this.node.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user