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

@@ -152,7 +152,7 @@ export class HeroViewComp extends CCComp {
this.in_destroy();
this.in_shield(dt);
this.in_stop(dt);
this.in_act(dt);
this.in_atk(dt);
this.move(dt);
// if(this.m_timer.update(dt)){
// this.move_to()
@@ -214,7 +214,7 @@ export class HeroViewComp 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();
@@ -225,26 +225,37 @@ export class HeroViewComp extends CCComp {
this.node.getChildByName("top").getChildByName("power").getComponent(ProgressBar)!.progress = power_progress;
}
shoot(skill_uuid:number){
console.log("hero shoot");
console.log(this.enemy)
console.log("hero box",this.enemy.getComponent(MonViewComp))
// 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)
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)
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
@@ -252,31 +263,21 @@ export class HeroViewComp extends CCComp {
}else{
t_pos=null
}
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);
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;
let eid = 0
check_enemy_alive(){
if(this.enemy){
if(this.enemy.isValid){
eid = this.enemy.getComponent(MonViewComp).ent.eid
if(!this.enemy.isValid){
return false
}
return true
}else{
return false
}
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) {
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();