Files
heros/assets/script/game/skill/TooltipCom.ts
panw 9c33bb0f7b feat(技能提示): 添加MP恢复提示功能
添加MP恢复提示类型到TooltipTypes枚举
在TooltipCom组件中实现MP恢复提示的显示逻辑
更新tooltip.prefab结构以支持MP恢复提示
移除未使用的tooltip.prefab.meta文件
移除英雄prefab中的tooltip 说话节点
2025-11-26 10:07:21 +08:00

125 lines
5.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { _decorator,Collider2D ,Contact2DType,v3,IPhysics2DContact,Vec3, tween, Label,resources,SpriteFrame,Sprite} 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 { SkillSet } from "../common/config/SkillSet";
import { TooltipTypes } from "../common/config/GameSet";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('TooltipCom')
@ecs.register('TooltipView', false)
export class TooltipCom extends CCComp {
/** 视图层逻辑代码分离演示 */
// start() {
// // var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
// // this.on(ModuleEvent.Cmd, this.onHandler, this);
// }
stype:number = 1; // 1:减少生命值2增加生命值3技能图标
value:string = "";
s_uuid:number = 1001;
alive_time:number = 0.3;
skill_name_time=0.5;
scale:number = 1;
start() {
switch(this.stype){
case TooltipTypes.life:
this.node.setPosition(v3(this.node.position.x,this.node.position.y))
this.node.setSiblingIndex(100);
this.node.getChildByName("loss_life").getChildByName("hp").getComponent(Label).string = this.value;
this.node.getChildByName("loss_life").active=true;
this.scheduleOnce(()=>{
this.ent.destroy()
},0.5)
break
case TooltipTypes.health:
this.node.setSiblingIndex(110);
this.node.getChildByName("add_life").getChildByName("hp").getComponent(Label).string = this.value;
this.node.getChildByName("add_life").active=true;
this.scheduleOnce(()=>{
this.ent.destroy()
},0.5)
break
case TooltipTypes.addmp:
this.node.setSiblingIndex(110);
this.node.getChildByName("add_mp").getChildByName("mp").getComponent(Label).string = this.value;
this.node.getChildByName("add_mp").active=true;
this.scheduleOnce(()=>{
this.ent.destroy()
},0.5)
break
case TooltipTypes.crit:
this.node.setPosition(v3(this.node.position.x,this.node.position.y))
this.node.setSiblingIndex(200);
this.node.getChildByName("bloss").getChildByName("hp").getComponent(Label).string = this.value;
this.node.getChildByName("bloss").active=true;
this.scheduleOnce(()=>{
this.ent.destroy()
},0.5)
break
case TooltipTypes.skill:
this.node.getChildByName("skill").getChildByName("name").getComponent(Label).string = "<"+SkillSet[this.s_uuid].name+">";
this.node.getChildByName("skill").active=true;
this.node.setPosition(v3(this.node.position.x,this.node.position.y+30))
this.scheduleOnce(()=>{
this.ent.destroy()
},0.5)
break
case TooltipTypes.uskill:
this.node.getChildByName("uskill").getChildByName("name").getComponent(Label).string = this.value;
this.node.getChildByName("uskill").active=true;
this.node.setPosition(v3(this.node.position.x,this.node.position.y+30))
this.scheduleOnce(()=>{
this.ent.destroy()
},0.5)
break
case TooltipTypes.lvup:
// this.node.getChildByName("lvup").getChildByName("name").getComponent(Label).string = this.value;
this.node.getChildByName("lvup").active=true;
this.node.setPosition(v3(this.node.position.x,this.node.position.y-30))
this.scheduleOnce(()=>{
this.ent.destroy()
},0.5)
break
case TooltipTypes.apup:
this.node.getChildByName("apup").getChildByName("num").getComponent(Label).string = "+"+this.value;
this.node.getChildByName("apup").active=true;
this.node.setPosition(v3(this.node.position.x,this.node.position.y-60))
this.scheduleOnce(()=>{
this.ent.destroy()
},0.5)
break
case TooltipTypes.hpup:
this.node.getChildByName("hpup").getChildByName("num").getComponent(Label).string = "+"+this.value;
this.node.getChildByName("hpup").active=true;
this.node.setPosition(v3(this.node.position.x,this.node.position.y-60))
this.scheduleOnce(()=>{
this.ent.destroy()
},0.5)
}
// console.log("TooltipView start:",this.node.getSiblingIndex());
}
update(deltaTime: number) {
}
do_up(){
tween(this.node).to(
this.alive_time,
{position:v3(this.node.position.x,this.node.position.y+60), },
{
onComplete:()=>{ this.ent.destroy()},
easing:"linear"
}
).start()
}
to_destroy() {
this.ent.destroy()
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}