伤害技能添加,技能还需完善
This commit is contained in:
@@ -36,7 +36,7 @@ export class Skill extends ecs.Entity {
|
||||
// console.log("load skill parent.position :",parent.position)
|
||||
pos=v3(parent.position.x+pos.x,parent.position.y+pos.y)
|
||||
node.parent = parent.parent;
|
||||
// node.setScale(scale,1)
|
||||
node.setScale(scale,1)
|
||||
//转换pos为世界坐标
|
||||
node.setPosition(pos)
|
||||
var sv = node.getComponent(SkillCom)!;
|
||||
|
||||
@@ -45,9 +45,9 @@ export class SkillCom extends CCComp {
|
||||
}
|
||||
if(this.t_pos){
|
||||
//通过欧拉角 延长 目标点 增量
|
||||
this.t_pos.x=Math.cos(this.angle * Math.PI / 180) * this.dis;
|
||||
this.t_pos.y=Math.sin(this.angle * Math.PI / 180) * this.dis;
|
||||
tween(this.node).to( 1,{ angle:this.angle,position: this.t_pos},
|
||||
// this.t_pos.x=Math.cos(this.angle * Math.PI / 180) * this.dis;
|
||||
// this.t_pos.y=Math.sin(this.angle * Math.PI / 180) * this.dis;
|
||||
tween(this.node).to( 0.5,{ angle:this.angle,position: this.t_pos},
|
||||
{
|
||||
onUpdate: (target: Vec3, ratio: number) => { // onUpdate 接受当前缓动的进度
|
||||
// 将缓动系统计算出的结果赋予 node 的位置
|
||||
|
||||
@@ -29,12 +29,19 @@ export class Tooltip extends ecs.Entity {
|
||||
this.remove(TooltipCom);
|
||||
super.destroy();
|
||||
}
|
||||
load(pos: Vec3 = Vec3.ZERO,type:number=1,vaule:string="",icon:string="") {
|
||||
load(pos: Vec3 = Vec3.ZERO,type:number=1,vaule:string="",s_uuid:number=1001,parent:any=null,cd:number=0.3) {
|
||||
|
||||
var path = "game/skills/tooltip";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
node.parent = parent;
|
||||
node.setPosition(pos)
|
||||
var sv = node.getComponent(TooltipCom)!;
|
||||
// console.log("load tooltip type",type,vaule,s_uuid);
|
||||
sv.stype = type;
|
||||
sv.value = vaule;
|
||||
sv.s_uuid = s_uuid;
|
||||
sv.alive_time = cd;
|
||||
this.add(sv)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
|
||||
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;
|
||||
|
||||
@@ -16,26 +17,35 @@ export class TooltipCom extends CCComp {
|
||||
// // var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
// // this.on(ModuleEvent.Cmd, this.onHandler, this);
|
||||
// }
|
||||
type:number = 1;
|
||||
stype:number = 1; // 1:减少生命值,2:增加生命值,3:技能图标
|
||||
value:string = "";
|
||||
icon:string = "";
|
||||
alive_time:number = 0.3;
|
||||
s_uuid:number = 1001;
|
||||
alive_time:number = 1;
|
||||
skill_name_time=1;
|
||||
start() {
|
||||
switch(this.type){
|
||||
case 1:
|
||||
this.node.getChildByName("loss_life").getChildByName("hp").getComponent(Label).string = this.value;
|
||||
this.node.getChildByName("loss_life").active=true;
|
||||
case 2:
|
||||
this.node.getChildByName("add_life").getChildByName("hp").getComponent(Label).string = this.value;
|
||||
this.node.getChildByName("add_life").active=true;
|
||||
break
|
||||
case 3:
|
||||
resources.load("game/heros/skill/"+this.icon, SpriteFrame, (err, spriteFrame) => {
|
||||
this.node.getChildByName("skill").getChildByName("icon").getComponent(Sprite).spriteFrame = spriteFrame;
|
||||
});
|
||||
this.node.getChildByName("skill").active=true;
|
||||
break
|
||||
}
|
||||
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;
|
||||
break
|
||||
case 2:
|
||||
this.node.getChildByName("add_life").getChildByName("hp").getComponent(Label).string = this.value;
|
||||
this.node.getChildByName("add_life").active=true;
|
||||
break
|
||||
case 3:
|
||||
// resources.load("game/heros/skill/"+SkillSet[this.s_uuid].path, SpriteFrame, (err, spriteFrame) => {
|
||||
// this.node.getChildByName("skill").getChildByName("icon").getComponent(Sprite).spriteFrame = spriteFrame;
|
||||
// });
|
||||
this.node.getChildByName("skill").getChildByName("name").getComponent(Label).string = SkillSet[this.s_uuid].name;
|
||||
this.node.getChildByName("skill").active=true;
|
||||
// this.alive_time = 2
|
||||
this.node.setPosition(v3(this.node.position.x,this.node.position.y+50))
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
@@ -44,13 +54,23 @@ export class TooltipCom extends CCComp {
|
||||
this.alive_time -= deltaTime;
|
||||
}else{
|
||||
this.ent.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if(this.skill_name_time >=0){
|
||||
// this.skill_name_time -= deltaTime;
|
||||
// }else{
|
||||
// if(this.node.getChildByName("skill").active== true){
|
||||
// this.node.getChildByName("skill").getChildByName("name").active=false;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
/** 视图对象通过 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user