This commit is contained in:
2025-01-08 23:59:41 +08:00
parent aa2d915bb3
commit 52cc268368
9 changed files with 213 additions and 142 deletions

View File

@@ -17,13 +17,15 @@ import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/O
import { Skill } from "../skills/Skill";
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
import { SkillCom } from "../skills/SkillCom";
import { SkillSet } from "../common/config/SkillSet";
import { SkillSet, SkTG, SkType } from "../common/config/SkillSet";
import { Tooltip } from "../skills/Tooltip";
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
import { TimerManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/TimerManager";
import { HeroSet } from "../common/config/heroSet";
import { BuffComp } from "./BuffComp";
import { BossList } from "../common/config/MissionSet";
import { Monster } from "./Mon";
import { MonModelComp } from "./MonModelComp";
const { ccclass, property } = _decorator;
/** 角色显示组件 */
@@ -272,28 +274,30 @@ export class HeroViewComp extends CCComp {
}
}
check_enemy_alive(){
let dir = 720
let enemys=smc.enemy_pos
this.enemy = v3(720,this.node.position.y)
// let dir = 720
// let enemys=smc.enemy_pos
// this.enemy = v3(720,this.node.position.y)
// if(this.box_group == BoxSet.MONSTER){
// enemys=smc.hero_pos
// // console.log("MONSTER enemys",enemys);
// this.enemy=v3(-720,this.node.position.y)
// }
// for (let i = 0; i < enemys.length; i++) {
// let ho:any = enemys[i];
// let x=Math.abs(ho.x-this.node.position.x)
// if(x < dir){
// dir = x
// this.enemy = ho
// }
// }
let dir = Math.abs(smc.mon_front_x-this.node.position.x)
if(this.box_group == BoxSet.MONSTER){
enemys=smc.hero_pos
// console.log("MONSTER enemys",enemys);
this.enemy=v3(-720,this.node.position.y)
dir = Math.abs(smc.hero_front_x-this.node.position.x)
}
for (let i = 0; i < enemys.length; i++) {
let ho:any = enemys[i];
let x=Math.abs(ho.x-this.node.position.x)
if(x < dir){
dir = x
this.enemy = ho
}
}
if(dir < this.dis){
this.is_atking=true
if(this.dis-dir > 80 &&this.type > 0 ) this.stop_cd = 0.1
if(dir < 65 &&this.type == 0 ) this.stop_cd = 0.1
}else{
this.is_atking=false
}
@@ -322,6 +326,14 @@ export class HeroViewComp extends CCComp {
console.log(this.hero_name+":"+this.uuid+"enemy ="+this.enemy.x+" x"+this.node.position.x+" t_pos"+t_pos);
return t_pos
}
get_back_enemy_pos(hero:any){
let t_pos:Vec3 = v3(720,0)
if(this.enemy){
t_pos = v3(this.enemy.x,this.enemy.y)
}
console.log(this.hero_name+":"+this.uuid+"enemy ="+this.enemy.x+" x"+this.node.position.x+" t_pos"+t_pos);
return {t_pos}
}
get_hero_pos(hero:any){
let t_pos:Vec3 = v3(-720,0)
if(!hero.node.isValid){
@@ -530,21 +542,20 @@ export class HeroViewComp extends CCComp {
this.as.max()
this.at = 0;
this.BUFFCOMP.tooltip(3,SkillSet[skill].name,skill);
switch (SkillSet[skill].tg) {
case 0: //自己
case SkTG.self: //自己
this.do_add_buff(this.node.getComponent(HeroViewComp),skill)
break;
case 1: //伙伴
case SkTG.friend: //伙伴
this.check_other_buff(skill)
break;
case 2: //自己和伙伴
case SkTG.team: //自己和伙伴
this.do_all_buff(skill)
break;
case 3: //敌人
case SkTG.enemy: //敌人
this.shoot_enemy(skill)
break;
case 4: //敌人和自己
case SkTG.all: //敌人和自己
this.do_add_buff(this.node.getComponent(HeroViewComp),skill)
this.shoot_enemy(skill)
break;
@@ -555,9 +566,15 @@ export class HeroViewComp extends CCComp {
check_other_buff(skill:number){
let heros:any = ecs.query(ecs.allOf(HeroModelComp));
let least_hp:number=0
let hight_hp:number=9999999999
let right_x:number=360
let left_x:number=-360
if(this.box_group==BoxSet.MONSTER){
heros=ecs.query(ecs.allOf(MonModelComp))
}
let t_hero:any= null
if (heros.length > 0) {
if(SkillSet[skill].type==92){ //随机添加buff
if(SkillSet[skill].type==SkType.random){ //随机添加buff
let i = RandomManager.instance.getRandomInt(0,heros.length-1,3)
while(!heros[i].HeroView){
i = RandomManager.instance.getRandomInt(0,heros.length-1,3)
@@ -570,12 +587,68 @@ export class HeroViewComp extends CCComp {
for (let i = 0; i < heros.length; i++) {
if(!heros[i].HeroView) continue
let hero = heros[i].HeroView;
if(SkillSet[skill].type==91){ //血量最少单体
if((hero.rhp_max-hero.hp) > least_hp){
least_hp = (hero.rhp_max-hero.hp)
t_hero = hero
}
}
switch(SkillSet[skill].type){
case SkType.leastHealth: //血量最少单体
if((hero.rhp_max-hero.hp) > least_hp){
least_hp = (hero.rhp_max-hero.hp)
t_hero = hero
}
break;
case SkType.highestHealth: //血量最多单体
if((hero.rhp_max-hero.hp) < hight_hp){
hight_hp = (hero.rhp_max-hero.hp)
t_hero = hero
}
break;
case SkType.frontRow: //最前排
if(hero.node.position.x > left_x){
left_x = hero.node.position.x
t_hero = hero
}
if(this.box_group==BoxSet.MONSTER){
if(hero.node.position.x < right_x){
right_x = hero.node.position.x
t_hero = hero
}
}
break;
case SkType.backRow: //最后排
if(hero.node.position.x < right_x){
right_x = hero.node.position.x
t_hero = hero
}
if(this.box_group==BoxSet.MONSTER){
if(hero.node.position.x > left_x){
left_x = hero.node.position.x
t_hero = hero
}
}
break;
}
// if(SkillSet[skill].type==SkType.leastHealth){ //血量最少单体
// if((hero.rhp_max-hero.hp) > least_hp){
// least_hp = (hero.rhp_max-hero.hp)
// t_hero = hero
// }
// }
// if(SkillSet[skill].type==SkType.highestHealth){ //血量最多单体
// if((hero.rhp_max-hero.hp) < hight_hp){
// hight_hp = (hero.rhp_max-hero.hp)
// t_hero = hero
// }
// }
// if(SkillSet[skill].type==SkType.frontRow){ //最前排
// if(hero.node.position.x > left_x){
// left_x = hero.node.position.x
// t_hero = hero
// }
// }
// if(SkillSet[skill].type==SkType.backRow){ //最后排
// if(hero.node.position.x < right_x){
// right_x = hero.node.position.x
// t_hero = hero
// }
// }
//todo 最前排 最后排 远程 近战 辅助
}
if(t_hero){ //存在目标
@@ -585,7 +658,6 @@ export class HeroViewComp extends CCComp {
}
}
}
do_all_buff(sk:number){
let skill = ecs.getEntity<Skill>(Skill);
@@ -602,16 +674,30 @@ export class HeroViewComp extends CCComp {
shoot_enemy(sk:number,y:number=0,x:number=0){
// console.log("mon shoot_enemy");
let skill = ecs.getEntity<Skill>(Skill);
let t_pos=this.get_enemy_pos()
if(SkillSet[sk].type==81){
//获取最远敌军位置
let t_pos=v3(smc.mon_front_x,BoxSet.GAME_LINE)
if(this.box_group==BoxSet.MONSTER){
t_pos=v3(smc.hero_front_x,BoxSet.GAME_LINE)
}
switch(SkillSet[sk].type){
case SkType.leastHealth: //血量最少单体
break;
case SkType.highestHealth: //血量最多单体
break;
case SkType.backRow: //最后排
t_pos=v3(smc.mon_back_x,BoxSet.GAME_LINE)
if(this.box_group==BoxSet.MONSTER){
t_pos=v3(smc.hero_back_x,BoxSet.GAME_LINE)
}
break;
}
let pos =this.skill_pos()
pos.y=this.node.position.y + y
pos.x=this.node.position.x + x
let is_crit=this.check_crit()
skill.load(pos,this.box_group,this.node,sk,this.ap_max,t_pos,is_crit,this.crit_add);
this.to_console(this.scale+this.hero_name+"使用技能:"+sk+" t_pos:"+t_pos+" box:"+this.box_group,);
this.to_console(this.scale+this.hero_name+"使用技能:"+sk+SkillSet[sk].name+" t_pos:"+t_pos+" box:"+this.box_group,);
}
do_add_buff(hero:any,sk:number){
let skill = ecs.getEntity<Skill>(Skill);
@@ -620,7 +706,7 @@ export class HeroViewComp extends CCComp {
this.to_console("do_add_buff:"+hero.hero_name+" "+sk);
let is_crit=this.check_crit()
skill.load(pos,this.box_group,this.node,sk,this.ap_max,t_pos,is_crit,this.crit_add);
this.to_console(this.scale+this.hero_name+"使用buff:"+sk+" t_pos:"+t_pos+" box:"+this.box_group,);
this.to_console(this.scale+this.hero_name+"使用buff:"+sk+SkillSet[sk].name+" t_pos:"+t_pos+" box:"+this.box_group,);
}
exp_add(exp:number=0){
@@ -720,8 +806,8 @@ export class HeroViewComp extends CCComp {
this.node.setPosition(pos)
}
to_console(value:any){
console.log("["+this.scale+this.hero_name+']'+value)
to_console(value:any,value2:any=null,value3:any=null){
console.log("["+this.scale+this.hero_name+']'+value,value2,value3)
}
reset() {
this.is_dead = false;