技能动画添加
This commit is contained in:
@@ -4,29 +4,17 @@ const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('LineCom')
|
||||
export class LineCom extends Component {
|
||||
base:SkillCom = null
|
||||
start() {
|
||||
let base =this.node.getComponent(SkillCom)
|
||||
let time = 720 / base.speed;
|
||||
let squaredDistance = base.t_pos.x * base.t_pos.x + base.t_pos.y * base.t_pos.y;
|
||||
let distance = Math.sqrt(squaredDistance);
|
||||
time = distance / base.speed;
|
||||
let e_pos=v3(this.node.position.x+base.t_pos.x,this.node.position.y+base.t_pos.y)
|
||||
// console.log("skill tx:"+e_pos.x+" node :"+this.node.position.x)
|
||||
this.node.getChildByName("skill").setRotationFromEuler(0,0,base.angle)
|
||||
// console.log("skill ",this.node.getRotation())
|
||||
tween(this.node).to( time,{ position: e_pos},
|
||||
{
|
||||
easing: "linear",
|
||||
onUpdate: (target: Vec3, ratio: number) => { },
|
||||
onComplete: (target?: object) => {
|
||||
base.is_destroy=true
|
||||
},
|
||||
}
|
||||
).start();
|
||||
this.base =this.node.getComponent(SkillCom)
|
||||
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
this.node.setPosition(this.node.position.x+this.base.speed*deltaTime,this.node.position.y,this.node.position.z)
|
||||
if(this.node.position.x>1000||this.node.position.x<-1000){
|
||||
this.base.is_destroy = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,18 +31,23 @@ export class Skill extends ecs.Entity {
|
||||
pos=v3(pos.x,pos.y)
|
||||
node.parent = parent;
|
||||
node.setPosition(pos)
|
||||
var sv = node.getComponent(SkillCom)!;
|
||||
let angle=0
|
||||
if(SkillSet[uuid].angle){
|
||||
angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
|
||||
if(t_pos.x<0){
|
||||
angle+=180
|
||||
}
|
||||
}
|
||||
sv.angle = angle;
|
||||
console.log(group+" "+SkillSet[uuid].name+"angle:"+angle)
|
||||
var sv = node.getComponent(SkillCom);
|
||||
// let angle=0
|
||||
// if(SkillSet[uuid].angle){
|
||||
// angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
|
||||
// if(t_pos.x<0){
|
||||
// angle+=180
|
||||
// }
|
||||
// }
|
||||
// sv.angle = angle;
|
||||
// console.log(group+" "+SkillSet[uuid].name+"angle:"+angle)
|
||||
sv.s_uuid = uuid;
|
||||
sv.ap = ap;
|
||||
sv.s_name = SkillSet[uuid].name;
|
||||
sv.ap = ap*SkillSet[uuid].ap;
|
||||
sv.cd = SkillSet[uuid].cd;
|
||||
sv.decd = SkillSet[uuid].decd;
|
||||
sv.debuff = SkillSet[uuid].debuff;
|
||||
sv.rate = SkillSet[uuid].rate;
|
||||
sv.is_crit=is_crit
|
||||
sv.crit_add=crit_add
|
||||
// node.setScale(v3(node.scale.x*scale,node.scale.y))
|
||||
|
||||
@@ -14,9 +14,14 @@ const { ccclass, property } = _decorator;
|
||||
@ecs.register('SkillView', false)
|
||||
export class SkillCom extends CCComp {
|
||||
s_uuid:number = 0;
|
||||
s_name:string = "";
|
||||
speed:number = 200;
|
||||
scale:number = 1;
|
||||
ap:number = 10;
|
||||
cd:number = 1;
|
||||
debuff:number = 0;
|
||||
decd:number = 0;
|
||||
rate:number = 0;
|
||||
atk_count:number = 0;
|
||||
is_crit:boolean = false;
|
||||
crit_add: number = 0;//暴击伤害加成
|
||||
@@ -54,9 +59,9 @@ export class SkillCom extends CCComp {
|
||||
// }
|
||||
|
||||
|
||||
// if(this.type==1 ){
|
||||
// this.is_destroy=true
|
||||
// }
|
||||
if(this.type==1 ){
|
||||
this.is_destroy=true
|
||||
}
|
||||
// console.log("skill onBeginContact",selfCollider.group,otherCollider.group)
|
||||
// if(this.type==1 ){
|
||||
// this.is_destroy=true
|
||||
|
||||
30
assets/script/game/skills/TgCom.ts
Normal file
30
assets/script/game/skills/TgCom.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { _decorator, Component, Node, v3 } from 'cc';
|
||||
import { SkillCom } from './SkillCom';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('TgCom')
|
||||
export class TgCom extends Component {
|
||||
time:number = 0
|
||||
cd:number = 0
|
||||
base:SkillCom = null
|
||||
start() {
|
||||
this.base =this.node.getComponent(SkillCom)
|
||||
this.node.setPosition(this.base.t_pos)
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
this.cd+=deltaTime
|
||||
if(this.cd>=this.base.cd){
|
||||
// this.node.setPosition(v3(-1000,0,0))
|
||||
this.node.active = false
|
||||
this.node.active = true
|
||||
this.cd=0
|
||||
}
|
||||
this.time+=deltaTime
|
||||
if(this.time>=this.base.in_time){
|
||||
this.base.is_destroy = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
9
assets/script/game/skills/TgCom.ts.meta
Normal file
9
assets/script/game/skills/TgCom.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "2e2390b0-a0cd-459a-847c-409e5e3ad3f3",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
20
assets/script/game/skills/timedCom.ts
Normal file
20
assets/script/game/skills/timedCom.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('timedCom')
|
||||
export class timedCom extends Component {
|
||||
time = 0.3;
|
||||
start() {
|
||||
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
this.time = this.time - deltaTime;
|
||||
if(this.time <= 0)
|
||||
{
|
||||
this.node.destroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1
assets/script/game/skills/timedCom.ts.meta
Normal file
1
assets/script/game/skills/timedCom.ts.meta
Normal file
@@ -0,0 +1 @@
|
||||
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"f140b15c-7345-4364-818e-787001fb1c19","files":[],"subMetas":{},"userData":{}}
|
||||
Reference in New Issue
Block a user