技能弹道完善
This commit is contained in:
@@ -92,7 +92,7 @@
|
|||||||
},
|
},
|
||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": -52.535,
|
"x": 0,
|
||||||
"y": 0,
|
"y": 0,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
@@ -287,13 +287,13 @@
|
|||||||
"_restitution": 0,
|
"_restitution": 0,
|
||||||
"_offset": {
|
"_offset": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
"x": 1.2,
|
"x": 0,
|
||||||
"y": 0.3
|
"y": 0
|
||||||
},
|
},
|
||||||
"_size": {
|
"_size": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
"width": 28.9,
|
"width": 15,
|
||||||
"height": 86.1
|
"height": 80
|
||||||
},
|
},
|
||||||
"_id": ""
|
"_id": ""
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -92,7 +92,7 @@
|
|||||||
},
|
},
|
||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": -52.535,
|
"x": 0,
|
||||||
"y": 0,
|
"y": 0,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
@@ -287,13 +287,13 @@
|
|||||||
"_restitution": 0,
|
"_restitution": 0,
|
||||||
"_offset": {
|
"_offset": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
"x": 15.2,
|
"x": 0,
|
||||||
"y": 0.3
|
"y": 0
|
||||||
},
|
},
|
||||||
"_size": {
|
"_size": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
"width": 28.9,
|
"width": 15,
|
||||||
"height": 86.1
|
"height": 80
|
||||||
},
|
},
|
||||||
"_id": ""
|
"_id": ""
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,8 +29,10 @@ export enum BoxSet {
|
|||||||
//游戏地平线
|
//游戏地平线
|
||||||
GAME_LINE = 10,
|
GAME_LINE = 10,
|
||||||
CSKILL_X = 280,
|
CSKILL_X = 280,
|
||||||
CSKILL_Y = 420,
|
CSKILL_Y = 300,
|
||||||
//攻击距离
|
//攻击距离
|
||||||
ATK_RANGE_X = 85,
|
ATK_RANGE_X = 85,
|
||||||
MOVE_RANGE_X = 20,
|
MOVE_RANGE_X = 20,
|
||||||
|
MAX_SKILL_SY = 50,
|
||||||
|
MAX_SKILL_BY = 80,
|
||||||
}
|
}
|
||||||
@@ -197,7 +197,7 @@ export class MonsterViewComp extends CCComp {
|
|||||||
do_max_skill(){
|
do_max_skill(){
|
||||||
let skill = ecs.getEntity<Skill>(Skill);
|
let skill = ecs.getEntity<Skill>(Skill);
|
||||||
let x=32
|
let x=32
|
||||||
let pos = v3(35*this.scale,40)
|
let pos = v3(-40*this.scale,BoxSet.MAX_SKILL_SY)
|
||||||
let scale = this.scale
|
let scale = this.scale
|
||||||
let speed =smc.skills[this.max_skill_uuid].speed;
|
let speed =smc.skills[this.max_skill_uuid].speed;
|
||||||
let dis = smc.skills[this.max_skill_uuid].dis;
|
let dis = smc.skills[this.max_skill_uuid].dis;
|
||||||
|
|||||||
@@ -29,7 +29,11 @@ export class Skill extends ecs.Entity {
|
|||||||
this.remove(SkillCom);
|
this.remove(SkillCom);
|
||||||
super.destroy();
|
super.destroy();
|
||||||
}
|
}
|
||||||
load(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) {
|
load(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)
|
||||||
|
{
|
||||||
var path = "game/skills/"+smc.skills[uuid].sp_name;
|
var path = "game/skills/"+smc.skills[uuid].sp_name;
|
||||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||||
var node = instantiate(prefab);
|
var node = instantiate(prefab);
|
||||||
@@ -48,6 +52,7 @@ export class Skill extends ecs.Entity {
|
|||||||
sv.t_pos = t_pos; // 目标增量
|
sv.t_pos = t_pos; // 目标增量
|
||||||
sv.type = smc.skills[uuid].type;
|
sv.type = smc.skills[uuid].type;
|
||||||
sv.box_tag= BoxSet.SKILL_TAG;
|
sv.box_tag= BoxSet.SKILL_TAG;
|
||||||
|
sv.run_type== run_type;
|
||||||
if(scale == 1){
|
if(scale == 1){
|
||||||
sv.box_group=BoxSet.HERO
|
sv.box_group=BoxSet.HERO
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export class SkillCom extends CCComp {
|
|||||||
dis:number = 80;
|
dis:number = 80;
|
||||||
scale:number = 1;
|
scale:number = 1;
|
||||||
atk:number = 10;
|
atk:number = 10;
|
||||||
|
atk_count:number = 0;
|
||||||
angle:number = 0;
|
angle:number = 0;
|
||||||
t_pos:Vec3 = null; // 目标增量
|
t_pos:Vec3 = null; // 目标增量
|
||||||
is_destroy:boolean = false;
|
is_destroy:boolean = false;
|
||||||
@@ -29,6 +30,8 @@ export class SkillCom extends CCComp {
|
|||||||
box_tag:number=0;
|
box_tag:number=0;
|
||||||
type:number = 1;
|
type:number = 1;
|
||||||
time:Timer = new Timer(0.01);
|
time:Timer = new Timer(0.01);
|
||||||
|
run_type:number = 0; // 0直线,1贝塞尔曲线 2 不动
|
||||||
|
in_time:number = 1.5; // 不动技能持续时间
|
||||||
start() {
|
start() {
|
||||||
// console.log("skill start parent :",this.node.parent)
|
// console.log("skill start parent :",this.node.parent)
|
||||||
// console.log("skill start t position :",this.t_pos)
|
// console.log("skill start t position :",this.t_pos)
|
||||||
@@ -46,46 +49,67 @@ export class SkillCom extends CCComp {
|
|||||||
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
|
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
|
||||||
}
|
}
|
||||||
if(this.t_pos){
|
if(this.t_pos){
|
||||||
this.x_speed=this.t_pos.x;
|
this.x_speed=Math.cos(this.angle * Math.PI / 180) * this.speed-30*this.scale;
|
||||||
this.y_speed=this.t_pos.y;
|
this.y_speed=Math.sin(this.angle * Math.PI / 180) * this.speed;
|
||||||
}else{
|
}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 s_pos = v3(this.node.position.x,this.node.position.y)
|
||||||
let c_pos = v3(this.node.position.x,this.node.position.y+200)
|
let c_pos = v3(this.node.position.x,this.node.position.y)
|
||||||
let e_pos = v3(this.node.position.x+100*this.scale,BoxSet.GAME_LINE-50)
|
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) => {
|
SkillCom.bezierTo(this.node,2,s_pos,c_pos,e_pos,{onUpdate: (target: Vec3, ratio: number) => {
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
if(this.run_type == 2){
|
||||||
// if(this.t_pos){
|
tween(this.node).to( this.in_time,
|
||||||
// //通过欧拉角 延长 目标点 增量
|
{ position: new Vec3(this.node.position.x,this.node.position.y) },
|
||||||
// // 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;
|
onComplete: (target?: object) => {
|
||||||
|
this.is_destroy=true
|
||||||
// tween(this.node).to( 0.5,{ angle:this.angle,position: this.t_pos},
|
},
|
||||||
// {
|
}
|
||||||
// onUpdate: (target: Vec3, ratio: number) => { // onUpdate 接受当前缓动的进度
|
).start();
|
||||||
// // 将缓动系统计算出的结果赋予 node 的位置
|
}
|
||||||
// },
|
if(this.run_type == 0){
|
||||||
// onComplete: (target?: object) => {
|
if(this.t_pos){
|
||||||
// this.is_destroy=true
|
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;
|
||||||
// ).start();
|
let distance = Math.sqrt(squaredDistance);
|
||||||
// }else{
|
let time = distance / this.speed-0.2;
|
||||||
// tween(this.node).to( this.dis/this.speed,
|
//通过欧拉角 延长 目标点 增量
|
||||||
// { position: new Vec3(this.node.position.x+this.scale*this.dis,this.node.position.y) },
|
// 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;
|
||||||
// onComplete: (target?: object) => {
|
let e_pos=v3(this.node.position.x+l_x+this.t_pos.x,this.node.position.y+this.t_pos.y)
|
||||||
// this.is_destroy=true
|
tween(this.node).to( 0.7,{ angle:this.angle,position: e_pos},
|
||||||
// },
|
{
|
||||||
// }
|
onUpdate: (target: Vec3, ratio: number) => { // onUpdate 接受当前缓动的进度
|
||||||
// ).start();
|
// 将缓动系统计算出的结果赋予 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) {
|
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||||
if(otherCollider.group != selfCollider.group&&otherCollider.tag !=BoxSet.ATK_RANGE&&otherCollider.tag !=BoxSet.SKILL_TAG){
|
if(otherCollider.group != selfCollider.group&&otherCollider.tag !=BoxSet.ATK_RANGE&&otherCollider.tag !=BoxSet.SKILL_TAG){
|
||||||
|
this.atk_count+=1
|
||||||
// console.log("skill onBeginContact",selfCollider.group,otherCollider.group)
|
// console.log("skill onBeginContact",selfCollider.group,otherCollider.group)
|
||||||
if(this.type==1 ){
|
if(this.type==1 ){
|
||||||
this.is_destroy=true
|
this.is_destroy=true
|
||||||
@@ -123,19 +147,21 @@ export class SkillCom extends CCComp {
|
|||||||
// this.node.setScale(v3(this.scale,this.node.scale.y,this.node.scale.z))
|
// this.node.setScale(v3(this.scale,this.node.scale.y,this.node.scale.z))
|
||||||
// this.move(deltaTime)
|
// this.move(deltaTime)
|
||||||
this.toDestroy()
|
this.toDestroy()
|
||||||
this.t_move(deltaTime)
|
// this.t_move(deltaTime)
|
||||||
|
|
||||||
if (this.node.position.x > 400||this.node.position.x < -400||this.node.position.y > 1000||this.node.position.y < BoxSet.GAME_LINE) {
|
if (this.node.position.x > 400||this.node.position.x < -400||this.node.position.y > 1000||this.node.position.y < BoxSet.GAME_LINE) {
|
||||||
this.is_destroy=true
|
this.is_destroy=true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t_move(dt: number){
|
t_move(dt: number){
|
||||||
if(!this.t_pos){
|
if( this.run_type!=0){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.node.setPosition(v3(this.node.position.x+this.x_speed*dt*this.scale,this.node.position.y+this.y_speed*dt))
|
this.node.setPosition(v3(this.node.position.x+this.x_speed*dt*this.scale,this.node.position.y+this.y_speed*dt))
|
||||||
}
|
}
|
||||||
line_move(dt: number) {
|
line_move(dt: number) {
|
||||||
|
if( this.run_type!=0 && this.t_pos){
|
||||||
|
return
|
||||||
|
}
|
||||||
this.node.setPosition(v3(this.node.position.x+dt*this.speed*this.scale,this.node.position.y))
|
this.node.setPosition(v3(this.node.position.x+dt*this.speed*this.scale,this.node.position.y))
|
||||||
}
|
}
|
||||||
bezier(t:number){
|
bezier(t:number){
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export class TooltipCom extends CCComp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update(deltaTime: number) {
|
update(deltaTime: number) {
|
||||||
this.node.setPosition(v3(this.node.position.x,this.node.position.y+deltaTime*10))
|
this.node.setPosition(v3(this.node.position.x+deltaTime*20,this.node.position.y+deltaTime*50))
|
||||||
if(this.alive_time >=0){
|
if(this.alive_time >=0){
|
||||||
this.alive_time -= deltaTime;
|
this.alive_time -= deltaTime;
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
Reference in New Issue
Block a user