技能运动需要完善

This commit is contained in:
2024-09-12 11:14:37 +08:00
parent a847611240
commit 1c9aa38385
212 changed files with 531 additions and 62599 deletions

View File

@@ -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