装备加成错误解决
This commit is contained in:
@@ -58,35 +58,26 @@ export const EquipInfo: { [key: number]: EquipData } = {
|
||||
2001: {uuid: 2001, name: "新手剑", type: EquipType.WEAPON,info:"攻击力增加80%",
|
||||
attributes: [
|
||||
{ type: BuffAttr.ATK, value: 80, target: EquipAttrTarget.HERO },
|
||||
{ type: BuffAttr.ATK_CD, value: 30, target: EquipAttrTarget.HERO },
|
||||
{ type: BuffAttr.ATK_COUNT, value: 1, target: EquipAttrTarget.HERO },
|
||||
]
|
||||
},
|
||||
2002: {uuid: 2002,name: "新手剑2",type: EquipType.WEAPON,info:"攻击速度增加30%",
|
||||
attributes: [
|
||||
{ type: BuffAttr.ATK_CD, value: 30, target: EquipAttrTarget.HERO },
|
||||
{ type: BuffAttr.ATK_COUNT, value: 1, target: EquipAttrTarget.HERO },
|
||||
]
|
||||
},
|
||||
2003: {uuid: 2003,name: "新手剑3",type: EquipType.WEAPON,info:"攻击次数增加1次",
|
||||
attributes: [
|
||||
{ type: BuffAttr.ATK_COUNT, value: 1, target: EquipAttrTarget.HERO },
|
||||
{ type: BuffAttr.ATK_CD, value: 30, target: EquipAttrTarget.HERO },
|
||||
{ type: BuffAttr.ATK_COUNT, value: 1, target: EquipAttrTarget.HERO },
|
||||
]
|
||||
},
|
||||
2004: {uuid: 2004,name: "防具1",type: EquipType.ARMOR,info:"生命值增加100%",
|
||||
attributes: [
|
||||
{ type: BuffAttr.HP, value: 100, target: EquipAttrTarget.HERO },
|
||||
{ type: BuffAttr.ATK_CD, value: 30, target: EquipAttrTarget.HERO },
|
||||
{ type: BuffAttr.ATK_COUNT, value: 1, target: EquipAttrTarget.HERO },
|
||||
]
|
||||
},
|
||||
2005: {uuid: 2005,name: "防具2",type: EquipType.ARMOR,info:"免伤增加50%",
|
||||
attributes: [
|
||||
{ type: BuffAttr.DEF, value: 50, target: EquipAttrTarget.HERO },
|
||||
{ type: BuffAttr.ATK_CD, value: 30, target: EquipAttrTarget.HERO },
|
||||
{ type: BuffAttr.ATK_COUNT, value: 1, target: EquipAttrTarget.HERO },
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ export const MissionStatus = {
|
||||
}
|
||||
export enum FightSet {
|
||||
FRIND_WAVE_UP=2, //伙伴登场波次
|
||||
MON_WAVE_TIME=10,//怪物波次时间
|
||||
// ATK_TO_ATK_RATIO=0.1,
|
||||
// ATK_TO_HP_RATIO=0.2,
|
||||
// ATK_TO_SHIELD_RATIO=2,
|
||||
|
||||
@@ -48,8 +48,8 @@ export class SkillConComp extends CCComp {
|
||||
cd=this.HeroView.cd*(100-this.FIGHTCON.friend.ATK_CD-this.FIGHTCON.ally.ATK_CD+this.FIGHTCON.friend_debuff.DECD+this.FIGHTCON.ally_debuff.DECD)/100
|
||||
}
|
||||
}else{
|
||||
cd=this.HeroView.cd*(100-this.FIGHTCON.enemy.ATK_CD+this.FIGHTCON.enemy_debuff.DECD)/100
|
||||
count+=this.FIGHTCON.enemy.ATK_COUNT-this.FIGHTCON.enemy_debuff.DECOUNT
|
||||
cd=this.HeroView.cd*(100-this.FIGHTCON.enemy.ATK_CD+this.FIGHTCON.enemy_debuff.DECD)/100
|
||||
}
|
||||
if(count<1) count=1
|
||||
// console.log(this.HeroView.hero_name+(this.HeroView.is_master?"[主]":"[从] 准备释放")+SkillSet[this.HeroView.atk_skill].name+"=>"+"=>cd:"+cd+"=> count:"+count)
|
||||
|
||||
@@ -111,19 +111,48 @@ export class EquipsComp extends Component {
|
||||
count_attrs(){
|
||||
// 重置所有属性
|
||||
this.reset_attrs();
|
||||
console.log("重置后的属性", this.attrs);
|
||||
|
||||
// 获取所有装备的属性
|
||||
let weapon_attrs = this.weapon.uuid ? EquipInfo[this.weapon.uuid]?.attributes || [] : [];
|
||||
let armor_attrs = this.armor.uuid ? EquipInfo[this.armor.uuid]?.attributes || [] : [];
|
||||
let accessory_attrs = this.accessory.uuid ? EquipInfo[this.accessory.uuid]?.attributes || [] : [];
|
||||
|
||||
console.log("武器属性", weapon_attrs);
|
||||
console.log("防具属性", armor_attrs);
|
||||
console.log("饰品属性", accessory_attrs);
|
||||
|
||||
// 合并所有装备属性
|
||||
const allAttrs = [...weapon_attrs, ...armor_attrs, ...accessory_attrs];
|
||||
console.log("合并后的所有属性", allAttrs);
|
||||
|
||||
// 计算每个目标的属性加成
|
||||
allAttrs.forEach(attr => {
|
||||
const target = attr.target || EquipAttrTarget.ALL;
|
||||
const targetKey = this.getTargetKey(target);
|
||||
let targetKey = null;
|
||||
|
||||
// 根据目标类型获取对应的key
|
||||
switch (target) {
|
||||
case EquipAttrTarget.ALL:
|
||||
targetKey = 'ally';
|
||||
break;
|
||||
case EquipAttrTarget.HERO:
|
||||
targetKey = 'hero';
|
||||
break;
|
||||
case EquipAttrTarget.FRIEND:
|
||||
targetKey = 'friend';
|
||||
break;
|
||||
case EquipAttrTarget.ENEMY:
|
||||
targetKey = 'enemy';
|
||||
break;
|
||||
}
|
||||
|
||||
console.log("处理属性加成", {
|
||||
target: target,
|
||||
targetKey: targetKey,
|
||||
attr: attr,
|
||||
beforeValue: targetKey ? this.attrs[targetKey][BuffAttr[attr.type]] : null
|
||||
});
|
||||
|
||||
if (targetKey) {
|
||||
switch (attr.type) {
|
||||
@@ -155,32 +184,39 @@ export class EquipsComp extends Component {
|
||||
this.attrs[targetKey].CARD_COUNT += attr.value;
|
||||
break;
|
||||
}
|
||||
|
||||
console.log("属性加成后", {
|
||||
targetKey: targetKey,
|
||||
attrType: BuffAttr[attr.type],
|
||||
afterValue: this.attrs[targetKey][BuffAttr[attr.type]]
|
||||
});
|
||||
}
|
||||
});
|
||||
console.log("count_attrs",this.attrs)
|
||||
oops.message.dispatchEvent(GameEvent.EquipChange,this.attrs)
|
||||
console.log("最终属性加成", this.attrs);
|
||||
oops.message.dispatchEvent(GameEvent.EquipChange, this.attrs);
|
||||
}
|
||||
|
||||
// 重置所有属性为0
|
||||
private reset_attrs() {
|
||||
this.attrs.hero=this.attrs.ally=this.attrs.enemy=this.attrs.friend=getBuffNum()
|
||||
// 创建新的属性对象
|
||||
const newAttrs = {
|
||||
hero: getBuffNum(),
|
||||
ally: getBuffNum(),
|
||||
enemy: getBuffNum(),
|
||||
friend: getBuffNum()
|
||||
};
|
||||
|
||||
// 替换整个 attrs 对象
|
||||
this.attrs = newAttrs;
|
||||
|
||||
console.log("重置属性", {
|
||||
hero: this.attrs.hero,
|
||||
ally: this.attrs.ally,
|
||||
enemy: this.attrs.enemy,
|
||||
friend: this.attrs.friend
|
||||
});
|
||||
}
|
||||
|
||||
// 根据目标类型获取对应的key
|
||||
private getTargetKey(target: EquipAttrTarget): string | null {
|
||||
switch (target) {
|
||||
case EquipAttrTarget.ALL:
|
||||
return 'hero'; // 默认作用于英雄
|
||||
case EquipAttrTarget.HERO:
|
||||
return 'hero';
|
||||
case EquipAttrTarget.FRIEND:
|
||||
return 'friend';
|
||||
case EquipAttrTarget.ENEMY:
|
||||
return 'enemy';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
equip_remove(e:GameEvent,data:any){
|
||||
console.log("equip_remove",data)
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@ export class FightConComp extends Component {
|
||||
enemy_debuff=geDebuffNum()
|
||||
friend_debuff=geDebuffNum()
|
||||
//注意临时buff和debuff 每种buff的值 必须都一样 多种值 战斗处理复杂 暂时放弃
|
||||
temp_hero_buff = this.getInitTempDebuff();
|
||||
temp_ally_buff = this.getInitTempDebuff();
|
||||
temp_enemy_buff = this.getInitTempDebuff();
|
||||
temp_friend_buff = this.getInitTempDebuff();
|
||||
temp_hero_debuff = this.getInitTempBuffDebuff();
|
||||
temp_ally_debuff = this.getInitTempBuffDebuff();
|
||||
temp_enemy_debuff = this.getInitTempBuffDebuff();
|
||||
temp_friend_debuff = this.getInitTempBuffDebuff();
|
||||
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")
|
||||
@@ -38,17 +38,7 @@ export class FightConComp extends Component {
|
||||
this.friend=equip.friend
|
||||
}
|
||||
private fight_ready(e:GameEvent){
|
||||
this.hero=this.ally=this.enemy=this.friend=getBuffNum()
|
||||
this.hero_debuff=this.ally_debuff=this.enemy_debuff=this.friend_debuff=geDebuffNum()
|
||||
this.clearAllTempBuffs()
|
||||
// console.log("临时英雄buff:",this.temp_hero_buff)
|
||||
// console.log("临时英雄debuff:",this.temp_hero_debuff)
|
||||
// console.log("临时全部buff:",this.temp_ally_buff)
|
||||
// console.log("临时全部debuff:",this.temp_ally_debuff)
|
||||
// console.log("临时敌方buff:",this.temp_enemy_buff)
|
||||
// console.log("临时敌方debuff:",this.temp_enemy_debuff)
|
||||
// console.log("临时友军buff:",this.temp_friend_buff)
|
||||
// console.log("临时友军debuff:",this.temp_friend_debuff)
|
||||
this.clearAlls()
|
||||
}
|
||||
|
||||
// 添加临时buff
|
||||
@@ -73,7 +63,7 @@ export class FightConComp extends Component {
|
||||
}
|
||||
}
|
||||
// 初始化所有buff/debuff为0
|
||||
private getInitTempBuffDebuff() {
|
||||
private getInitTempBuff() {
|
||||
const obj = {};
|
||||
for (const key in BuffAttr) {
|
||||
if (!isNaN(Number(key))) {
|
||||
@@ -93,9 +83,23 @@ export class FightConComp extends Component {
|
||||
return obj;
|
||||
}
|
||||
|
||||
private clearAllTempBuffs() {
|
||||
this.temp_hero_buff = this.temp_ally_buff = this.temp_enemy_buff = this.temp_friend_buff = this.getInitTempBuffDebuff();
|
||||
this.temp_hero_debuff = this.temp_ally_debuff = this.temp_enemy_debuff = this.temp_friend_debuff = this.getInitTempDebuff();
|
||||
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) {
|
||||
|
||||
@@ -28,7 +28,7 @@ export class MissionComp extends CCComp {
|
||||
this.on(GameEvent.MissionStart,this.mission_start,this)
|
||||
this.on(GameEvent.FightEnd,this.fight_end,this)
|
||||
this.on(GameEvent.MissionEnd,this.mission_end,this)
|
||||
this.on(GameEvent.CardsClose,this.after_used_skill_card,this)
|
||||
// this.on(GameEvent.CardsClose,this.after_used_skill_card,this)
|
||||
this.on(GameEvent.WaveUpdate,this.on_mon_wave_update,this)
|
||||
}
|
||||
|
||||
@@ -60,7 +60,6 @@ export class MissionComp extends CCComp {
|
||||
}
|
||||
|
||||
async mission_start(){
|
||||
smc.mission.status=MissionStatus.ready
|
||||
oops.message.dispatchEvent(GameEvent.FightReady)
|
||||
this.node.active=true
|
||||
this.data_init()
|
||||
@@ -68,42 +67,27 @@ export class MissionComp extends CCComp {
|
||||
let loading=this.node.parent.getChildByName("loading")
|
||||
loading.active=true
|
||||
this.scheduleOnce(()=>{
|
||||
this.to_hero_skill_select()
|
||||
this.to_ready()
|
||||
this.to_fight()
|
||||
loading.active=false
|
||||
},0.5)
|
||||
}
|
||||
|
||||
to_hero_skill_select(){
|
||||
to_ready(){
|
||||
console.log("英雄技能选择")
|
||||
oops.message.dispatchEvent(GameEvent.HeroSkillSelect)
|
||||
smc.mission.status=MissionStatus.ready_skill_select
|
||||
}
|
||||
after_used_skill_card(){
|
||||
switch(smc.mission.status){
|
||||
case MissionStatus.ready_skill_select:
|
||||
console.log("next => to_fight")
|
||||
this.scheduleOnce(()=>{
|
||||
this.to_fight()
|
||||
},0.3)
|
||||
break
|
||||
case MissionStatus.playing:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
to_hero_select(){
|
||||
smc.mission.status=MissionStatus.ready_hero_select
|
||||
oops.message.dispatchEvent(GameEvent.HeroSelect)
|
||||
}
|
||||
|
||||
to_fight(){
|
||||
smc.mission.status=MissionStatus.playing
|
||||
smc.vmdata.mission_data.in_fight=true
|
||||
oops.message.dispatchEvent(GameEvent.FightStart)
|
||||
oops.message.dispatchEvent(GameEvent.FightStart) //MissionMonComp 监听刷怪
|
||||
}
|
||||
|
||||
|
||||
to_end_fight(){
|
||||
smc.mission.status=MissionStatus.end
|
||||
oops.message.dispatchEvent(GameEvent.FightEnd)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
|
||||
import { Monster } from "../hero/Mon";
|
||||
import { BoxSet } from "../common/config/BoxSet";
|
||||
import { HeroSet, MonSet } from "../common/config/heroSet";
|
||||
import { Missions } from "../common/config/Mission";
|
||||
import { FightSet, Missions } from "../common/config/Mission";
|
||||
import { RandomManager } from "db://oops-framework/core/common/random/RandomManager";
|
||||
import { Timer } from "db://oops-framework/core/common/timer/Timer";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
@@ -23,8 +23,9 @@ export class MissionMonCompComp extends CCComp {
|
||||
private isSpawning: boolean = false;// 是否正在生成怪物
|
||||
private spawnInterval: number = 1; // 每个怪物生成间隔时间
|
||||
private spawnTimer: number = 0; // 生成计时器
|
||||
private is_fight:boolean = false;
|
||||
onLoad(){
|
||||
this.on(GameEvent.FightStart,this.mon_refresh,this)
|
||||
this.on(GameEvent.FightStart,this.to_fight,this)
|
||||
}
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
@@ -34,10 +35,12 @@ export class MissionMonCompComp extends CCComp {
|
||||
}
|
||||
protected update(dt: number): void {
|
||||
if(!smc.mission.play||smc.mission.pause) return
|
||||
// if(this.timer.update(dt)){
|
||||
// this.mon_refresh()
|
||||
// }
|
||||
|
||||
if(this.is_fight) {
|
||||
if(this.timer.update(dt)){
|
||||
this.do_mon_wave()
|
||||
}
|
||||
}
|
||||
// 处理刷怪队列
|
||||
if (this.monsterQueue.length > 0 && !this.isSpawning) {
|
||||
this.spawnTimer += dt;
|
||||
@@ -47,14 +50,20 @@ export class MissionMonCompComp extends CCComp {
|
||||
}
|
||||
}
|
||||
}
|
||||
to_fight(){
|
||||
console.log("[MissionMonComp]:to_fight")
|
||||
this.is_fight=true
|
||||
this.do_mon_wave()
|
||||
this.timer=new Timer(FightSet.MON_WAVE_TIME)
|
||||
}
|
||||
test_call(){
|
||||
this.addToSpawnQueue(5202, 0, true);
|
||||
}
|
||||
|
||||
|
||||
mon_refresh(){
|
||||
do_mon_wave(){
|
||||
oops.message.dispatchEvent(GameEvent.WaveUpdate)
|
||||
console.log("怪物登场,当前波次 :",smc.vmdata.mission_data.current_wave)
|
||||
console.log("[MissionMonComp]:怪物登场,当前波次 :",smc.vmdata.mission_data.current_wave)
|
||||
let positions = [0, 1, 2];
|
||||
positions.forEach(pos => {
|
||||
let x = RandomManager.instance.getRandomInt(0, Missions[0].length, 1);
|
||||
@@ -62,6 +71,7 @@ export class MissionMonCompComp extends CCComp {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 新增:添加到刷怪队列
|
||||
private addToSpawnQueue(uuid: number, position: number, isBoss: boolean = false) {
|
||||
this.monsterQueue.push({
|
||||
|
||||
Reference in New Issue
Block a user