技能运动需要完善
This commit is contained in:
@@ -60,11 +60,16 @@ export class CSkillComp extends CCComp {
|
||||
let t_pos = v3(0,0)
|
||||
let angle = 0
|
||||
let m_pos=v3(0,0)
|
||||
let target:any = null
|
||||
let eid=0
|
||||
let monsters:any = ecs.query(ecs.allOf(MonModelComp));
|
||||
if (monsters.length > 0) {
|
||||
m_pos = monsters[0].MonView.node.position
|
||||
target= monsters[0].MonView.node
|
||||
eid = monsters[0].MonView.eid
|
||||
|
||||
}else{
|
||||
return
|
||||
m_pos = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE)
|
||||
}
|
||||
t_pos = v3(m_pos.x-this.node.position.x,m_pos.y-this.node.position.y) // 目标增量
|
||||
@@ -77,7 +82,7 @@ export class CSkillComp extends CCComp {
|
||||
let dis = smc.skills[this.skill_uuid].dis+this.dis;
|
||||
let atk = smc.skills[this.skill_uuid].atk+this.atk;
|
||||
let speed = smc.skills[this.skill_uuid].speed+this.speed;
|
||||
skill.load(pos,speed,dis,scale,this.node,this.skill_uuid,atk,angle,t_pos);
|
||||
skill.load(eid,target,pos,speed,dis,scale,this.node,this.skill_uuid,atk,angle,t_pos);
|
||||
}
|
||||
add_buff(){
|
||||
// 1: 远距离攻击,碰撞后 结束
|
||||
|
||||
@@ -29,10 +29,10 @@ export class Skill extends ecs.Entity {
|
||||
this.remove(SkillCom);
|
||||
super.destroy();
|
||||
}
|
||||
load(pos: Vec3 = Vec3.ZERO,speed:number = 100,
|
||||
load(target_eid:number,target:any,pos: Vec3 = Vec3.ZERO,speed:number = 100,
|
||||
dis:number = 50,scale:number = 1,parent:Node,
|
||||
uuid:number=1001,atk:number =10,angle = 0,
|
||||
t_pos:Vec3 = null,run_type:number=0)
|
||||
t_pos:Vec3 = null,run_type:number=0,)
|
||||
{
|
||||
var path = "game/skills/"+smc.skills[uuid].sp_name;
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
@@ -53,6 +53,8 @@ export class Skill extends ecs.Entity {
|
||||
sv.type = smc.skills[uuid].type;
|
||||
sv.box_tag= BoxSet.SKILL_TAG;
|
||||
sv.run_type== run_type;
|
||||
sv.target=target;
|
||||
sv.target_eid=target_eid
|
||||
if(scale == 1){
|
||||
sv.box_group=BoxSet.HERO
|
||||
}else{
|
||||
|
||||
@@ -4,6 +4,9 @@ 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 { MoveToComp } from "../common/ecs/position/MoveTo";
|
||||
import { MonModelComp } from "../mon/MonModelComp";
|
||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -25,6 +28,8 @@ export class SkillCom extends CCComp {
|
||||
atk_count:number = 0;
|
||||
angle:number = 0;
|
||||
t_pos:Vec3 = null; // 目标增量
|
||||
target:any =null
|
||||
target_eid:number = 0;
|
||||
is_destroy:boolean = false;
|
||||
box_group:number = 0;
|
||||
box_tag:number=0;
|
||||
@@ -48,63 +53,63 @@ export class SkillCom extends CCComp {
|
||||
// collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
|
||||
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
|
||||
}
|
||||
if(this.t_pos){
|
||||
this.x_speed=Math.cos(this.angle * Math.PI / 180) * this.speed-30*this.scale;
|
||||
this.y_speed=Math.sin(this.angle * Math.PI / 180) * this.speed;
|
||||
}else{
|
||||
this.x_speed=this.speed
|
||||
this.y_speed=0
|
||||
}
|
||||
if(this.run_type == 1){
|
||||
let s_pos = v3(this.node.position.x,this.node.position.y)
|
||||
let c_pos = v3(this.node.position.x,this.node.position.y)
|
||||
let e_pos = v3(this.node.position.x+this.dis*this.scale,BoxSet.GAME_LINE-50)
|
||||
SkillCom.bezierTo(this.node,2,s_pos,c_pos,e_pos,{onUpdate: (target: Vec3, ratio: number) => {
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
if(this.run_type == 2){
|
||||
tween(this.node).to( this.in_time,
|
||||
{ position: new Vec3(this.node.position.x,this.node.position.y) },
|
||||
{
|
||||
onComplete: (target?: object) => {
|
||||
this.is_destroy=true
|
||||
},
|
||||
}
|
||||
).start();
|
||||
}
|
||||
if(this.run_type == 0){
|
||||
if(this.t_pos){
|
||||
let l_x=Math.cos(this.angle * Math.PI / 180) * 50;
|
||||
let l_y=Math.sin(this.angle * Math.PI / 180) * 50;
|
||||
let squaredDistance = this.t_pos.x * this.t_pos.x + this.t_pos.y * this.t_pos.y;
|
||||
let distance = Math.sqrt(squaredDistance);
|
||||
let time = distance / this.speed-0.2;
|
||||
//通过欧拉角 延长 目标点 增量
|
||||
// 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;
|
||||
let e_pos=v3(this.node.position.x+l_x+this.t_pos.x,this.node.position.y+this.t_pos.y)
|
||||
tween(this.node).to( 0.7,{ angle:this.angle,position: e_pos},
|
||||
{
|
||||
onUpdate: (target: Vec3, ratio: number) => { // onUpdate 接受当前缓动的进度
|
||||
// 将缓动系统计算出的结果赋予 node 的位置
|
||||
},
|
||||
onComplete: (target?: object) => {
|
||||
this.is_destroy=true
|
||||
},
|
||||
}
|
||||
).start();
|
||||
}else{
|
||||
tween(this.node).to( this.dis/this.speed,
|
||||
{ position: new Vec3(this.node.position.x+this.scale*this.dis,this.node.position.y) },
|
||||
{
|
||||
onComplete: (target?: object) => {
|
||||
this.is_destroy=true
|
||||
},
|
||||
}
|
||||
).start();
|
||||
}
|
||||
}
|
||||
// if(this.t_pos){
|
||||
// this.x_speed=Math.cos(this.angle * Math.PI / 180) * this.speed-30*this.scale;
|
||||
// this.y_speed=Math.sin(this.angle * Math.PI / 180) * this.speed;
|
||||
// }else{
|
||||
// this.x_speed=this.speed
|
||||
// this.y_speed=0
|
||||
// }
|
||||
// if(this.run_type == 1){
|
||||
// let s_pos = v3(this.node.position.x,this.node.position.y)
|
||||
// let c_pos = v3(this.node.position.x,this.node.position.y)
|
||||
// let e_pos = v3(this.node.position.x+this.dis*this.scale,BoxSet.GAME_LINE-50)
|
||||
// SkillCom.bezierTo(this.node,2,s_pos,c_pos,e_pos,{onUpdate: (target: Vec3, ratio: number) => {
|
||||
// }
|
||||
// }).start();
|
||||
// }
|
||||
// if(this.run_type == 2){
|
||||
// tween(this.node).to( this.in_time,
|
||||
// { position: new Vec3(this.node.position.x,this.node.position.y) },
|
||||
// {
|
||||
// onComplete: (target?: object) => {
|
||||
// this.is_destroy=true
|
||||
// },
|
||||
// }
|
||||
// ).start();
|
||||
// }
|
||||
// if(this.run_type == 0){
|
||||
// if(this.t_pos){
|
||||
// let l_x=Math.cos(this.angle * Math.PI / 180) * 50;
|
||||
// let l_y=Math.sin(this.angle * Math.PI / 180) * 50;
|
||||
// let squaredDistance = this.t_pos.x * this.t_pos.x + this.t_pos.y * this.t_pos.y;
|
||||
// let distance = Math.sqrt(squaredDistance);
|
||||
// let time = distance / this.speed-0.2;
|
||||
// //通过欧拉角 延长 目标点 增量
|
||||
// // 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;
|
||||
// let e_pos=v3(this.node.position.x+l_x+this.t_pos.x,this.node.position.y+this.t_pos.y)
|
||||
// tween(this.node).to( 0.7,{ angle:this.angle,position: e_pos},
|
||||
// {
|
||||
// onUpdate: (target: Vec3, ratio: number) => { // onUpdate 接受当前缓动的进度
|
||||
// // 将缓动系统计算出的结果赋予 node 的位置
|
||||
// },
|
||||
// onComplete: (target?: object) => {
|
||||
// this.is_destroy=true
|
||||
// },
|
||||
// }
|
||||
// ).start();
|
||||
// }else{
|
||||
// tween(this.node).to( this.dis/this.speed,
|
||||
// { position: new Vec3(this.node.position.x+this.scale*this.dis,this.node.position.y) },
|
||||
// {
|
||||
// onComplete: (target?: object) => {
|
||||
// this.is_destroy=true
|
||||
// },
|
||||
// }
|
||||
// ).start();
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
@@ -147,11 +152,50 @@ export class SkillCom extends CCComp {
|
||||
// this.node.setScale(v3(this.scale,this.node.scale.y,this.node.scale.z))
|
||||
// this.move(deltaTime)
|
||||
this.toDestroy()
|
||||
let enemy_is_alive=false
|
||||
if(this.box_group==BoxSet.HERO){
|
||||
let mons =ecs.query(ecs.allOf(MonModelComp));
|
||||
for(let i=0;i<mons.length;i++){
|
||||
if(mons[i].eid == this.target_eid){
|
||||
enemy_is_alive=true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(this.box_group==BoxSet.MONSTER){
|
||||
let heros =ecs.query(ecs.allOf(HeroViewComp));
|
||||
for(let i=0;i<heros.length;i++){
|
||||
if(heros[i].eid == this.target_eid){
|
||||
enemy_is_alive=true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(enemy_is_alive){
|
||||
this.move_to(this.target)
|
||||
}else{
|
||||
this.ent.destroy()
|
||||
}
|
||||
// this.t_move(deltaTime)
|
||||
if (this.node.position.x > 400||this.node.position.x < -400||this.node.position.y > 1000||this.node.position.y < -100) {
|
||||
this.is_destroy=true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
move_to(target:any){
|
||||
if(target.x > this.node.position.x){
|
||||
this.node.setScale(v3(1,1,1))
|
||||
}else{
|
||||
this.node.setScale(v3(-1,1,1))
|
||||
}
|
||||
var move = this.ent.get(MoveToComp) || this.ent.add(MoveToComp);
|
||||
move.target = v3(target.x,target.y);
|
||||
move.node = this.node;
|
||||
move.speed = this.speed;
|
||||
}
|
||||
|
||||
|
||||
t_move(dt: number){
|
||||
if( this.run_type!=0){
|
||||
return
|
||||
|
||||
@@ -29,7 +29,7 @@ export class Tooltip extends ecs.Entity {
|
||||
this.remove(TooltipCom);
|
||||
super.destroy();
|
||||
}
|
||||
load(pos: Vec3 = Vec3.ZERO,type:number=1,vaule:string="",s_uuid:number=1001,parent:any=null,cd:number=0.3) {
|
||||
load(pos: Vec3 = Vec3.ZERO,type:number=1,vaule:string="",s_uuid:number=1001,parent:any=null,cd:number=1) {
|
||||
|
||||
var path = "game/skills/tooltip";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
|
||||
@@ -31,39 +31,46 @@ export class TooltipCom extends CCComp {
|
||||
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;
|
||||
this.node.setPosition(v3(this.node.position.x,this.node.position.y+50))
|
||||
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:
|
||||
// resources.load("game/heros/skill/"+smc.skills[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 = smc.skills[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))
|
||||
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) {
|
||||
this.node.setPosition(v3(this.node.position.x+deltaTime*20,this.node.position.y+deltaTime*50))
|
||||
if(this.alive_time >=0){
|
||||
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;
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user