This commit is contained in:
2024-09-20 00:15:58 +08:00
parent efaf6ac27c
commit cb286ab554
10 changed files with 1016 additions and 178 deletions

View File

@@ -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 { BossSpine } from "./BossSpine";
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";
@@ -19,7 +19,8 @@ import { RandomManager } from "../../../../extensions/oops-plugin-framework/asse
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { MoveToComp } from "../common/ecs/position/MoveTo";
import { Tooltip } from "../skills/Tooltip";
import { MonViewComp } from "../mon/MonViewComp";
import { HeroViewComp } from "../hero/HeroViewComp";
const { ccclass, property } = _decorator;
/** 角色显示组件 */
@@ -82,7 +83,7 @@ export class BossViewComp extends CCComp {
shield_max:number = 200;
shield_time:number = 0; //护盾持续时间
box_group:number = BoxSet.HERO;
box_group:number = BoxSet.MONSTER;
atk_range:number = 150;
private timer:Timer = new Timer(0.1); //计时器
is_dead:boolean = false; //是否摧毁
@@ -92,6 +93,7 @@ export class BossViewComp extends CCComp {
onLoad() {
// this.BoxRang = this.node.getChildByName("range_box");
this.as = this.node.getComponent(BossSpine);
console.log(this.as)
}
start () {
@@ -175,37 +177,38 @@ export class BossViewComp extends CCComp {
this.in_stop(dt);
this.atk_time += dt;
this.in_atk();
// this.move();
this.check_enemys()
this.move(dt);
this.check_enemy_alive()
}
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;
}
}
check_enemy_alive(){
let dir = 320
for (let i = 0; i < GameSet.ATK_LINES; i++) {
let hero:any = smc.hero_pos[i];
let x=Math.abs(hero.x-this.node.position.x)
let y = Math.abs(hero.y-this.node.position.y)
let squaredDistance =x*x+y*y
let distance = Math.sqrt(squaredDistance);
if(distance < dir){
dir = distance
this.enemy = hero
}
}
if(dir < this.atk_dis){
this.is_atking=true
}else{
this.enemy = v3(720,this.node.position.y);
this.is_atking=false
}
}
move(){
move(dt:number){
if(this.stop_cd > 0){
return
}
if(this.enemy){
this.move_to(this.enemy.position)
}else{
this.move_to(v3(0,0));
if(this.scale===-1&&this.node.position.x <= BoxSet.HERO_START){
return;
}
// this.set_diry()
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale, this.node.position.y+dt*this.dir_y, this.node.position.z);
}
move_to(enemy:Vec3){
// console.log("move to ",enemy);
@@ -222,7 +225,7 @@ export class BossViewComp extends CCComp {
shoot(skill_uuid:number,y:number=0,x:number=0){
// console.log("mon shoot");
let skill = ecs.getEntity<Skill>(Skill);
let atk = smc.skills[skill_uuid].atk+this.atk+this.buff_atk+this.mission_atk;
let atk = smc.skills[skill_uuid].atk+this.atk+this.buff_atk;
let {pos,t_pos}=this.get_enemy_pos()
pos.y=pos.y + y
pos.x=pos.x + x
@@ -241,16 +244,7 @@ export class BossViewComp extends CCComp {
}
return {pos,t_pos}
}
check_enemy_alive(){
if(this.enemy){
if(!this.enemy.isValid){
return false
}
return true
}else{
return false
}
}
in_atk() {
if(this.atk_time >= this.atk_cd){
// if(this.is_atking&&this.check_enemy_alive()){