加血技能完成 怪物动画减少
This commit is contained in:
@@ -73,10 +73,8 @@ export class CSkillComp extends CCComp {
|
||||
let randian=Math.atan2(dir.y,dir.x)
|
||||
angle = randian * (180 / Math.PI);
|
||||
let scale = this.scale
|
||||
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(pos,scale,this.node,this.skill_uuid,atk,angle,t_pos);
|
||||
}
|
||||
add_buff(){
|
||||
// 1: 远距离攻击,碰撞后 结束
|
||||
|
||||
@@ -29,35 +29,50 @@ export class Skill extends ecs.Entity {
|
||||
this.remove(SkillCom);
|
||||
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,run_type:number=0,)
|
||||
load(pos: Vec3 = Vec3.ZERO,group:number,parent:Node,
|
||||
uuid:number=1001,atk:number =10,t_pos:Vec3 = null)
|
||||
|
||||
{
|
||||
var path = "game/skills/"+smc.skills[uuid].sp_name;
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
// console.log("load skill :",path,prefab)
|
||||
var node = instantiate(prefab);
|
||||
// console.log("load skill parent.position :",parent.position)
|
||||
pos=v3(pos.x,pos.y)
|
||||
node.parent = parent;
|
||||
node.setScale(scale,1)
|
||||
//转换pos为世界坐标
|
||||
node.setPosition(pos)
|
||||
var sv = node.getComponent(SkillCom)!;
|
||||
sv.speed = speed;
|
||||
sv.dis = dis;
|
||||
sv.scale = scale;
|
||||
sv.atk = atk;
|
||||
let scale =1
|
||||
if(t_pos.x < pos.x){
|
||||
scale= - 1
|
||||
}
|
||||
let angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
|
||||
if(scale == -1){
|
||||
angle = angle +180
|
||||
}
|
||||
if(!smc.skills[uuid].angle){
|
||||
angle=0
|
||||
}
|
||||
sv.angle = angle;
|
||||
console.log(smc.skills[uuid].name+"angle:"+angle)
|
||||
sv.s_uuid = uuid;
|
||||
sv.atk = atk;
|
||||
node.setScale(v3(node.scale.x*scale,node.scale.y))
|
||||
|
||||
sv.speed=smc.skills[uuid].speed;
|
||||
sv.dis=smc.skills[uuid].dis;
|
||||
sv.run_type=smc.skills[uuid].run;
|
||||
if(sv.dis == 0){
|
||||
sv.run_type=2
|
||||
}
|
||||
|
||||
sv.in_time=smc.skills[uuid].in;
|
||||
|
||||
sv.t_pos = t_pos; // 目标增量
|
||||
sv.type = smc.skills[uuid].type;
|
||||
sv.box_tag= BoxSet.SKILL_TAG;
|
||||
sv.run_type== run_type;
|
||||
if(scale == 1){
|
||||
sv.box_group=BoxSet.HERO
|
||||
}else{
|
||||
sv.box_group=BoxSet.MONSTER
|
||||
}
|
||||
sv.box_group=group
|
||||
// console.log("load skill :",sv)
|
||||
this.add(sv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { _decorator,Collider2D ,Contact2DType,v3,IPhysics2DContact,Vec3, tween} from "cc";
|
||||
import { _decorator,Collider2D ,Contact2DType,v3,IPhysics2DContact,Vec3, tween, math} 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";
|
||||
@@ -7,6 +7,7 @@ import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/
|
||||
import { MoveToComp } from "../common/ecs/position/MoveTo";
|
||||
import { MonModelComp } from "../mon/MonModelComp";
|
||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||
import { SkillSet } from "../common/config/SkillSet";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -19,6 +20,7 @@ export class SkillCom extends CCComp {
|
||||
// // var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
// // this.on(ModuleEvent.Cmd, this.onHandler, this);
|
||||
// }
|
||||
s_uuid:number = 0;
|
||||
speed:number = 200;
|
||||
y_speed:number = 0;
|
||||
x_speed:number = 0;
|
||||
@@ -27,23 +29,24 @@ export class SkillCom extends CCComp {
|
||||
atk:number = 10;
|
||||
atk_count:number = 0;
|
||||
angle:number = 0;
|
||||
t_pos:Vec3 = null; // 目标增量
|
||||
t_pos:Vec3 = v3(0,0,0); // 目标增量
|
||||
is_destroy:boolean = false;
|
||||
box_group:number = 0;
|
||||
box_tag:number=0;
|
||||
type:number = 1;
|
||||
time:Timer = new Timer(0.01);
|
||||
run_type:number = 0; // 0直线,1贝塞尔曲线 2 不动
|
||||
in_time:number = 1.5; // 不动技能持续时间
|
||||
in_time:number = 0.3; // 不动技能持续时间
|
||||
start() {
|
||||
// console.log("skill start parent :",this.node.parent)
|
||||
// console.log("skill start t position :",this.t_pos)
|
||||
|
||||
// console.log("skill start run_type",this.run_type)
|
||||
|
||||
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;
|
||||
this.node.active=true
|
||||
this.node.angle = this.angle;
|
||||
|
||||
let collider = this.getComponent(Collider2D);
|
||||
collider.group = this.box_group;
|
||||
// console.log("skill group",this.box_group)
|
||||
|
||||
collider.tag = this.box_tag;
|
||||
collider.sensor = true;
|
||||
if (collider) {
|
||||
@@ -51,22 +54,40 @@ 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 == 0){ //直线,默认直线,有特定目标 朝向目标直线
|
||||
let time = 720 / this.speed;
|
||||
let squaredDistance = this.t_pos.x * this.t_pos.x + this.t_pos.y * this.t_pos.y;
|
||||
let distance = Math.sqrt(squaredDistance);
|
||||
time = distance / this.speed;
|
||||
let e_pos=v3(this.node.position.x+this.t_pos.x,this.node.position.y+this.t_pos.y)
|
||||
|
||||
tween(this.node).to( time,{ angle:this.angle,position: e_pos},
|
||||
{
|
||||
easing: "linear",
|
||||
onUpdate: (target: Vec3, ratio: number) => { },
|
||||
onComplete: (target?: object) => {
|
||||
this.is_destroy=true
|
||||
},
|
||||
}
|
||||
).start();
|
||||
}
|
||||
if(this.run_type == 1){
|
||||
// console.log("skill run_type",this.run_type)
|
||||
if(this.run_type == 1){ //贝塞尔曲线
|
||||
console.log("skill bezierTo",this.t_pos)
|
||||
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) => {
|
||||
}
|
||||
let c_pos = v3((this.t_pos.x+this.node.position.x)/2,this.node.position.y+100)
|
||||
let e_pos = v3(this.node.position.x+this.t_pos.x,this.node.position.y+this.t_pos.y)
|
||||
let time =Math.abs(this.t_pos.x/this.speed)
|
||||
SkillCom.bezierTo(this.node,time,s_pos,c_pos,e_pos,{
|
||||
onComplete: (target?: object) => {
|
||||
this.is_destroy=true
|
||||
},
|
||||
}).start();
|
||||
}
|
||||
if(this.run_type == 2){
|
||||
|
||||
if(this.run_type == 2){ //原地不动的
|
||||
tween(this.node).to( this.in_time,
|
||||
{ position: new Vec3(this.node.position.x,this.node.position.y) },
|
||||
{
|
||||
@@ -76,38 +97,6 @@ export class SkillCom extends CCComp {
|
||||
}
|
||||
).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) {
|
||||
@@ -120,40 +109,13 @@ export class SkillCom extends CCComp {
|
||||
}
|
||||
}
|
||||
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
// console.log("skill post contact")
|
||||
// switch (selfCollider.group) {
|
||||
|
||||
// case BoxSet.HERO:
|
||||
// switch (otherCollider.group){
|
||||
// case BoxSet.MONSTER:
|
||||
// case BoxSet.DEFAULT:
|
||||
// setTimeout(() => {
|
||||
// this.toDestroy()
|
||||
// }, 10);
|
||||
// break
|
||||
// }
|
||||
// break;
|
||||
// case BoxSet.MONSTER:
|
||||
// switch (otherCollider.group){
|
||||
// case BoxSet.PLAYER:
|
||||
// case BoxSet.HERO:
|
||||
// case BoxSet.DEFAULT:
|
||||
// setTimeout(() => {
|
||||
// this.toDestroy()
|
||||
// }, 10);
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
// this.node.setScale(v3(this.scale,this.node.scale.y,this.node.scale.z))
|
||||
// this.move(deltaTime)
|
||||
|
||||
this.toDestroy()
|
||||
// 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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
t_move(dt: number){
|
||||
|
||||
29
assets/script/game/skills/anonce.ts
Normal file
29
assets/script/game/skills/anonce.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { _decorator, Component, Node, sp ,Animation, AnimationState} from 'cc';
|
||||
import { Timer } from '../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer';
|
||||
const { ccclass, property ,} = _decorator;
|
||||
|
||||
@ccclass('anonce')
|
||||
export class anonce extends Component {
|
||||
|
||||
timer:Timer=new Timer(0.5);
|
||||
|
||||
start() {
|
||||
|
||||
}
|
||||
protected onLoad(): void {
|
||||
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
if(this.node.active){
|
||||
if(!this.node.getChildByName("skill").getComponent(Animation).getState("heathed").isPlaying){
|
||||
this.node.getChildByName("skill").getComponent(Animation).play();
|
||||
}
|
||||
if (this.timer.update(deltaTime)) {
|
||||
this.node.active=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
9
assets/script/game/skills/anonce.ts.meta
Normal file
9
assets/script/game/skills/anonce.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "9df173c3-eed0-4d48-9c27-e2ead9a9f68f",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user