113 lines
3.5 KiB
TypeScript
113 lines
3.5 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';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('FightConComp')
|
|
export class FightConComp extends Component {
|
|
|
|
hero=getBuffNum()
|
|
ally=getBuffNum()
|
|
enemy=getBuffNum()
|
|
friend=getBuffNum()
|
|
hero_debuff=geDebuffNum()
|
|
ally_debuff=geDebuffNum()
|
|
enemy_debuff=geDebuffNum()
|
|
friend_debuff=geDebuffNum()
|
|
//注意临时buff和debuff 每种buff的值 必须都一样 多种值 战斗处理复杂 暂时放弃
|
|
temp_hero_buff = this.getInitTempBuff();
|
|
temp_ally_buff = this.getInitTempBuff();
|
|
temp_enemy_buff = this.getInitTempBuff();
|
|
temp_friend_buff = this.getInitTempBuff();
|
|
temp_hero_debuff = this.getInitTempDebuff();
|
|
temp_ally_debuff = this.getInitTempDebuff();
|
|
temp_enemy_debuff = this.getInitTempDebuff();
|
|
temp_friend_debuff = this.getInitTempDebuff();
|
|
|
|
onLoad(){
|
|
// console.log("fight con start")
|
|
oops.message.on(GameEvent.EquipChange,this.equip_change,this)
|
|
oops.message.on(GameEvent.FightReady,this.fight_ready,this)
|
|
}
|
|
|
|
private equip_change(e:GameEvent,equip:any){
|
|
this.hero=equip.hero
|
|
this.ally=equip.ally
|
|
this.enemy=equip.enemy
|
|
this.friend=equip.friend
|
|
}
|
|
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=getBuffNum()
|
|
this.ally=getBuffNum()
|
|
this.enemy=getBuffNum()
|
|
this.friend=getBuffNum()
|
|
this.hero_debuff=geDebuffNum()
|
|
this.ally_debuff=geDebuffNum()
|
|
this.enemy_debuff=geDebuffNum()
|
|
this.friend_debuff=geDebuffNum()
|
|
this.temp_hero_buff = this.getInitTempBuff()
|
|
this.temp_ally_buff = this.getInitTempBuff()
|
|
this.temp_enemy_buff = this.getInitTempBuff()
|
|
this.temp_friend_buff = this.getInitTempBuff()
|
|
this.temp_hero_debuff = this.getInitTempDebuff()
|
|
this.temp_ally_debuff = this.getInitTempDebuff()
|
|
this.temp_enemy_debuff = this.getInitTempDebuff()
|
|
this.temp_friend_debuff = this.getInitTempDebuff()
|
|
}
|
|
|
|
update(deltaTime: number) {
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|