mon 和hero 统一

This commit is contained in:
2024-11-04 16:03:23 +08:00
parent 52ee8dd813
commit 81a8f1fb50
5 changed files with 80 additions and 28 deletions

View File

@@ -105,6 +105,7 @@ export class HeroViewComp extends CCComp {
this.as.move()
this.node.getChildByName("top").getChildByName("hp").active = false;
this.sprite = this.node.getChildByName("anm").getComponent(Sprite);
this.node.setScale(this.scale,1);
// this.node.getChildByName("top").getChildByName("shield").active = false;
// this.node.getChildByName("top").setScale(this.scale,1);
// this.node.getChildByName("atk").setScale(this.scale,1);
@@ -124,6 +125,7 @@ export class HeroViewComp extends CCComp {
// 注册单个碰撞体的回调函数
let collider = this.getComponent(Collider2D);
collider.group = this.box_group;
console.log("hero collider ",this.scale,collider);
if (collider) {
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
// collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
@@ -154,22 +156,22 @@ export class HeroViewComp extends CCComp {
}
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
if(selfCollider.group == otherCollider.group&&selfCollider.tag==otherCollider.tag){
if(otherCollider.node.name=="role") return
let self_x = selfCollider.node.position.x;
let other_x = otherCollider.node.position.x;
if(otherCollider.node.getComponent(HeroViewComp).type == this.type && self_x < other_x && Math.abs(other_x-self_x) < 15 ){
this.stop_cd = 0.1;
}
// if(selfCollider.node.position.y < otherCollider.node.position.y){
// if(selfCollider.node.getSiblingIndex() < otherCollider.node.getSiblingIndex()){
// if(selfCollider.group == otherCollider.group&&selfCollider.tag==otherCollider.tag){
// if(otherCollider.node.name=="role") return
// let self_x = selfCollider.node.position.x;
// let other_x = otherCollider.node.position.x;
// if(otherCollider.node.getComponent(HeroViewComp).type == this.type && self_x < other_x && Math.abs(other_x-self_x) < 15 ){
// this.stop_cd = 0.1;
// }
// // if(selfCollider.node.position.y < otherCollider.node.position.y){
// // if(selfCollider.node.getSiblingIndex() < otherCollider.node.getSiblingIndex()){
// selfCollider.node.setSiblingIndex(otherCollider.node.getSiblingIndex()+1)
// // console.log("onPreSolve b:"+selfCollider.node.uuid+":"+selfCollider.node.getSiblingIndex()+"/"+otherCollider.node.uuid+":"+otherCollider.node.getSiblingIndex());
// }
// // selfCollider.node.setSiblingIndex(otherCollider.node.getSiblingIndex()+1)
// // // console.log("onPreSolve b:"+selfCollider.node.uuid+":"+selfCollider.node.getSiblingIndex()+"/"+otherCollider.node.uuid+":"+otherCollider.node.getSiblingIndex());
// // }
// }
}
// // }
// }
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
this.stop_cd = 0.1;
this.is_atking=true
@@ -230,7 +232,10 @@ export class HeroViewComp extends CCComp {
if(this.stop_cd > 0){
return
}
if (this.node.position.x >= 250-this.atk_dis/2) {
if (this.node.position.x >= 360 && this.scale==1) {
return;
}
if(this.scale===-1&&this.node.position.x <= -360){
return;
}
// if(this.enemy){
@@ -301,14 +306,14 @@ export class HeroViewComp extends CCComp {
pos.y=pos.y + y
pos.x=pos.x + x
skill.load(pos,BoxSet.HERO,this.node,skill_uuid,atk,t_pos);
skill.load(pos,this.box_group,this.node,skill_uuid,atk,t_pos);
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
}
to_add_buff(hero:any,s_uuid:number){
let skill = ecs.getEntity<Skill>(Skill);
let atk = smc.skills[s_uuid].atk+this.atk;
let {pos,t_pos}=this.get_hero_pos(hero)
skill.load(pos,BoxSet.HERO,this.node,this.max_skill_uuid,atk,t_pos);
skill.load(pos,this.box_group,this.node,this.max_skill_uuid,atk,t_pos);
if(smc.skills[s_uuid].hp > 0){ //buff加血
let increase_hp=Math.floor(smc.skills[s_uuid].hp*this.atk*this.s_boncus*smc.vm_data.mission.hero.atk)
hero.add_hp(increase_hp)