技能继续调整
This commit is contained in:
@@ -1,90 +0,0 @@
|
||||
import { _decorator, EventTarget } from 'cc';
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
const { ccclass } = _decorator;
|
||||
|
||||
/** 事件总线组件 - 简化版,仅提供基本的发布订阅功能 */
|
||||
@ecs.register('EBusComp', false)
|
||||
export class EBusComp extends CCComp {
|
||||
|
||||
/** 内部事件目标 */
|
||||
private _eventTarget: EventTarget;
|
||||
|
||||
/** 获取事件目标 */
|
||||
private get eventTarget(): EventTarget {
|
||||
if (!this._eventTarget) {
|
||||
this._eventTarget = new EventTarget();
|
||||
}
|
||||
return this._eventTarget;
|
||||
}
|
||||
|
||||
start() {
|
||||
// 组件启动时的初始化逻辑
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布事件
|
||||
* @param event 事件名称
|
||||
* @param data 事件数据
|
||||
*/
|
||||
public emit(event: string, data?: any): void {
|
||||
this.eventTarget.emit(event, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订阅事件
|
||||
* @param event 事件名称
|
||||
* @param callback 回调函数
|
||||
* @param target 回调函数的this指向
|
||||
*/
|
||||
public on(event: string, listener: (...args: any[]) => void, object?: any): void {
|
||||
this.eventTarget.on(event, listener, object);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消订阅事件
|
||||
* @param event 事件名称
|
||||
* @param callback 回调函数
|
||||
* @param target 回调函数的this指向
|
||||
*/
|
||||
public off(event?: string, callback?: (data?: any) => void, target?: any): void {
|
||||
if (arguments.length === 0) {
|
||||
// 无参调用:清理本节点所有监听
|
||||
this.eventTarget.targetOff(this);
|
||||
} else if (arguments.length === 1) {
|
||||
// 仅提供 event:清理该事件名下所有回调
|
||||
this.eventTarget.targetOff(event);
|
||||
} else {
|
||||
// 完整参数:精确移除指定回调
|
||||
this.eventTarget.off(event!, callback!, target);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 订阅一次性事件
|
||||
* @param event 事件名称
|
||||
* @param callback 回调函数
|
||||
* @param target 回调函数的this指向
|
||||
*/
|
||||
public once(event: string, callback: (data?: any) => void, target?: any): void {
|
||||
this.eventTarget.once(event, callback, target);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消所有事件监听
|
||||
*/
|
||||
public targetOff(target: any): void {
|
||||
this.eventTarget.targetOff(target);
|
||||
}
|
||||
|
||||
reset() {
|
||||
// 清理所有事件监听
|
||||
if (this._eventTarget) {
|
||||
this._eventTarget.targetOff(this);
|
||||
}
|
||||
|
||||
// 组件删除时触发自定义释放逻辑
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "b44b7a75-de7d-4aa1-ad20-78e6690926c0",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -47,4 +47,8 @@ export default class HeroAnmComp extends Component{
|
||||
if(this.anmcon.getState("buff").isPlaying) return
|
||||
this.anmcon.play("buff")
|
||||
}
|
||||
dead(){
|
||||
if(this.anmcon.getState("dead").isPlaying) return
|
||||
this.anmcon.play("dead")
|
||||
}
|
||||
}
|
||||
@@ -454,8 +454,8 @@ export class HeroAttrSystem extends ecs.ComblockSystem
|
||||
model.updateTemporaryBuffsDebuffs(this.dt);
|
||||
|
||||
// 2. HP/MP 自然回复(业务规则)
|
||||
model.mp += HeroUpSet.MP * this.dt;
|
||||
model.hp += HeroUpSet.HP * this.dt;
|
||||
model.mp += HeroUpSet.MP * this.dt/60;
|
||||
model.hp += HeroUpSet.HP * this.dt/60;
|
||||
|
||||
// 3. 限制属性值在合理范围内
|
||||
if (model.mp > model.Attrs[Attrs.MP_MAX]) {
|
||||
|
||||
@@ -66,6 +66,10 @@ export class HeroSpine extends Component {
|
||||
break
|
||||
}
|
||||
}
|
||||
dead(){
|
||||
// console.log("do dead");
|
||||
this.anm.dead()
|
||||
}
|
||||
do_buff(){
|
||||
this.anm.buff()
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import { GameEvent } from "../common/config/GameEvent";
|
||||
import { TooltipTypes } from "../common/config/Mission";
|
||||
import { Attrs, } from "../common/config/HeroAttrs";
|
||||
import { HeroAttrsComp } from "./HeroAttrsComp";
|
||||
import { EBusComp } from "./EBusComp";
|
||||
import { Tooltip } from "../skill/Tooltip";
|
||||
import { timedCom } from "../skill/timedCom";
|
||||
|
||||
@@ -93,7 +92,7 @@ export class HeroViewComp extends CCComp {
|
||||
|
||||
// 添加安全检查,防止在实体销毁过程中访问null的model
|
||||
if (!this.model) return;
|
||||
|
||||
if(this.model.is_dead) return;
|
||||
// ✅ View 层职责:处理表现相关的逻辑
|
||||
this.processDamageQueue(); // 伤害数字显示队列
|
||||
|
||||
@@ -158,17 +157,7 @@ export class HeroViewComp extends CCComp {
|
||||
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/end/" + anm;
|
||||
@@ -270,7 +259,7 @@ export class HeroViewComp extends CCComp {
|
||||
this.model.is_count_dead = true; // 防止重复触发,必须存在防止重复调用
|
||||
|
||||
// 播放死亡特效
|
||||
this.dead();
|
||||
this.as.dead();
|
||||
|
||||
// 根据阵营触发不同事件
|
||||
if(this.model.fac === FacSet.MON){
|
||||
@@ -325,14 +314,7 @@ export class HeroViewComp extends CCComp {
|
||||
// 预留:反击、护盾触发等
|
||||
}
|
||||
|
||||
to_grave(){
|
||||
tween(this.node).to(0.5, { position:v3(-900,this.node.position.y+300,0)},{
|
||||
onComplete: (target?: object) => {
|
||||
this.node.setPosition(-900,this.node.position.y-300,0)
|
||||
}
|
||||
}).start()
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** 调试日志(已禁用) */
|
||||
to_console(value:any, value2:any=null, value3:any=null){
|
||||
|
||||
Reference in New Issue
Block a user