ddd
This commit is contained in:
@@ -237,6 +237,26 @@ export class HeroViewComp extends CCComp {
|
||||
this.move(dt);
|
||||
}
|
||||
|
||||
//移动
|
||||
move(dt: number){
|
||||
if(this.stop_cd > 0||smc.mission.is_victory||smc.mission.is_defeat){
|
||||
this.status_change("idle")
|
||||
return
|
||||
}
|
||||
if (this.node.position.x >= 300 && this.scale==1) {
|
||||
return;
|
||||
}
|
||||
if(this.scale===-1&&this.node.position.x <= -300){
|
||||
return;
|
||||
}
|
||||
this.status_change("move")
|
||||
|
||||
|
||||
// if(this.enemy){
|
||||
// return
|
||||
// }
|
||||
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale, this.node.position.y+dt*this.dir_y, this.node.position.z);
|
||||
}
|
||||
check_mission_buff(){
|
||||
this.ap_max=(100+smc.vmdata.mission.ap)/100*this.ap
|
||||
this.crit_max=(100+smc.vmdata.mission.crit)/100*this.crit
|
||||
@@ -252,7 +272,7 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
}
|
||||
check_enemy_alive(){
|
||||
let dir = 320
|
||||
let dir = 720
|
||||
let enemys=smc.enemy_pos
|
||||
this.enemy = v3(720,this.node.position.y)
|
||||
if(this.box_group == BoxSet.MONSTER){
|
||||
@@ -290,26 +310,6 @@ export class HeroViewComp extends CCComp {
|
||||
// this.as.change_default("move")
|
||||
}
|
||||
}
|
||||
//移动
|
||||
move(dt: number){
|
||||
if(this.stop_cd > 0||smc.mission.is_victory||smc.mission.is_defeat){
|
||||
this.status_change("idle")
|
||||
return
|
||||
}
|
||||
if (this.node.position.x >= 300 && this.scale==1) {
|
||||
return;
|
||||
}
|
||||
if(this.scale===-1&&this.node.position.x <= -300){
|
||||
return;
|
||||
}
|
||||
this.status_change("move")
|
||||
|
||||
|
||||
// if(this.enemy){
|
||||
// return
|
||||
// }
|
||||
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale, this.node.position.y+dt*this.dir_y, this.node.position.z);
|
||||
}
|
||||
|
||||
skill_pos(){
|
||||
return v3((this.node.position.x,this.node.position.y + 35))
|
||||
@@ -355,6 +355,8 @@ export class HeroViewComp extends CCComp {
|
||||
if(is_crit){
|
||||
l_hp = l_hp * (150+crit_add)/100
|
||||
}
|
||||
let luck = RandomManager.instance.getRandomInt(-10,10)
|
||||
l_hp=l_hp*(100+luck)/100
|
||||
return Math.ceil(l_hp)
|
||||
}
|
||||
check_debuff(skill:any,l_hp:number=0){
|
||||
@@ -531,69 +533,31 @@ export class HeroViewComp extends CCComp {
|
||||
|
||||
switch (SkillSet[skill].tg) {
|
||||
case 0: //自己
|
||||
this.to_add_buff(this.node.getComponent(HeroViewComp),skill)
|
||||
this.do_add_buff(this.node.getComponent(HeroViewComp),skill)
|
||||
break;
|
||||
case 1: //伙伴
|
||||
this.push_least_buff(skill)
|
||||
this.check_other_buff(skill)
|
||||
break;
|
||||
case 2: //自己和伙伴
|
||||
|
||||
this.to_all_buff(skill)
|
||||
this.do_all_buff(skill)
|
||||
break;
|
||||
case 3: //敌人
|
||||
this.shoot_enemy(skill)
|
||||
break;
|
||||
case 4: //敌人和自己
|
||||
this.to_add_buff(this.node.getComponent(HeroViewComp),skill)
|
||||
this.do_add_buff(this.node.getComponent(HeroViewComp),skill)
|
||||
this.shoot_enemy(skill)
|
||||
break;
|
||||
}
|
||||
}
|
||||
to_all_buff(sk:number){
|
||||
|
||||
|
||||
}
|
||||
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()
|
||||
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);
|
||||
console.log(this.scale+this.hero_name+"使用技能:"+sk+" t_pos:"+t_pos+" box:"+this.box_group,);
|
||||
}
|
||||
to_add_buff(hero:any,sk:number){
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let t_pos=this.get_hero_pos(hero)
|
||||
let pos = this.skill_pos()
|
||||
console.log("to_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);
|
||||
console.log(this.scale+this.hero_name+"使用buff:"+sk+" t_pos:"+t_pos+" box:"+this.box_group,);
|
||||
|
||||
if(SkillSet[sk].hp > 0){ //buff加血
|
||||
let increase_hp=Math.floor(SkillSet[sk].hp*this.ap_max)
|
||||
hero.add_hp(increase_hp)
|
||||
}
|
||||
if(SkillSet[sk].apup > 0){ //buff加攻击
|
||||
let increase_atk=Math.floor(SkillSet[sk].apup*this.ap_max)
|
||||
hero.add_ap(increase_atk)
|
||||
}
|
||||
|
||||
if(SkillSet[sk].shield > 0){ //buff护盾
|
||||
hero.add_shield(SkillSet[sk].shield)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
push_least_buff(skill:number){
|
||||
check_other_buff(skill:number){
|
||||
let heros:any = ecs.query(ecs.allOf(HeroModelComp));
|
||||
let least_hp:number=0
|
||||
let t_hero:any= null
|
||||
if (heros.length > 0) {
|
||||
if(SkillSet[skill].type==92){ //随机添加buff
|
||||
|
||||
let i = RandomManager.instance.getRandomInt(0,heros.length-1,3)
|
||||
while(!heros[i].HeroView){
|
||||
i = RandomManager.instance.getRandomInt(0,heros.length-1,3)
|
||||
@@ -601,7 +565,7 @@ export class HeroViewComp extends CCComp {
|
||||
break
|
||||
}
|
||||
}
|
||||
this.to_add_buff(heros[i].HeroView,skill)
|
||||
this.do_add_buff(heros[i].HeroView,skill)
|
||||
}else{
|
||||
for (let i = 0; i < heros.length; i++) {
|
||||
if(!heros[i].HeroView) continue
|
||||
@@ -611,14 +575,11 @@ export class HeroViewComp extends CCComp {
|
||||
least_hp = (hero.rhp_max-hero.hp)
|
||||
t_hero = hero
|
||||
}
|
||||
}else{ //群体
|
||||
this.to_add_buff(hero,skill)
|
||||
}
|
||||
|
||||
}
|
||||
//todo 最前排 最后排 远程 近战 辅助
|
||||
}
|
||||
if(t_hero){ //血量最少单体
|
||||
|
||||
this.to_add_buff(t_hero,skill)
|
||||
if(t_hero){ //存在目标
|
||||
this.do_add_buff(t_hero,skill)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -626,7 +587,42 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
do_all_buff(sk:number){
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let t_pos=v3(-320,0)
|
||||
if(this.box_group==BoxSet.MONSTER){
|
||||
t_pos=v3(320,0)
|
||||
}
|
||||
let pos = t_pos
|
||||
this.to_console("to_all_buff:"+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("使用buff:"+sk+" t_pos:"+t_pos+" box:"+this.box_group);
|
||||
}
|
||||
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 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,);
|
||||
}
|
||||
do_add_buff(hero:any,sk:number){
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let t_pos=this.get_hero_pos(hero)
|
||||
let pos = this.skill_pos()
|
||||
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,);
|
||||
}
|
||||
|
||||
exp_add(exp:number=0){
|
||||
if(this.box_group==BoxSet.HERO){
|
||||
smc.vmdata.mission.exp +=exp
|
||||
@@ -644,7 +640,7 @@ export class HeroViewComp extends CCComp {
|
||||
* @param time 可选参数,表示增加行动点数的时间,默认为0。
|
||||
*/
|
||||
add_ap(ap: number){
|
||||
this.ap += ap;
|
||||
this.ap += Math.floor(ap);
|
||||
}
|
||||
add_shield(shield:number){
|
||||
this.shield =shield
|
||||
@@ -652,38 +648,32 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
add_hp(hp: number=0){
|
||||
this.BUFFCOMP.heathed();
|
||||
this.hp+=hp;
|
||||
this.hp+=Math.floor(hp);
|
||||
if(this.hp > this.rhp_max){
|
||||
this.hp = this.rhp_max;
|
||||
}
|
||||
this.BUFFCOMP.tooltip(2,hp.toFixed(0));
|
||||
}
|
||||
add_hp_max(hp: number=0){
|
||||
this.BUFFCOMP.show_buff(1)
|
||||
this.hp += hp/100*this.hp_max;
|
||||
this.BUFFCOMP.show_buff(0.5)
|
||||
this.hp += Math.floor(hp/100*this.hp_max) ;
|
||||
}
|
||||
hp_less(hp: number,is_crit:boolean=false){
|
||||
if(this.is_dead){
|
||||
return;
|
||||
}
|
||||
this.hp -= hp;
|
||||
if(this.is_dead) return
|
||||
hp=Math.floor(hp)
|
||||
this.hp -= hp
|
||||
if(is_crit){
|
||||
this.BUFFCOMP.tooltip(4,hp.toFixed(0),250);
|
||||
}else{
|
||||
this.BUFFCOMP.tooltip(1,hp.toFixed(0),250);
|
||||
}
|
||||
|
||||
if(this.hp > this.rhp_max){
|
||||
this.hp = this.rhp_max;
|
||||
}
|
||||
|
||||
if(this.hp <= 0){
|
||||
this.dead();
|
||||
this.to_grave()
|
||||
this.is_dead = true;
|
||||
// setTimeout(() => {
|
||||
// this.ent.destroy();
|
||||
// }, 15);
|
||||
}
|
||||
}
|
||||
/** 静止时间 */
|
||||
@@ -720,7 +710,6 @@ export class HeroViewComp extends CCComp {
|
||||
smc.vmdata.mission.dead +=1
|
||||
}
|
||||
this.node.setPosition(pos)
|
||||
|
||||
}
|
||||
//是否在墓地
|
||||
in_grave(){
|
||||
@@ -730,6 +719,10 @@ export class HeroViewComp extends CCComp {
|
||||
let pos =v3(HeroSet.StartPos[this.type],this.node.position.y,this.node.position.z)
|
||||
this.node.setPosition(pos)
|
||||
}
|
||||
|
||||
to_console(value:any){
|
||||
console.log("["+this.scale+this.hero_name+']'+value)
|
||||
}
|
||||
reset() {
|
||||
this.is_dead = false;
|
||||
this.node.destroy();
|
||||
|
||||
Reference in New Issue
Block a user