This commit is contained in:
2024-09-12 13:46:42 +08:00
parent 1c9aa38385
commit 5f1b081374
16 changed files with 186 additions and 215 deletions

View File

@@ -172,7 +172,7 @@ export class MonViewComp extends CCComp {
this.in_destroy();
this.in_shield();
this.in_stop(dt);
this.in_act(dt);
this.in_atk(dt);
this.move(dt);
// if(this.m_timer.update(dt)){
// this.move_to()
@@ -234,7 +234,7 @@ export class MonViewComp extends CCComp {
}
power_change(power: number){
this.power += power;
if(this.power >= this.power_max){
if(this.power >= this.power_max&&this.check_enemy_alive()){
this.as.atk()
this.scheduleOnce(()=>{
this.do_max_skill();
@@ -247,12 +247,27 @@ export class MonViewComp extends CCComp {
shoot(skill_uuid:number){
// console.log("mon shoot");
let skill = ecs.getEntity<Skill>(Skill);
let x=32
let pos = v3(35*this.scale,50)
let scale = this.scale
let speed =smc.skills[skill_uuid].speed;
let dis = smc.skills[skill_uuid].dis;
let atk = smc.skills[skill_uuid].atk+this.atk;
let {pos,angle,t_pos}=this.get_enemy_pos()
skill.load(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
do_max_skill(){
let skill = ecs.getEntity<Skill>(Skill);
let scale = this.scale
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;
let {pos,angle,t_pos}=this.get_enemy_pos()
skill.load(pos,speed,dis,scale,this.node,this.max_skill_uuid,atk,angle,t_pos);
this.tooltip(3,smc.skills[this.max_skill_uuid].name,this.max_skill_uuid);
}
get_enemy_pos(){
let pos = v3(35*this.scale,50)
let angle=0
let t_pos:Vec3 = v3(0,0)
if(this.enemy){
@@ -260,7 +275,7 @@ export class MonViewComp extends CCComp {
console.log("move_to",this.enemy.isValid);
return
}
t_pos = v3(this.enemy.position.x-this.node.position.x,this.enemy.position.y-this.node.position.y)
t_pos = v3(this.enemy.position.x-(this.node.position.x+pos.x),this.enemy.position.y-(this.node.position.y+pos.y)+BoxSet.ATK_Y)
angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
if(this.scale == -1){
angle = angle +180
@@ -268,25 +283,21 @@ export class MonViewComp extends CCComp {
}else{
t_pos=null
}
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);
return {pos,t_pos,angle}
}
//使用max_skill
do_max_skill(){
let skill = ecs.getEntity<Skill>(Skill);
let x=32
let pos = v3(-40*this.scale,BoxSet.MAX_SKILL_SY)
let scale = this.scale
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(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);
check_enemy_alive(){
if(this.enemy){
if(!this.enemy.isValid){
return false
}
return true
}else{
return false
}
}
in_act(dt: number) {
in_atk(dt: number) {
if(this.atk_time >= this.atk_cd){
if(this.is_atking){
if(this.is_atking&&this.check_enemy_alive()){
this.atk_time = 0;
// console.log("atk_cd:"+this.atk_cd);
this.as.atk();