dd
This commit is contained in:
@@ -9,7 +9,7 @@ import { Vec3, v3,_decorator ,Collider2D,Contact2DType,Label,Node,Prefab,instant
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { RoleSpine } from "./RoleSpine";
|
||||
import {BoxSet} from "../common/config/BoxSet"
|
||||
import {BoxSet, GameSet} from "../common/config/BoxSet"
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { SkillCom } from "../skills/SkillCom";
|
||||
import { Skill } from "../skills/Skill";
|
||||
@@ -185,7 +185,7 @@ export class RoleViewComp extends CCComp {
|
||||
this.in_atk();
|
||||
this.skill_cds(dt);
|
||||
this.move(dt);
|
||||
this.check_enemys()
|
||||
this.check_enemy_alive()
|
||||
}
|
||||
skill_cds(dt:number){
|
||||
if(this.skill1.alive) this.skill1.cd -= dt;
|
||||
@@ -195,27 +195,27 @@ export class RoleViewComp extends CCComp {
|
||||
if(this.skill5.alive) this.skill5.cd -= dt;
|
||||
|
||||
if(this.skill1.cd <= 0){
|
||||
this.shoot(this.skill1.uuid);
|
||||
this.handle_skill(this.skill1.uuid);
|
||||
this.skill1.cd=this.skill1.cd_max
|
||||
console.log("shoot uuid :"+this.skill1.uuid);
|
||||
}
|
||||
if(this.skill2.cd <= 0){
|
||||
this.shoot(this.skill2.uuid);
|
||||
this.handle_skill(this.skill2.uuid);
|
||||
this.skill2.cd=this.skill2.cd_max
|
||||
console.log("shoot uuid :"+this.skill2.uuid);
|
||||
}
|
||||
if(this.skill3.cd <= 0){
|
||||
this.shoot(this.skill3.uuid);
|
||||
this.handle_skill(this.skill3.uuid);
|
||||
this.skill3.cd=this.skill3.cd_max
|
||||
console.log("shoot uuid :"+this.skill3.uuid);
|
||||
}
|
||||
if(this.skill4.cd <= 0){
|
||||
this.shoot(this.skill4.uuid);
|
||||
this.handle_skill(this.skill4.uuid);
|
||||
this.skill4.cd=this.skill4.cd_max
|
||||
console.log("shoot uuid :"+this.skill4.uuid);
|
||||
}
|
||||
if(this.skill5.cd <= 0){
|
||||
this.shoot(this.skill5.uuid);
|
||||
this.handle_skill(this.skill5.uuid);
|
||||
this.skill5.cd=this.skill5.cd_max
|
||||
console.log("shoot uuid :"+this.skill5.uuid);
|
||||
}
|
||||
@@ -231,25 +231,32 @@ export class RoleViewComp extends CCComp {
|
||||
// });
|
||||
// console.log(this.skills);
|
||||
}
|
||||
check_enemys(){
|
||||
let enemys=ecs.query(ecs.allOf(MonViewComp));
|
||||
if(enemys.length > 0){
|
||||
let x= 720
|
||||
for (let i = 0; i < enemys.length; i++) {
|
||||
let enemy:any = enemys[i];
|
||||
if(!enemy.MonView) continue
|
||||
let node=enemy.MonView.node
|
||||
if(node.isValid){
|
||||
if(node.position.x < x){
|
||||
x=node.position.x
|
||||
this.enemy = node.position;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
this.enemy = v3(720,this.node.position.y);
|
||||
}
|
||||
handle_skill(uuid:number){
|
||||
// console.log("handle_skill uuid:"+uuid);
|
||||
this.as.max();
|
||||
this.scheduleOnce(()=>{
|
||||
this.shoot(this.skill);
|
||||
},0.3)
|
||||
}
|
||||
// check_enemys(){
|
||||
// let enemys=ecs.query(ecs.allOf(MonViewComp));
|
||||
// if(enemys.length > 0){
|
||||
// let x= 720
|
||||
// for (let i = 0; i < enemys.length; i++) {
|
||||
// let enemy:any = enemys[i];
|
||||
// if(!enemy.MonView) continue
|
||||
// let node=enemy.MonView.node
|
||||
// if(node.isValid){
|
||||
// if(node.position.x < x){
|
||||
// x=node.position.x
|
||||
// this.enemy = node.position;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// this.enemy = v3(720,this.node.position.y);
|
||||
// }
|
||||
// }
|
||||
move(dt:number){
|
||||
if(this.stop_cd > 0){
|
||||
this.as.idle()
|
||||
@@ -287,30 +294,40 @@ export class RoleViewComp extends CCComp {
|
||||
return {pos,t_pos}
|
||||
}
|
||||
check_enemy_alive(){
|
||||
if(this.enemy){
|
||||
if(!this.enemy.isValid){
|
||||
return false
|
||||
let dir = 320
|
||||
this.enemy = v3(720,this.node.position.y)
|
||||
for (let i = 0; i < GameSet.ATK_LINES; i++) {
|
||||
let mon:any = smc.enemy_pos[i];
|
||||
let x=Math.abs(mon.x-this.node.position.x)
|
||||
let y = Math.abs(mon.y-this.node.position.y)
|
||||
let squaredDistance =x*x+y*y
|
||||
let distance = Math.sqrt(squaredDistance);
|
||||
if(distance < dir){
|
||||
dir = distance
|
||||
this.enemy = mon
|
||||
}
|
||||
return true
|
||||
}
|
||||
if(dir < this.atk_dis){
|
||||
this.is_atking=true
|
||||
}else{
|
||||
return false
|
||||
this.is_atking=false
|
||||
}
|
||||
}
|
||||
in_atk() {
|
||||
if(this.atk_time >= this.atk_cd){
|
||||
// if(this.is_atking&&this.check_enemy_alive()){
|
||||
// this.atk_time = 0;
|
||||
// // console.log("atk_cd:"+this.atk_cd);
|
||||
// this.as.atk();
|
||||
// this.scheduleOnce(()=>{
|
||||
// this.shoot(this.skill,-30);
|
||||
// },0.4)
|
||||
// }
|
||||
this.atk_time = 0;
|
||||
this.as.atk();
|
||||
this.scheduleOnce(()=>{
|
||||
this.shoot(this.skill,-30,45);
|
||||
},0.3)
|
||||
if(this.is_atking){
|
||||
this.atk_time = 0;
|
||||
// console.log("atk_cd:"+this.atk_cd);
|
||||
this.as.atk();
|
||||
this.scheduleOnce(()=>{
|
||||
this.shoot(this.skill,-30);
|
||||
},0.4)
|
||||
}
|
||||
// this.atk_time = 0;
|
||||
// this.as.atk();
|
||||
// this.scheduleOnce(()=>{
|
||||
// this.shoot(this.skill,-30,45);
|
||||
// },0.3)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,7 +354,7 @@ export class RoleViewComp extends CCComp {
|
||||
return;
|
||||
}
|
||||
this.hp += lhp;
|
||||
this.tooltip(1,hp.toString());
|
||||
// this.tooltip(1,hp.toString());
|
||||
if(this.hp > this.hp_max){
|
||||
this.hp = this.hp_max;
|
||||
}
|
||||
@@ -485,12 +502,12 @@ export class RoleViewComp extends CCComp {
|
||||
|
||||
in_atked() {
|
||||
|
||||
var path = "game/skills/atked";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
let pos = v3(0,60)
|
||||
node.setPosition(pos)
|
||||
node.parent = this.node;
|
||||
// var path = "game/skills/atked";
|
||||
// var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
// var node = instantiate(prefab);
|
||||
// let pos = v3(0,30)
|
||||
// node.setPosition(pos)
|
||||
// node.parent = this.node;
|
||||
|
||||
|
||||
// this.sprite.setSharedMaterial(this.hitFlashMaterial, 0);
|
||||
|
||||
Reference in New Issue
Block a user