140 lines
4.3 KiB
TypeScript
140 lines
4.3 KiB
TypeScript
import { _decorator, Component, Node } from 'cc';
|
|
import { oops } from 'db://oops-framework/core/Oops';
|
|
import { GameEvent } from '../common/config/GameEvent';
|
|
import { geDebuffNum, getBuffNum, BuffAttr, DebuffAttr } from '../common/config/SkillSet';
|
|
import { Timer } from 'db://oops-framework/core/common/timer/Timer';
|
|
import { FightSet } from '../common/config/Mission';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('FightConComp')
|
|
export class FightConComp extends Component {
|
|
|
|
hero_buff=getBuffNum()
|
|
friend_buff=getBuffNum()
|
|
enemy_buff=getBuffNum()
|
|
|
|
hero_debuff=geDebuffNum()
|
|
friend_debuff=geDebuffNum()
|
|
enemy_debuff=geDebuffNum()
|
|
//注意临时buff和debuff 每种buff的值 必须都一样 多种值 战斗处理复杂 暂时放弃
|
|
temp_hero_buff = this.getInitTempBuff();
|
|
temp_friend_buff = this.getInitTempBuff();
|
|
temp_enemy_buff = this.getInitTempBuff();
|
|
|
|
temp_hero_debuff = this.getInitTempDebuff();
|
|
temp_friend_debuff = this.getInitTempDebuff();
|
|
temp_enemy_debuff = this.getInitTempDebuff();
|
|
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
|
|
|
|
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)
|
|
|
|
}
|
|
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_friend_atk=data.atk_add_friend_atk
|
|
this.atk_add_friend_hp=data.atk_add_friend_hp
|
|
this.atk_add_glod=data.atk_add_glod
|
|
this.atk_add_master_atk=data.atk_add_master_atk
|
|
this.atk_add_master_hp=data.atk_add_master_hp
|
|
this.friend_alive_cd=FightSet.FRIEND_LIVE_CD-data.friend_live_cd_less
|
|
}
|
|
|
|
|
|
|
|
private equip_change(e:GameEvent,equip:any){
|
|
this.hero_buff=equip.hero_buff
|
|
this.friend_buff=equip.friend_buff
|
|
|
|
this.hero_debuff=equip.hero_debuff
|
|
this.friend_debuff=equip.friend_debuff
|
|
this.enemy_debuff=equip.enemy_debuff
|
|
}
|
|
|
|
private fight_ready(e:GameEvent){
|
|
this.clearAlls()
|
|
}
|
|
|
|
// 添加临时buff
|
|
addTempBuff(target: 'hero'|'ally'|'enemy'|'friend', buffId: number, value: number, count: number) {
|
|
const key = `temp_${target}_buff`;
|
|
if (!this[key][buffId]) {
|
|
this[key][buffId] = { value, count };
|
|
} else {
|
|
this[key][buffId].value += value;
|
|
this[key][buffId].count += count;
|
|
}
|
|
}
|
|
|
|
// 触发一次buff效果后减少次数
|
|
triggerTempBuff(target: 'hero'|'ally'|'enemy'|'friend', buffId: number) {
|
|
const key = `temp_${target}_buff`;
|
|
if (this[key][buffId]) {
|
|
this[key][buffId].count -= 1;
|
|
if (this[key][buffId].count <= 0) {
|
|
delete this[key][buffId];
|
|
}
|
|
}
|
|
}
|
|
// 初始化所有buff/debuff为0
|
|
private getInitTempBuff() {
|
|
const obj = {};
|
|
for (const key in BuffAttr) {
|
|
if (!isNaN(Number(key))) {
|
|
obj[Number(key)] = { value: 0, count: 0 };
|
|
}
|
|
}
|
|
return obj;
|
|
}
|
|
|
|
private getInitTempDebuff() {
|
|
const obj = {};
|
|
for (const key in DebuffAttr) {
|
|
if (!isNaN(Number(key))) {
|
|
obj[Number(key)] = { value: 0, count: 0 };
|
|
}
|
|
}
|
|
return obj;
|
|
}
|
|
|
|
private clearAlls() {
|
|
this.hero_buff=getBuffNum()
|
|
this.friend_buff=getBuffNum()
|
|
this.enemy_buff=getBuffNum()
|
|
|
|
this.hero_debuff=geDebuffNum()
|
|
this.friend_debuff=geDebuffNum()
|
|
this.enemy_debuff=geDebuffNum()
|
|
|
|
this.temp_hero_buff = this.getInitTempBuff()
|
|
this.temp_friend_buff = this.getInitTempBuff()
|
|
this.temp_enemy_buff = this.getInitTempBuff()
|
|
|
|
this.temp_hero_debuff = this.getInitTempDebuff()
|
|
this.temp_friend_debuff = this.getInitTempDebuff()
|
|
this.temp_enemy_debuff = this.getInitTempDebuff()
|
|
}
|
|
|
|
update(deltaTime: number) {
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|