dd
This commit is contained in:
@@ -33,7 +33,9 @@ export class Skill extends ecs.Entity {
|
||||
var path = "game/skills/"+SkillSet[uuid].sp_name;
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
node.parent = parent;
|
||||
// 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)
|
||||
//转换pos为世界坐标
|
||||
node.setPosition(pos)
|
||||
@@ -43,7 +45,7 @@ export class Skill extends ecs.Entity {
|
||||
sv.scale = scale;
|
||||
sv.atk = atk;
|
||||
sv.angle = angle;
|
||||
sv.t_pos = t_pos;
|
||||
sv.t_pos = t_pos; // 目标增量
|
||||
sv.type = SkillSet[uuid].type;
|
||||
sv.box_tag= BoxSet.SKILL_TAG;
|
||||
if(scale == 1){
|
||||
@@ -54,12 +56,3 @@ export class Skill extends ecs.Entity {
|
||||
this.add(sv);
|
||||
}
|
||||
}
|
||||
|
||||
/** Skill 模块业务逻辑系统组件,如无业务逻辑处理可删除此对象 */
|
||||
export class EcsSkillSystem extends ecs.System {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
// this.add(new ecs.ComblockSystem());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,14 @@ export class SkillCom extends CCComp {
|
||||
scale:number = 1;
|
||||
atk:number = 10;
|
||||
angle:number = 0;
|
||||
t_pos:Vec3 = null;
|
||||
t_pos:Vec3 = null; // 目标增量
|
||||
is_destroy:boolean = false;
|
||||
box_group:number = 0;
|
||||
box_tag:number=0;
|
||||
type:number = 1;
|
||||
time:Timer = new Timer(0.01);
|
||||
start() {
|
||||
// console.log("skill start position :",this.node.position)
|
||||
this.node.active=true
|
||||
this.node.angle = this.angle;
|
||||
let collider = this.getComponent(Collider2D);
|
||||
@@ -43,7 +44,7 @@ export class SkillCom extends CCComp {
|
||||
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
|
||||
}
|
||||
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},
|
||||
|
||||
40
assets/script/game/skills/Tooltip.ts
Normal file
40
assets/script/game/skills/Tooltip.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { BoxSet } from "../common/config/BoxSet";
|
||||
import { SkillSet } from "../common/config/SkillSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { TooltipCom } from "./TooltipCom";
|
||||
import { instantiate, Node, Prefab, Vec3 ,tween, v3,animation,Label,resources,SpriteFrame,Sprite} from "cc";
|
||||
|
||||
/** Skill 模块 */
|
||||
@ecs.register(`Tooltip`)
|
||||
export class Tooltip extends ecs.Entity {
|
||||
/** ---------- 数据层 ---------- */
|
||||
// SkillModel!: SkillModelComp;
|
||||
|
||||
/** ---------- 业务层 ---------- */
|
||||
// SkillBll!: SkillBllComp;
|
||||
|
||||
/** ---------- 视图层 ---------- */
|
||||
TooltipView!: TooltipCom;
|
||||
|
||||
/** 实始添加的数据层组件 */
|
||||
protected init() {
|
||||
|
||||
}
|
||||
|
||||
/** 模块资源释放 */
|
||||
destroy() {
|
||||
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
|
||||
this.remove(TooltipCom);
|
||||
super.destroy();
|
||||
}
|
||||
load(pos: Vec3 = Vec3.ZERO,type:number=1,vaule:string="",icon:string="") {
|
||||
var path = "game/skills/tooltip";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
node.setPosition(pos)
|
||||
var sv = node.getComponent(TooltipCom)!;
|
||||
this.add(sv)
|
||||
}
|
||||
}
|
||||
9
assets/script/game/skills/Tooltip.ts.meta
Normal file
9
assets/script/game/skills/Tooltip.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "a5e3c618-6636-439e-aa36-d4ee97793b18",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
56
assets/script/game/skills/TooltipCom.ts
Normal file
56
assets/script/game/skills/TooltipCom.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
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";
|
||||
|
||||
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);
|
||||
// }
|
||||
type:number = 1;
|
||||
value:string = "";
|
||||
icon:string = "";
|
||||
alive_time:number = 0.3;
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
this.node.setPosition(v3(this.node.position.x,this.node.position.y+deltaTime*10))
|
||||
if(this.alive_time >=0){
|
||||
this.alive_time -= deltaTime;
|
||||
}else{
|
||||
this.ent.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
9
assets/script/game/skills/TooltipCom.ts.meta
Normal file
9
assets/script/game/skills/TooltipCom.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "49ffd76d-7069-4947-b170-62cd72619ede",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user