131 lines
4.7 KiB
TypeScript
131 lines
4.7 KiB
TypeScript
import { _decorator, Component, Node, Vec3 } from 'cc';
|
|
import { oops } from 'db://oops-framework/core/Oops';
|
|
import { GameEvent } from '../common/config/GameEvent';
|
|
import { geDebuffNum, getBuffNum, BuffAttr, DebuffAttr, SkillSet } from '../common/config/SkillSet';
|
|
import { Timer } from 'db://oops-framework/core/common/timer/Timer';
|
|
import { FightSet } from '../common/config/Mission';
|
|
import { SuperCards, SuperCardsType } from '../common/config/CardSet';
|
|
import { EquipSpecialAttr } from '../common/config/Equips';
|
|
import { ecs } from 'db://oops-framework/libs/ecs/ECS';
|
|
import { Skill } from '../skills/Skill';
|
|
import { MasterModelComp } from '../hero/MasterModel';
|
|
import { HeroViewComp } from '../hero/HeroViewComp';
|
|
import { MonModelComp } from '../hero/MonModelComp';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('FightConComp')
|
|
export class FightConComp extends Component {
|
|
//装备 及 光环效果 物品存在生效 enemy_buff 是针对 怪物的debuff 偶尔也有buff 需要注意
|
|
hero_buff=getBuffNum()
|
|
enemy_buff=getBuffNum()
|
|
|
|
|
|
//注意临时buff和debuff 每种buff的值 必须都一样 多种值 战斗处理复杂 暂时放弃
|
|
atk_type:number=0;
|
|
//装备特殊属性 触发后 局内永久生效
|
|
atk_add_glod:number=0
|
|
atk_add_master_atk:number=0
|
|
atk_add_master_hp:number=0
|
|
double_atked:number=0
|
|
atked_add_skill_stone:number=0
|
|
atk_add_value:number=0
|
|
|
|
//卡牌特效
|
|
card_atk_add:number=0 //卡牌特效 攻击提高攻击力效果 额外添加值
|
|
card_hp_add:number=0 //卡牌特效 攻击提高生命值效果 额外添加值
|
|
|
|
|
|
|
|
|
|
aoe_pos:Vec3=new Vec3(-280,20,0)
|
|
buff_pos:Vec3=new Vec3(-280,100,0)
|
|
debuff_pos:Vec3=new Vec3(-280,100,0)
|
|
|
|
onLoad(){
|
|
// console.log("fight con start")
|
|
oops.message.on(GameEvent.EquipChange,this.equip_change,this)
|
|
oops.message.on(GameEvent.FightReady,this.fight_ready,this)
|
|
oops.message.on(GameEvent.ChangeATK_EQUIP_SPECIAL_ATTR,this.change_equip_special_attr,this)
|
|
oops.message.on(GameEvent.UseSpecialCard,this.use_special_card,this)
|
|
|
|
}
|
|
protected start(): void {
|
|
|
|
}
|
|
change_equip_special_attr(e:GameEvent,data:any){
|
|
console.log("[FightConComp]:change_equip_special_attr",data)
|
|
this.atk_add_value=data[EquipSpecialAttr.ATK_ADD_VALUE]
|
|
this.atk_add_glod=data[EquipSpecialAttr.ATK_ADD_GLOD]
|
|
this.atk_add_master_atk=data[EquipSpecialAttr.ATK_ADD_MASTER_ATK]+this.atk_add_value+(this.card_atk_add > 0 ? this.card_atk_add:0) //装备特殊属性 英雄/伙伴 攻击力增加
|
|
this.atk_add_master_hp=data[EquipSpecialAttr.ATK_ADD_MASTER_HP]+this.atk_add_value+(this.card_hp_add > 0 ? this.card_hp_add:0) //装备特殊属性 英雄/伙伴 生命值增加
|
|
this.double_atked=data[EquipSpecialAttr.DOUBLE_ATKED]
|
|
this.atked_add_skill_stone=data[EquipSpecialAttr.ATKED_ADD_SKILL_STONE]
|
|
}
|
|
|
|
|
|
|
|
private equip_change(e:GameEvent,equip:any){
|
|
|
|
}
|
|
|
|
private fight_ready(e:GameEvent){
|
|
this.clearAlls()
|
|
}
|
|
|
|
|
|
private use_special_card(e:GameEvent,data:any){
|
|
console.log("[FightConComp]:use_special_card:",SuperCards[data.uuid])
|
|
switch(SuperCards[data.uuid].type){
|
|
case SuperCardsType.SPECIAL:
|
|
switch(data.uuid){
|
|
case 3001:
|
|
console.log("[FightConComp]:use_special_card:附魔宝典")
|
|
this.card_atk_add+=SuperCards[data.uuid].value1
|
|
break
|
|
case 3002:
|
|
console.log("[FightConComp]:use_special_card:附魔宝典")
|
|
this.card_hp_add+=SuperCards[data.uuid].value1
|
|
break
|
|
}
|
|
break
|
|
case SuperCardsType.AOE:
|
|
oops.message.dispatchEvent(GameEvent.MaxSkill,{uuid:SuperCards[data.uuid].value1})
|
|
break
|
|
case SuperCardsType.BUFF:
|
|
|
|
break
|
|
case SuperCardsType.DEBUFF:
|
|
break
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
// /** 随机选择目标 */
|
|
// private pickRandomTarget(count: number=1): ecs.Entity[] {
|
|
// let entities = ecs.query(ecs.allOf(MonModelComp))
|
|
// const shuffled = [...entities].sort(() => 0.5 - Math.random());
|
|
// return shuffled.slice(0, count);
|
|
// }
|
|
|
|
private clearAlls() {
|
|
this.hero_buff=getBuffNum()
|
|
this.enemy_buff=getBuffNum()
|
|
this.atk_add_glod=0
|
|
this.atk_add_master_atk=0
|
|
this.atk_add_master_hp=0
|
|
this.double_atked=0
|
|
this.atked_add_skill_stone=0
|
|
this.atk_add_value=0
|
|
this.card_atk_add=0
|
|
this.card_hp_add=0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|