技能ui完成, todo 技能执行
This commit is contained in:
@@ -48,103 +48,6 @@ export class HeroBuffComp extends CCComp {
|
||||
this.mv= this.getComponent(HeroViewComp);
|
||||
} /** 视图层逻辑代码分离演示 */
|
||||
start () {
|
||||
|
||||
|
||||
}
|
||||
add_buff(uuid:number=0,args:any[]){
|
||||
|
||||
let new_buff={
|
||||
skill_uuid:uuid,
|
||||
skill_name:smc.skills[uuid].name,
|
||||
atk:smc.skills[uuid].atk,
|
||||
hp:smc.skills[uuid].hp,
|
||||
shield:smc.skills[uuid].shield,
|
||||
time:smc.skills[uuid].bsd,
|
||||
bcd:smc.skills[uuid].bcd,
|
||||
sk_uuid:smc.skills[uuid].uuid,
|
||||
args:args
|
||||
}
|
||||
this.buff_add(new_buff);
|
||||
}
|
||||
|
||||
|
||||
update(dt: number){
|
||||
if (this.timer.update(dt)) {
|
||||
this.buff_update()
|
||||
}
|
||||
}
|
||||
|
||||
reset() {
|
||||
|
||||
this.node.destroy();
|
||||
}
|
||||
show_buff_atk(){
|
||||
var path = "game/skills/buff/atk"
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
node.setPosition(this.node.position.x,this.node.position.y+40,this.node.position.z);
|
||||
}
|
||||
buff_add(buff:any){
|
||||
if(!this.node.isValid){ return }
|
||||
let i = 0
|
||||
if(this.buffs.length >=0){
|
||||
this.buffs.forEach((b:any,index:number)=>{
|
||||
if(b.skill_uuid==buff.skill_uuid){
|
||||
b.time=buff.time;
|
||||
if(buff.atk>0){
|
||||
this.mv.atk+=(buff.atk+buff.args.atk-b.atk);
|
||||
}
|
||||
if(buff.hp>0){
|
||||
this.mv.hp+=(buff.hp+buff.args.hp);
|
||||
this.mv.add_hp(buff.hp+buff.args.hp);
|
||||
// this.mv.hp_max+=(buff.hp-b.hp);
|
||||
}
|
||||
if(buff.shield>0){
|
||||
this.mv.shield=(buff.shield+buff.args.shield);
|
||||
// this.mv.shield_max=(buff.shield+buff.args.shield);
|
||||
}
|
||||
|
||||
i=index
|
||||
}
|
||||
})
|
||||
}
|
||||
if (i==0||this.buffs.length==0) {
|
||||
this.buffs.push(buff);
|
||||
if(buff.atk>0){
|
||||
this.mv.atk+=(buff.atk+buff.args.atk);
|
||||
this.show_buff_atk();
|
||||
}
|
||||
if(buff.hp>0){
|
||||
this.mv.hp+=(buff.hp+buff.args.hp);
|
||||
this.mv.add_hp(buff.hp+buff.args.hp);
|
||||
// this.mv.hp_max+=buff.hp;
|
||||
}
|
||||
if(buff.shield>0){
|
||||
this.mv.shield=(buff.shield+buff.args.shield);
|
||||
// this.mv.shield_max=(buff.shield+buff.args.shield);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
buff_remove(index:number){
|
||||
if(this.buffs[index].atk>0){
|
||||
this.mv.atk-=(this.buffs[index].atk+this.buffs[index].args.atk);
|
||||
}
|
||||
if(this.buffs[index].shield>0){
|
||||
this.mv.shield=0
|
||||
// this.mv.shield_max-=(this.buffs[index].shield+this.buffs[index].args.shield);
|
||||
}
|
||||
// if(this.buffs[index].hp>0){
|
||||
// this.mv.hp_max-=this.buffs[index].hp;
|
||||
// }
|
||||
}
|
||||
buff_update(){
|
||||
this.buffs.forEach((buff:any,index:number)=>{
|
||||
buff.time -= 0.1;
|
||||
if(buff.time <= 0){
|
||||
this.buff_remove(index);
|
||||
}
|
||||
})
|
||||
this.buffs = this.buffs.filter((buff:any) => buff.time > 0);
|
||||
}
|
||||
}
|
||||
@@ -483,9 +483,9 @@ export class HeroViewComp extends CCComp {
|
||||
handle_skill(skill:number){
|
||||
this.as.max()
|
||||
this.at = 0;
|
||||
this.tooltip(3,smc.skills[skill].name,skill);
|
||||
this.tooltip(3,SkillSet[skill].name,skill);
|
||||
|
||||
switch (smc.skills[skill].tg) {
|
||||
switch (SkillSet[skill].tg) {
|
||||
case 0: //自己
|
||||
this.to_add_buff(this.node.getComponent(HeroViewComp),skill)
|
||||
break;
|
||||
@@ -521,25 +521,25 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
to_add_buff(hero:any,sk:number){
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let AP = smc.skills[sk].ap+this.ap+smc.vmdata.mission.ap; //攻击力需要加上局内buff
|
||||
let AP = SkillSet[sk].ap+this.ap+smc.vmdata.mission.ap; //攻击力需要加上局内buff
|
||||
if(this.box_group == BoxSet.MONSTER){
|
||||
AP = smc.skills[sk].ap+this.ap+smc.vmdata.mission.map;
|
||||
AP = SkillSet[sk].ap+this.ap+smc.vmdata.mission.map;
|
||||
}
|
||||
let {pos,t_pos}=this.get_hero_pos(hero)
|
||||
console.log("to_add_buff:"+hero.hero_name+" "+sk);
|
||||
let is_crit=this.check_crit()
|
||||
skill.load(pos,this.box_group,this.node,sk,AP,t_pos,is_crit,this.crit_add);
|
||||
if(smc.skills[sk].hp > 0){ //buff加血
|
||||
let increase_hp=Math.floor(smc.skills[sk].hp*AP)
|
||||
if(SkillSet[sk].hp > 0){ //buff加血
|
||||
let increase_hp=Math.floor(SkillSet[sk].hp*AP)
|
||||
hero.add_hp(increase_hp)
|
||||
}
|
||||
if(smc.skills[sk].ap > 0){ //buff加攻击
|
||||
let increase_atk=Math.floor(smc.skills[sk].ap*AP)
|
||||
hero.add_ap(increase_atk,smc.skills[sk].bsd)
|
||||
if(SkillSet[sk].ap > 0){ //buff加攻击
|
||||
let increase_atk=Math.floor(SkillSet[sk].ap*AP)
|
||||
hero.add_ap(increase_atk,SkillSet[sk].bsd)
|
||||
}
|
||||
|
||||
if(smc.skills[sk].shield > 0){ //buff护盾
|
||||
hero.add_shield(smc.skills[sk].shield)
|
||||
if(SkillSet[sk].shield > 0){ //buff护盾
|
||||
hero.add_shield(SkillSet[sk].shield)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -549,7 +549,7 @@ export class HeroViewComp extends CCComp {
|
||||
let least_hp:number=0
|
||||
let t_hero:any= null
|
||||
if (heros.length > 0) {
|
||||
if(smc.skills[skill].type==92){ //随机添加buff
|
||||
if(SkillSet[skill].type==92){ //随机添加buff
|
||||
|
||||
let i = RandomManager.instance.getRandomInt(0,heros.length-1,3)
|
||||
while(!heros[i].HeroView){
|
||||
@@ -563,7 +563,7 @@ export class HeroViewComp extends CCComp {
|
||||
for (let i = 0; i < heros.length; i++) {
|
||||
if(!heros[i].HeroView) continue
|
||||
let hero = heros[i].HeroView;
|
||||
if(smc.skills[skill].type==91){ //血量最少单体
|
||||
if(SkillSet[skill].type==91){ //血量最少单体
|
||||
if((hero.hp_max-hero.hp) > least_hp){
|
||||
least_hp = (hero.hp_max-hero.hp)
|
||||
t_hero = hero
|
||||
|
||||
Reference in New Issue
Block a user