role 也转为使用hero 预制体

This commit is contained in:
2024-09-02 17:15:30 +08:00
parent 83bd06334f
commit 8b9c04eae3
15 changed files with 299 additions and 223 deletions

View File

@@ -37,7 +37,9 @@ export class MonsterViewComp extends CCComp {
BoxRang:Node =null!
buff:MonsterBuffComp =null!
is_role:boolean = false;
enemy_pos:Vec3=null!;
enemy:any=null!;
/** 角色动画 */
as: MonsterSpine = null!;
hero_uuid:number = 1001;
@@ -74,7 +76,7 @@ export class MonsterViewComp extends CCComp {
shield_time:number = 0; //护盾持续时间
box_group:number = 2;
atk_range:number = 150;
private timer:Timer = new Timer(0.1); //计时器
is_dead:boolean = false; //是否摧毁
is_stop:boolean = false;
@@ -87,11 +89,16 @@ export class MonsterViewComp extends CCComp {
} /** 视图层逻辑代码分离演示 */
start () {
this.sprite = this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
this.node.getChildByName("top").setScale(this.scale,1);
this.node.getChildByName("top").setScale(this.scale,1);
this.node.getChildByName("atk").setScale(this.scale,1);
this.node.getChildByName("hp_max").setScale(this.scale,1);
this.orginalFlashMaterial = this.sprite.getRenderMaterial(0);
this.BoxRang.getComponent(BoxRangComp).box_group = this.box_group;
this.BoxRang.getComponent(BoxRangComp).offset_x = this.scale*smc.skills[this.skill_uuid].dis;
this.BoxRang.getComponent(BoxRangComp).atk_range = this.atk_range
// this.BoxRang.getComponent(BoxRangComp).offset_x = this.scale*smc.skills[this.skill_uuid].dis/3;
// console.log("monseter ",this.BoxRang);
this.buff.group=this.box_group
@@ -139,7 +146,6 @@ export class MonsterViewComp extends CCComp {
if(self_pos.x < other_pos.x){
this.stop_cd=0.1
}
this.stop_cd=0.1
break;
case BoxSet.MONSTER:
if(self_pos.x > other_pos.x){
@@ -188,12 +194,23 @@ export class MonsterViewComp extends CCComp {
// console.log("monster shoot");
let skill = ecs.getEntity<Skill>(Skill);
let x=32
let pos = v3(35*this.scale,40)
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;
skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk);
let angle=0
let t_pos:Vec3 = v3(0,0)
if(this.enemy){
t_pos = v3(this.enemy.position.x-this.node.position.x,this.enemy.position.y-this.node.position.y)
angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
if(this.scale == -1){
angle = angle +180
}
}else{
t_pos=null
}
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