技能运动需要完善

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

@@ -210,7 +210,7 @@ export class RoleViewComp extends CCComp {
}else{
t_pos=null
}
skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk,angle,t_pos);
skill.load(this.enemy,pos,speed,dis,scale,this.node,skill_uuid,atk,angle,t_pos);
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
}
//使用max_skill
@@ -222,7 +222,7 @@ export class RoleViewComp extends CCComp {
let speed =smc.skills[this.max_skill_uuid].speed;
let dis = smc.skills[this.max_skill_uuid].dis;
let atk = smc.skills[this.max_skill_uuid].atk+this.atk;
skill.load(pos,speed,dis,scale,this.node,this.max_skill_uuid,atk);
skill.load(this.enemy,pos,speed,dis,scale,this.node,this.max_skill_uuid,atk);
this.tooltip(3,smc.skills[this.max_skill_uuid].name,this.max_skill_uuid);
}
in_atk(dt: number) {

View File

@@ -21,6 +21,9 @@ export class SingletonModuleComp extends ecs.Comp {
initialize: Initialize = null!;
/** 游戏地图 */
map: GameMap = null!;
cards: any = [
{uuid:9001,type:1},{uuid:9011,type:1},{uuid:9021,type:1},{uuid:9031,type:1},{uuid:9041,type:1}
];
player_skills: any = [
];
player_buffs: any = [

View File

@@ -4,21 +4,17 @@
export const CardList={
1:[
{uuid:9001,type:1},{uuid:9002,type:1},{uuid:9003,type:1},{uuid:9004,type:1},{uuid:9005,type:1},{uuid:9006,type:1},{uuid:9007,type:1},{uuid:9008,type:1},{uuid:9009,type:1},
{uuid:9010,type:1},
{uuid:9001,type:1},{uuid:9011,type:1},{uuid:9021,type:1},{uuid:9031,type:1},{uuid:9041,type:1}
// {uuid:9007,type:1},{uuid:9008,type:1},{uuid:9009,type:1},{uuid:9010,type:1},{uuid:9011,type:1},{uuid:9012,type:1},
],
2:[
{uuid:9001,type:1},{uuid:9002,type:1},{uuid:9003,type:1},{uuid:9004,type:1},{uuid:9005,type:1},{uuid:9006,type:1},{uuid:9007,type:1},{uuid:9008,type:1},{uuid:9009,type:1},
{uuid:9010,type:1},// {uuid:9007,type:1},{uuid:9008,type:1},{uuid:9009,type:1},{uuid:9010,type:1},{uuid:9011,type:1},{uuid:9012,type:1},
{uuid:9001,type:1},{uuid:9011,type:1},{uuid:9021,type:1},{uuid:9031,type:1},{uuid:9041,type:1}
],
3:[
{uuid:9001,type:1},{uuid:9002,type:1},{uuid:9003,type:1},{uuid:9004,type:1},{uuid:9005,type:1},{uuid:9006,type:1},{uuid:9007,type:1},{uuid:9008,type:1},{uuid:9009,type:1},
{uuid:9010,type:1},// {uuid:9007,type:1},{uuid:9008,type:1},{uuid:9009,type:1},{uuid:9010,type:1},{uuid:9011,type:1},{uuid:9012,type:1},
{uuid:9001,type:1},{uuid:9011,type:1},{uuid:9021,type:1},{uuid:9031,type:1},{uuid:9041,type:1}
],
4:[
{uuid:9010,type:1},{uuid:9001,type:1},{uuid:9002,type:1},{uuid:9003,type:1},{uuid:9004,type:1},{uuid:9005,type:1},{uuid:9006,type:1},{uuid:9007,type:1},{uuid:9008,type:1},{uuid:9009,type:1},
{uuid:9001,type:1},{uuid:9011,type:1},{uuid:9021,type:1},{uuid:9031,type:1},{uuid:9041,type:1}
],
5:[
{uuid:1001,type:2},{uuid:1002,type:2},{uuid:4011,type:2},{uuid:4012,type:2},
@@ -33,8 +29,4 @@ export const CardList={
{uuid:6102,type:3},{uuid:6103,type:3}, {uuid:6210,type:3},{uuid:6213,type:3},{uuid:6216,type:3},{uuid:6211,type:3},{uuid:6212,type:3},
{uuid:6214,type:3},{uuid:6215,type:3},{uuid:6217,type:3},{uuid:6218,type:3},
],
7:[
],
}

View File

@@ -1,24 +1,21 @@
export const HeroSet={
9001:{uuid: 9001,path: "k1",type: 1,level: 1,name: "战士1",atk: 4,hp: 24,atk_dis:40,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "狗"},
9002:{uuid: 9002,path: "k2",type: 2,level: 1,name: "战士2",atk: 2,hp: 48,atk_dis:40,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "血量型",mon: "绵羊"},
9003:{uuid: 9003,path: "k3",type: 1,level: 1,name: "战士3",atk: 4,hp: 24,atk_dis:40,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻击型",mon: "蚂蚁"},
9004:{uuid: 9004,path: "m1",type: 1,level: 1,name: "魔法师1",atk: 4,hp: 24,atk_dis:400,atk_cd: 2,power: 50,speed: 30,
skill: "base2",max_skill: "base2",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻击型",mon: "蚂蚁"},
9005:{uuid: 9005,path: "m2",type: 3,level: 1,name: "魔法师2",atk: 3,hp: 18,atk_dis:400,atk_cd: 1,power: 50,speed: 30,
skill: "base2",max_skill: "base2",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻速型",mon: "鼠"},
9006:{uuid: 9006,path: "m3",type: 3,level: 1,name: "魔法师3",atk: 3,hp: 18,atk_dis:400,atk_cd: 2,power: 50,speed: 30,
skill: "base2",max_skill: "base2",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻速型",mon: "猫"},
9007:{uuid: 9007,path: "arc1",type: 3,level: 1,name: "弓箭手1",atk: 3,hp: 18,atk_dis:500,atk_cd: 1,power: 50,speed: 30,
skill: "base3",max_skill: "base3",skill_uuid: 9001,max_skill_uuid: 1001,word: "狂暴",info: "全体攻击", atktype: "攻速型",mon: "松鼠"},
9008:{uuid: 9008,path: "arc2",type: 3,level: 2,name: "弓箭手2",atk: 4,hp: 27,atk_dis:500,atk_cd: 1,power: 50,speed: 30,
skill: "base3",max_skill: "base3",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻速型",mon: "机械蜜蜂"},
9009:{uuid: 9009,path: "arc3",type: 1,level: 2,name: "弓箭手3",atk: 6,hp: 36,atk_dis:500,atk_cd: 2,power: 50,speed: 30,
skill: "base3",max_skill: "base3",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻击型",mon: "鹰"},
9010:{uuid: 9009,path: "m4",type: 1,level: 2,name: "大火法",atk: 6,hp: 36,atk_dis:500,atk_cd: 2,power: 50,speed: 30,
skill: "fire",max_skill: "base3",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻击型",mon: "鹰"},
9001:{uuid: 9001,path: "k3",type: 1,level: 1,name: "战士",atk: 4,hp: 350,atk_dis:40,atk_cd: 2,power:0,power_max: 10,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: 1,},
9011:{uuid: 9004,path: "m1",type: 1,level: 1,name: "冰法",atk: 4,hp: 15,atk_dis:400,atk_cd: 2,power:0,power_max: 10,speed: 30,
skill: "base2",max_skill: "ice",skill_uuid: 9001,max_skill_uuid: 1002, atktype: 1,},
9021:{uuid: 9005,path: "m2",type: 3,level: 1,name: "火法",atk: 6,hp: 15,atk_dis:400,atk_cd: 2,power:0,power_max: 10,speed: 30,
skill: "base2",max_skill: "fire",skill_uuid: 9001,max_skill_uuid: 1001, atktype: 2},
9031:{uuid: 9006,path: "m3",type: 3,level: 1,name: "牧师",atk: 3,hp: 20,atk_dis:400,atk_cd: 2,power:0,power_max: 10,speed: 30,
skill: "base2",max_skill: "base2",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: 2},
9041:{uuid: 9009,path: "arc1",type: 3,level: 1,name: "弓箭手",atk: 3,hp: 15,atk_dis:400,atk_cd: 1,power:0,power_max: 10,speed: 30,
skill: "base3",max_skill: "base3",skill_uuid: 9001,max_skill_uuid: 1001,word: "狂暴",info: "全体攻击", atktype: 2},
}

View File

@@ -65,6 +65,7 @@ export class BoxRangComp extends CCComp {
}else{
if(this.HeroViewComp.enemy.isValid==false){
this.HeroViewComp.enemy = otherCollider.node;
}
}
this.HeroViewComp.is_atking = true;

View File

@@ -81,6 +81,7 @@ export class Hero extends ecs.Entity {
mv.atk_cd = smc.heros[uuid].atk_cd;
mv.atk_dis = smc.heros[uuid].atk_dis;
mv.power = smc.heros[uuid].power;
mv.power_max= smc.heros[uuid].power_max;
mv.type = smc.heros[uuid].type;
mv.skill_uuid = 9001;
mv.max_skill_uuid = smc.heros[uuid].max_skill_uuid;

View File

@@ -21,6 +21,7 @@ import { SkillSet } from "../common/config/SkillSet";
import { Tooltip } from "../skills/Tooltip";
import { MoveToComp } from "../common/ecs/position/MoveTo";
import { BoxRangComp } from "./BoxRangComp";
import { MonViewComp } from "../mon/MonViewComp";
const { ccclass, property } = _decorator;
/** 角色显示组件 */
@@ -224,7 +225,9 @@ export class HeroViewComp extends CCComp {
this.node.getChildByName("top").getChildByName("power").getComponent(ProgressBar)!.progress = power_progress;
}
shoot(skill_uuid:number){
// console.log("mon shoot");
console.log("hero shoot");
console.log(this.enemy)
console.log("hero box",this.enemy.getComponent(MonViewComp))
let skill = ecs.getEntity<Skill>(Skill);
let x=32
let pos = v3(35*this.scale,50)
@@ -234,11 +237,13 @@ export class HeroViewComp extends CCComp {
let atk = smc.skills[skill_uuid].atk+this.atk;
let angle=0
let t_pos:Vec3 = v3(0,0)
let eid = 0
if(this.enemy){
if(!this.enemy.isValid){
console.log("move_to",this.enemy.isValid);
return
}
eid = this.enemy.getComponent(MonViewComp).ent.eid
t_pos = v3(this.enemy.position.x-this.node.position.x,this.enemy.position.y-this.node.position.y)
angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
if(this.scale == -1){
@@ -247,7 +252,8 @@ export class HeroViewComp extends CCComp {
}else{
t_pos=null
}
skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk,angle,t_pos);
skill.load(eid,this.enemy,pos,speed,dis,scale,this.node,skill_uuid,atk,angle,t_pos);
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
}
//使用max_skill
@@ -259,8 +265,14 @@ export class HeroViewComp extends CCComp {
let speed =smc.skills[this.max_skill_uuid].speed;
let dis = smc.skills[this.max_skill_uuid].dis;
let atk = smc.skills[this.max_skill_uuid].atk+this.atk;
skill.load(pos,speed,dis,scale,this.node,this.max_skill_uuid,atk);
this.tooltip(3,smc.skills[this.max_skill_uuid].name,this.max_skill_uuid);
let eid = 0
if(this.enemy){
if(this.enemy.isValid){
eid = this.enemy.getComponent(MonViewComp).ent.eid
}
}
skill.load(eid,this.enemy,pos,speed,dis,scale,this.node,this.max_skill_uuid,atk);
this.tooltip(3,smc.skills[this.max_skill_uuid].name,this.max_skill_uuid,100);
}
in_act(dt: number) {
if(this.atk_time >= this.atk_cd){
@@ -372,12 +384,12 @@ export class HeroViewComp extends CCComp {
this.node.getChildByName("top").getChildByName("shield").active=true
}
}
tooltip(type:number=1,value:string="",s_uuid:number=1001){
tooltip(type:number=1,value:string="",s_uuid:number=1001,y:number=60){
// console.log("tooltip",type);
let tip =ecs.getEntity<Tooltip>(Tooltip);
let pos = this.node.getPosition();
let node =this.node.parent
pos.y=pos.y+60;
pos.y=pos.y+y;
tip.load(pos,type,value,s_uuid,node);
}

View File

@@ -236,8 +236,8 @@ export class CardControllerComp extends CCComp {
load_cards() {
this.in_load = true
let card:any=null
for (let index = 1; index <= 6; index++) {
card=RandomManager.instance.getRandomByObjectList(CardList[index], 1);
for (let index = 1; index <= 4; index++) {
card=RandomManager.instance.getRandomByObjectList(smc.cards, 1);
this.cards[index].uuid=card[0].uuid
this.cards[index].type=card[0].type
@@ -246,20 +246,31 @@ export class CardControllerComp extends CCComp {
let name: string = "";
let level: number = 0;
let { uuid, type } = card[0];
switch (type) {
case 1:
url = "game/hero/hero_icon";
({ uuid: pathName, name, level } = smc.heros[uuid]);
break;
case 2:
url = "game/heros/skill";
({ path: pathName, name, level } = smc.skills[uuid]);
break;
case 3:
default:
url = "game/heros/skill";
({ path: pathName, name, level } = smc.skills[uuid]);
}
url = "game/hero/hero_icon";
({ uuid: pathName, name, level } = smc.heros[uuid]);
this.cards[index].lv=level
let node=this.node.getChildByName('cards').getChildByName('card'+index)
node.getChildByName('cost').getComponent(Label).string=level.toString()
node.getChildByName('name').getComponent(Label).string=name
// const sprite = node.getChildByName("item").getComponent(Sprite);
// console.log(this['card'+index],url,pathName,sprite)
resources.load(url, SpriteAtlas, (err: any, atlas) => {
const sprite = node.getChildByName("item").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(pathName);
});
this.cards[index].alive=true
}
for (let index = 5; index <= 6; index++) {
card=RandomManager.instance.getRandomByObjectList(CardList[index], 1);
this.cards[index].uuid=card[0].uuid
this.cards[index].type=card[0].type
let url: string = "";
let pathName: string = "";
let name: string = "";
let level: number = 0;
let { uuid, type } = card[0];
url = "game/heros/skill";
({ path: pathName, name, level } = smc.skills[uuid]);
this.cards[index].lv=level
let node=this.node.getChildByName('cards').getChildByName('card'+index)
node.getChildByName('cost').getComponent(Label).string=level.toString()

View File

@@ -156,8 +156,8 @@ export class MapMonsterComp extends CCComp {
let monster_layer = scene.entityLayer!.node!
let monster_layer1 = scene.entityLayer1!.node!;
let monster_layer2 = scene.entityLayer2!.node!;
this.addMonster(m[0],monster_layer,pos)
this.addMonster(m1[0],monster_layer1,pos1)
this.addMonster(m[0],monster_layer,pos2)
this.addMonster(m1[0],monster_layer1,pos2)
this.addMonster(m2[0],monster_layer2,pos2)
this.setp_num -= 1
}

View File

@@ -268,7 +268,7 @@ export class MonViewComp extends CCComp {
}else{
t_pos=null
}
skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk,angle,t_pos);
skill.load(this.enemy,pos,speed,dis,scale,this.node,skill_uuid,atk,angle,t_pos);
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
}
//使用max_skill
@@ -280,7 +280,7 @@ export class MonViewComp extends CCComp {
let speed =smc.skills[this.max_skill_uuid].speed;
let dis = smc.skills[this.max_skill_uuid].dis;
let atk = smc.skills[this.max_skill_uuid].atk+this.atk;
skill.load(pos,speed,dis,scale,this.node,this.max_skill_uuid,atk);
skill.load(this.enemy,pos,speed,dis,scale,this.node,this.max_skill_uuid,atk);
this.tooltip(3,smc.skills[this.max_skill_uuid].name,this.max_skill_uuid);
}
in_act(dt: number) {

View File

@@ -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 远距离攻击,碰撞后 结束

View File

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

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

View File

@@ -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)!;

View File

@@ -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;
// }
// }
}