英雄召唤基本完成 下一步 满3个英雄后 不再出现其他英雄
This commit is contained in:
@@ -70,8 +70,8 @@ export class BuffComp extends Component {
|
||||
}
|
||||
hp_show(){
|
||||
// if(this.node.getComponent(HeroViewComp).fac == 0) return
|
||||
let hp=this.HeroView.hp;
|
||||
let hp_max=this.HeroView.hp_max;
|
||||
let hp=this.HeroView.currentHp;
|
||||
let hp_max=this.HeroView.currentHpMax;
|
||||
let hp_progress= hp/hp_max;
|
||||
this.hp_bar.progress = hp_progress;
|
||||
if(this.HeroView.is_boss) return
|
||||
@@ -91,11 +91,11 @@ export class BuffComp extends Component {
|
||||
let view_atk = 0 //临时buff
|
||||
let view_deatk = 0 //临时debuff
|
||||
if(is_hp){
|
||||
info.hp=this.HeroView.hp
|
||||
info.hp_max=this.HeroView.hp_max
|
||||
info.hp=this.HeroView.currentHp
|
||||
info.hp_max=this.HeroView.currentHpMax
|
||||
}else{
|
||||
info.hp=this.HeroView.hp
|
||||
info.hp_max=this.HeroView.hp_max
|
||||
info.hp=this.HeroView.currentHp
|
||||
info.hp_max=this.HeroView.currentHpMax
|
||||
|
||||
for(let i=0;i<this.HeroView.BUFF_ATKS.length;i++){
|
||||
view_atk += this.HeroView.BUFF_ATKS[i].value
|
||||
|
||||
@@ -10,8 +10,9 @@ import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp";
|
||||
import { FriendModelComp } from "./FriendModel";
|
||||
import { MasterModelComp } from "./MasterModel";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { BuffAttr } from "../common/config/SkillSet";
|
||||
import { BuffAttr, SkillSet } from "../common/config/SkillSet";
|
||||
import { FightSet } from "../common/config/Mission";
|
||||
import { Skill } from "../skills/Skill";
|
||||
/** 角色实体 */
|
||||
@ecs.register(`Hero`)
|
||||
|
||||
@@ -39,20 +40,29 @@ export class Hero extends ecs.Entity {
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有英雄槽位
|
||||
* @returns 英雄槽位数组
|
||||
*/
|
||||
private getHeroSlots(): any[] {
|
||||
return [smc.vmdata.hero1, smc.vmdata.hero2, smc.vmdata.hero3]
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找可用的英雄槽位
|
||||
* @returns 可用的英雄槽位对象,如果没有可用槽位则返回null
|
||||
*/
|
||||
private findAvailableHeroSlot(): any {
|
||||
return this.getHeroSlots().find(slot => slot.uuid === 0) || null
|
||||
}
|
||||
|
||||
/** 加载角色 */
|
||||
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,info:any={ap:0,hp:0,lv:1,crit:0,crit_d:0,dod:0,dod_no:false,crit_no:false},fight_pos:number=1) {
|
||||
// console.log("英雄加载:",uuid,pos,scale,info)
|
||||
scale = 1
|
||||
if(smc.vmdata.hero1.uuid==0){
|
||||
this.vmHero=smc.vmdata.hero1
|
||||
|
||||
}else if(smc.vmdata.hero2.uuid==0){
|
||||
this.vmHero=smc.vmdata.hero2
|
||||
|
||||
}else if(smc.vmdata.hero3.uuid==0){
|
||||
this.vmHero=smc.vmdata.hero3
|
||||
|
||||
}else{
|
||||
// 查找空闲英雄槽位
|
||||
this.vmHero = this.findAvailableHeroSlot()
|
||||
if (!this.vmHero) {
|
||||
console.log("[Hero] 英雄已满")
|
||||
return
|
||||
}
|
||||
@@ -95,7 +105,7 @@ export class Hero extends ecs.Entity {
|
||||
hv.hero_name= hero.name;
|
||||
hv.speed =hv.ospeed = hero.speed;
|
||||
hv.dis = hero.dis;
|
||||
this.vmHero.cd_max=hv.cd = hv.cd_base = hero.cd
|
||||
hv.cd = hv.cd_base = hero.cd
|
||||
this.vmHero.hp=this.vmHero.hp_max= hv.hp = hv.hp_max = hv.hp_base=hero.hp+info.hp
|
||||
hv.ap = hv.ap_base=hero.ap+info.ap;
|
||||
hero.buff.forEach((buff:any)=>{
|
||||
@@ -151,6 +161,8 @@ export class Hero extends ecs.Entity {
|
||||
}
|
||||
})
|
||||
hv.atk_skill=hero.skills[0]
|
||||
hv.skills=hero.skills
|
||||
this.vmHero.cd_max=SkillSet[hv.skills[1]].cd
|
||||
return hv
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,48 @@ export class HeroViewComp extends CCComp {
|
||||
|
||||
vmHero:any={}
|
||||
|
||||
/**
|
||||
* 获取当前血量 - 根据阵营选择正确的变量
|
||||
*/
|
||||
get currentHp(): number {
|
||||
if (this.fac === FacSet.HERO) {
|
||||
return this.vmHero.hp || 0;
|
||||
}
|
||||
return this.hp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前血量 - 根据阵营选择正确的变量
|
||||
*/
|
||||
set currentHp(value: number) {
|
||||
if (this.fac === FacSet.HERO) {
|
||||
this.vmHero.hp = value;
|
||||
} else {
|
||||
this.hp = value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最大血量 - 根据阵营选择正确的变量
|
||||
*/
|
||||
get currentHpMax(): number {
|
||||
if (this.fac === FacSet.HERO) {
|
||||
return this.vmHero.hp_max || 0;
|
||||
}
|
||||
return this.hp_max;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置最大血量 - 根据阵营选择正确的变量
|
||||
*/
|
||||
set currentHpMax(value: number) {
|
||||
if (this.fac === FacSet.HERO) {
|
||||
this.vmHero.hp_max = value;
|
||||
} else {
|
||||
this.hp_max = value;
|
||||
}
|
||||
}
|
||||
|
||||
box_group:number = BoxSet.HERO;
|
||||
|
||||
is_dead:boolean = false; //是否摧毁
|
||||
@@ -68,6 +110,7 @@ export class HeroViewComp extends CCComp {
|
||||
dis: number = 80;
|
||||
at: number = 0; /** 冷却时间 */
|
||||
atk_skill:number=0;
|
||||
skills:any[]=[]
|
||||
puncture:number=0; //穿刺敌人伤害后方敌人个数
|
||||
puncture_damage:number=0; //后伤害加成
|
||||
def: number = 0; //免伤
|
||||
@@ -156,6 +199,7 @@ export class HeroViewComp extends CCComp {
|
||||
this.as = this.getComponent(HeroSpine);
|
||||
//console.log("[HeroViewComp]:hero view comp ",this.FIGHTCON)
|
||||
this.on(GameEvent.EXPUP,this.exp_up,this)
|
||||
this.on(GameEvent.HeroLvUp,this.to_update_lv,this)
|
||||
const collider = this.node.getComponent(BoxCollider2D);
|
||||
this.scheduleOnce(()=>{
|
||||
if (collider) collider.enabled = true; // 先禁用
|
||||
@@ -311,7 +355,6 @@ export class HeroViewComp extends CCComp {
|
||||
return this.cd_base/((this.cd_buff+this.TALENT[BuffAttr.ATK_CD])/100+1)
|
||||
case BuffAttr.HP:
|
||||
return Math.floor(this.hp_base*(100+this.hp_buff+this.TALENT[BuffAttr.HP])/100)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,9 +369,9 @@ export class HeroViewComp extends CCComp {
|
||||
// this.update_vmdata()
|
||||
break
|
||||
case BuffAttr.HP:
|
||||
let diff=this.check_atrr(BuffAttr.HP)-this.hp_max
|
||||
this.hp_max=this.check_atrr(BuffAttr.HP)
|
||||
this.hp+=diff
|
||||
let diff=this.check_atrr(BuffAttr.HP)-this.currentHpMax
|
||||
this.currentHpMax=this.check_atrr(BuffAttr.HP)
|
||||
this.currentHp+=diff
|
||||
// this.update_vmdata()
|
||||
break
|
||||
}
|
||||
@@ -363,7 +406,7 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
|
||||
add_hp_max(hp: number=0,is_num:boolean=false){
|
||||
// console.log("[HeroViewComp]:add_hp_max add:",hp,this.hp_max)
|
||||
// console.log("[HeroViewComp]:add_hp_max add:",hp,this.currentHpMax)
|
||||
if(is_num){
|
||||
this.hp_base += Math.floor(hp) ;
|
||||
}else{
|
||||
@@ -374,7 +417,7 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
|
||||
de_hp_max(hp: number=0,is_num:boolean=true){ //最大值 只存在数值添加, 比例通过hp_buff处理
|
||||
//console.log("[HeroViewComp]:de_hp_max de:",hp,this.hp_max)
|
||||
//console.log("[HeroViewComp]:de_hp_max de:",hp,this.currentHpMax)
|
||||
this.hp_base -= Math.floor(hp) ;
|
||||
this.count_atrr(BuffAttr.HP)
|
||||
// this.update_vm
|
||||
@@ -383,8 +426,8 @@ export class HeroViewComp extends CCComp {
|
||||
add_hp(hp: number = 0,is_num:boolean=true) {
|
||||
this.BUFFCOMP.heathed();
|
||||
let real_hp=0
|
||||
let hp_max=Math.floor(this.hp_max*(100+this.hp_buff)/100)
|
||||
let lost_hp=hp_max-this.hp
|
||||
let hp_max=Math.floor(this.currentHpMax*(100+this.hp_buff)/100)
|
||||
let lost_hp=hp_max-this.currentHp
|
||||
if(is_num){
|
||||
if(lost_hp > hp){
|
||||
real_hp=Math.floor(hp);
|
||||
@@ -399,7 +442,7 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
}
|
||||
if(real_hp > 0){
|
||||
this.hp+=real_hp;
|
||||
this.currentHp+=real_hp;
|
||||
this.BUFFCOMP.tooltip(TooltipTypes.health,real_hp.toFixed(0));
|
||||
}
|
||||
// this.update_vm
|
||||
@@ -486,8 +529,8 @@ export class HeroViewComp extends CCComp {
|
||||
// this.is_stop=true
|
||||
break
|
||||
case DebuffAttr.DEHP:
|
||||
this.hp_max-=deV/100*this.hp_max
|
||||
if(this.hp-this.hp_max>0) this.hp=this.hp_max
|
||||
this.currentHpMax-=deV/100*this.currentHpMax
|
||||
if(this.currentHp-this.currentHpMax>0) this.currentHp=this.currentHpMax
|
||||
break
|
||||
case DebuffAttr.DEATK: //99为具体数字 并且局内永久生效,其他为百分比
|
||||
if(deC == 99){
|
||||
@@ -610,11 +653,11 @@ export class HeroViewComp extends CCComp {
|
||||
damage = Math.floor(damage * (1 + (FightSet.CRIT_DAMAGE+crit_d)/100))
|
||||
if(this.fac==FacSet.MON) smc.vmdata.hero.power+=smc.vmdata.hero.POWER_UP+FightSet.CRIT_TO_POWER //暴击涨能量 怪物被暴击,因为只有一个英雄 直接处理
|
||||
}
|
||||
this.hp -= damage;
|
||||
this.currentHp -= damage;
|
||||
if(this.fac==FacSet.HERO) smc.vmdata.hero.power+=smc.vmdata.hero.POWER_UP+FightSet.ATKED_TO_POWER //被攻击涨能量
|
||||
if(this.fac==FacSet.MON) smc.vmdata.hero.power+=smc.vmdata.hero.POWER_UP+FightSet.ATK_TO_POWER //攻击命中涨能量 因为是只有1个英雄 直接处理
|
||||
|
||||
if(this.hp <= 0) {
|
||||
if(this.currentHp <= 0) {
|
||||
if(this == null) return;
|
||||
this.is_dead=true
|
||||
this.BUFFCOMP.dead()
|
||||
@@ -727,7 +770,7 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
// to_alive(){
|
||||
// this.is_dead=false
|
||||
// this.hp=this.hp_max*(100+this.hp_buff)/100
|
||||
// this.currentHp=this.currentHpMax*(100+this.hp_buff)/100
|
||||
// this.BUFFCOMP.vmdata_update(true)
|
||||
// this.node.setPosition(HeroPos[this.fight_pos].pos)
|
||||
// this.BUFFCOMP.heathed()
|
||||
@@ -775,14 +818,18 @@ export class HeroViewComp extends CCComp {
|
||||
// smc.vmdata.hero.next_exp=getUpExp(this.lv)
|
||||
if(smc.vmdata.hero.exp >= smc.vmdata.hero.next_exp){
|
||||
// console.log("[HeroViewComp]:升级")
|
||||
this.to_update()
|
||||
this.to_update_lv("seft",data)
|
||||
oops.message.dispatchEvent(GameEvent.CanUpdateLv)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
to_update(){
|
||||
to_update_lv(event:string,data:any){
|
||||
if(this.fac==FacSet.MON) return
|
||||
console.log("[HeroViewComp]:升级",this.BUFFCOMP)
|
||||
if(this.hero_uuid!=data.uuid) return
|
||||
this.add_ap(HeroInfo[data.uuid].ap,true)
|
||||
this.add_hp_max(HeroInfo[data.uuid].hp,true)
|
||||
this.BUFFCOMP.lv_up()
|
||||
// this.BUFFCOMP.tooltip(TooltipTypes.lvup)
|
||||
}
|
||||
|
||||
@@ -47,8 +47,16 @@ export class SkillConComp extends CCComp {
|
||||
|
||||
update(dt: number) {
|
||||
if(!smc.mission.play||smc.mission.pause) return
|
||||
if(this.HeroView.DEBUFF_STUN <= 0&&this.HeroView.DEBUFF_FROST <= 0) this.HeroView.at += dt;
|
||||
|
||||
if(this.HeroView.DEBUFF_STUN <= 0&&this.HeroView.DEBUFF_FROST <= 0) {
|
||||
this.HeroView.at += dt;
|
||||
this.HeroView.vmHero.cd += dt
|
||||
}
|
||||
if(this.HeroView.vmHero.cd > this.HeroView.vmHero.cd_max){
|
||||
let sc=SkillSet[this.HeroView.skills[1]]
|
||||
if(!sc) return
|
||||
this.castSkill(sc,false,0)
|
||||
this.HeroView.vmHero.cd = 0
|
||||
}
|
||||
let cd = this.count_cd(this.HeroView.cd,this.HeroView)
|
||||
if (this.HeroView.is_atking &&(this.HeroView.at > cd)) {
|
||||
if(this.HeroView.is_dead) return
|
||||
|
||||
Reference in New Issue
Block a user