176 lines
6.8 KiB
TypeScript
176 lines
6.8 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()
|
|
friend_buff=getBuffNum()
|
|
enemy_buff=getBuffNum()
|
|
|
|
|
|
//注意临时buff和debuff 每种buff的值 必须都一样 多种值 战斗处理复杂 暂时放弃
|
|
atk_type:number=0;
|
|
//装备特殊属性 触发后 局内永久生效
|
|
friend_alive_cd:number=FightSet.FRIEND_LIVE_CD
|
|
atk_add_friend_atk:number=0
|
|
atk_add_friend_hp:number=0
|
|
atk_add_glod:number=0
|
|
atk_add_master_atk:number=0
|
|
atk_add_master_hp:number=0
|
|
double_dead:number=0
|
|
double_atked:number=0
|
|
friend_atked_add_skill_stone:number=0
|
|
atk_add_value:number=0
|
|
friend_get_master_equip: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 {
|
|
this.friend_alive_cd=FightSet.FRIEND_LIVE_CD
|
|
|
|
}
|
|
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_friend_atk=data[EquipSpecialAttr.ATK_ADD_FRIEND_ATK]+this.atk_add_value+(this.card_atk_add > 0 ? this.card_atk_add:0) //装备特殊属性 英雄/伙伴 攻击力增加
|
|
this.atk_add_friend_hp=data[EquipSpecialAttr.ATK_ADD_FRIEND_HP]+this.atk_add_value+(this.card_hp_add > 0 ? this.card_hp_add:0) //装备特殊属性 英雄/伙伴 生命值增加
|
|
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.friend_alive_cd=FightSet.FRIEND_LIVE_CD-data[EquipSpecialAttr.FRIEND_LIVE_CD]
|
|
this.double_dead=data[EquipSpecialAttr.DOUBLE_DEAD]
|
|
this.double_atked=data[EquipSpecialAttr.DOUBLE_ATKED]
|
|
this.friend_atked_add_skill_stone=data[EquipSpecialAttr.FRIEND_ATKED_ADD_SKILL_STONE]
|
|
this.friend_get_master_equip=data[EquipSpecialAttr.FRIEND_GET_MASTER_EQUIP]
|
|
}
|
|
|
|
|
|
|
|
private equip_change(e:GameEvent,equip:any){
|
|
let old_hero_hp=JSON.parse(JSON.stringify(this.hero_buff.HP))
|
|
let old_friend_hp=JSON.parse(JSON.stringify(this.friend_buff.HP))
|
|
|
|
let new_hero_hp=JSON.parse(JSON.stringify(equip.hero_buff.HP))
|
|
let new_friend_hp=JSON.parse(JSON.stringify(equip.friend_buff.HP))
|
|
|
|
this.hero_buff=equip.hero_buff
|
|
this.friend_buff=equip.friend_buff
|
|
this.enemy_buff=equip.enemy_buff
|
|
|
|
|
|
let hero_hp_add=new_hero_hp-old_hero_hp
|
|
let friend_hp_add=new_friend_hp-old_friend_hp
|
|
console.log("[FightConComp]:old_hero_hp:"+old_hero_hp+" new_hero_hp:"+new_hero_hp+" hero_hp_add:"+hero_hp_add)
|
|
if(hero_hp_add!==0){
|
|
|
|
oops.message.dispatchEvent(GameEvent.UpdateHP,{hp:hero_hp_add,is_master:true})
|
|
}
|
|
|
|
if(friend_hp_add!==0){
|
|
oops.message.dispatchEvent(GameEvent.UpdateHP,{hp:friend_hp_add,is_master:false})
|
|
}
|
|
|
|
this.scheduleOnce(()=>{
|
|
oops.message.dispatchEvent(GameEvent.UpdateVMData)
|
|
},0.1)
|
|
}
|
|
|
|
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.friend_buff=getBuffNum()
|
|
this.enemy_buff=getBuffNum()
|
|
|
|
|
|
this.friend_alive_cd=FightSet.FRIEND_LIVE_CD
|
|
this.atk_add_friend_atk=0
|
|
this.atk_add_friend_hp=0
|
|
this.atk_add_glod=0
|
|
this.atk_add_master_atk=0
|
|
this.atk_add_master_hp=0
|
|
this.double_dead=0
|
|
this.double_atked=0
|
|
this.friend_atked_add_skill_stone=0
|
|
this.atk_add_value=0
|
|
this.friend_get_master_equip=0
|
|
this.card_atk_add=0
|
|
this.card_hp_add=0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|