85 lines
3.8 KiB
TypeScript
85 lines
3.8 KiB
TypeScript
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 { BoxSet } from "../common/config/BoxSet";
|
||
import { smc } from "../common/SingletonModuleComp";
|
||
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
|
||
import { SkillSet } from "../common/config/SkillSet";
|
||
|
||
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 = 1;
|
||
skill_name_time=0.5;
|
||
start() {
|
||
this.node.getChildByName("loss_life").active=false;
|
||
this.node.getChildByName("add_life").active=false
|
||
this.node.getChildByName("skill").active=false;
|
||
// console.log("TooltipView start",this.node);
|
||
switch(this.stype){
|
||
case 1:
|
||
this.node.getChildByName("loss_life").getChildByName("hp").getComponent(Label).string = this.value;
|
||
this.node.getChildByName("loss_life").active=true;
|
||
tween(this.node).to(
|
||
this.alive_time,
|
||
{position:v3(this.node.position.x+10,this.node.position.y+40), },
|
||
{
|
||
onComplete:()=>{ this.ent.destroy()},
|
||
easing:"linear"
|
||
}
|
||
).start()
|
||
break
|
||
case 2:
|
||
this.node.getChildByName("add_life").getChildByName("hp").getComponent(Label).string = this.value;
|
||
this.node.getChildByName("add_life").active=true;
|
||
tween(this.node).to(
|
||
this.alive_time,
|
||
{position:v3(this.node.position.x+10,this.node.position.y+40), },
|
||
{
|
||
onComplete:()=>{ this.ent.destroy()},
|
||
easing:"linear"
|
||
}
|
||
).start()
|
||
break
|
||
case 3:
|
||
|
||
this.node.getChildByName("skill").getChildByName("name").getComponent(Label).string = smc.skills[this.s_uuid].name;
|
||
this.node.getChildByName("skill").active=true;
|
||
this.node.setPosition(v3(this.node.position.x,this.node.position.y+60))
|
||
// this.alive_time = 2
|
||
tween(this.node).to(
|
||
this.alive_time,
|
||
{position:v3(this.node.position.x,this.node.position.y), },
|
||
{
|
||
onComplete:()=>{ this.ent.destroy()},
|
||
easing:"linear"
|
||
}
|
||
).start()
|
||
break
|
||
}
|
||
}
|
||
|
||
update(deltaTime: number) {
|
||
|
||
}
|
||
|
||
|
||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||
reset() {
|
||
this.node.getChildByName("loss_life").active=false;
|
||
this.node.getChildByName("add_life").active=false;
|
||
this.node.getChildByName("skill").active=false;
|
||
this.node.destroy();
|
||
}
|
||
} |