继续完善 装备buff

This commit is contained in:
2025-06-12 16:24:23 +08:00
parent 4c0d1023a0
commit cb38aa55a4
12 changed files with 227 additions and 190 deletions

View File

@@ -1,4 +1,5 @@
import { _decorator, Component, Node, view, UITransform, Vec3, math, EventHandler, Graphics, Color, TweenEasing, Enum } from 'cc';
import { SkillCom } from '../skills/SkillCom';
const { ccclass, property } = _decorator;
// 定义缓动类型枚举
@@ -151,7 +152,11 @@ export class BezierMove extends Component {
this.node.setPosition(this._endPoint);
this._isMoving = false;
// 触发移动完成事件
// EventHandler.emitEvents(this.onMoveComplete, this);
console.log("onMoveComplete")
let skill=this.node.getComponent(SkillCom)
if(skill){
skill.doDestroy()
}
this._moveEndCallback && this._moveEndCallback.apply(this._moveEndTarget);
// 清除轨迹
if (this.showTrajectory && this._graphics) {

View File

@@ -54,6 +54,10 @@ export enum GameSet {
AP_UPDATE_RATE=120,
AP_CHANGE_RATE=100,
}
export enum FacSet {
HERO=0,
MON=1,
}
export const ColorSet: { [key: string]: string } = {
RED: "FF364D",
RED1: "FC1702",

View File

@@ -1,4 +1,5 @@
import { app } from "electron";
import { BuffAttr } from "./SkillSet";
// 装备类型
export enum EquipType {
@@ -7,18 +8,6 @@ export enum EquipType {
ACCESSORY = 3 // 饰品
}
// 基础属性加成
export enum EquipAttr {
ATK = 1, // 攻击力
ATK_COUNT = 2, // 攻击个数
ATK_CD = 3, // 攻击速度
HP = 4, // 生命值
DEF = 5, // 免伤
SKILL_DMG = 6, // 技能效果
SKILL_CD = 7, // 技能冷却缩减
CARD_EFFECT = 8, // 卡牌效果
CARD_COUNT = 8, // 卡牌起效次数,每3次多起效一次
}
//装备属性起效对象
export enum EquipAttrTarget {
ALL = 0, // 所有
@@ -52,7 +41,7 @@ export const accessory_id=[2201,2202,2203,2204,2205,2206,2207,2208,2209,2210,221
export const equip_list=[2001,2002,2003,2004,2005]
// 装备属性加成接口
export interface EquipAttribute {
type: EquipAttr; // 属性类型
type: BuffAttr; // 属性类型
value: number; // 属性值
target?: EquipAttrTarget; // 属性作用目标(可选)
}
@@ -68,36 +57,36 @@ export interface EquipData {
export const EquipInfo: { [key: number]: EquipData } = {
2001: {uuid: 2001, name: "新手剑", type: EquipType.WEAPON,info:"攻击力增加80%",
attributes: [
{ type: EquipAttr.ATK, value: 80, target: EquipAttrTarget.HERO },
{ type: EquipAttr.ATK_CD, value: 30, target: EquipAttrTarget.HERO },
{ type: EquipAttr.ATK_COUNT, value: 1, target: EquipAttrTarget.HERO },
{ 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: EquipAttr.ATK_CD, value: 30, target: EquipAttrTarget.HERO },
{ type: EquipAttr.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 },
]
},
2003: {uuid: 2003,name: "新手剑3",type: EquipType.WEAPON,info:"攻击次数增加1次",
attributes: [
{ type: EquipAttr.ATK_COUNT, value: 1, target: EquipAttrTarget.HERO },
{ type: EquipAttr.ATK_CD, value: 30, target: EquipAttrTarget.HERO },
{ type: EquipAttr.ATK_COUNT, value: 1, target: EquipAttrTarget.HERO },
{ 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: EquipAttr.HP, value: 100, target: EquipAttrTarget.HERO },
{ type: EquipAttr.ATK_CD, value: 30, target: EquipAttrTarget.HERO },
{ type: EquipAttr.ATK_COUNT, value: 1, target: EquipAttrTarget.HERO },
{ 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: EquipAttr.DEF, value: 50, target: EquipAttrTarget.HERO },
{ type: EquipAttr.ATK_CD, value: 30, target: EquipAttrTarget.HERO },
{ type: EquipAttr.ATK_COUNT, value: 1, target: EquipAttrTarget.HERO },
{ 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 },
]
},

View File

@@ -1,5 +1,3 @@
export enum TargetGroup {
Self = 0, // 自身
Ally = 1, // 友方单位
@@ -29,6 +27,7 @@ export enum skRun {
runing = 0,
dead = 1,
}
//技能释放cd: 0:技能配置的cd,1:HeroViewComp.cd 值,2:HeroViewComp.pw:0值,当HeroViewComppw==HeroViewComp.pwm值是 释放
export enum CdType {
SkillCD = 0, // 使用技能配置的cd
@@ -37,16 +36,17 @@ export enum CdType {
AtkCount = 3, // 攻击次数触发
BeAtkCount = 4, // 被攻击次数触发
}
//技能释放cd: 0:技能配置的cd,1:HeroViewComp.cd 值,2:HeroViewComp.pw:0值,当HeroViewComppw==HeroViewComp.pwm值是 释放
//技能释放cd: 0:技能配置的cd,1:HeroViewComp.cd 值,2:HeroViewComp.pw:0值,当HeroViewComppw==HeroViewComp.pwm值是 释放
export enum AnimType {
linear = 0, // 直线
parabolic = 1, // 抛物线 贝塞尔
fixed = 2, // 固定位置
fixedStart = 3, // 固定在出发点
fixedEnd = 4, // 固定在终点
}
export enum endType {
animationEnd = 0,
timeEnd = 1,
@@ -55,23 +55,58 @@ export enum endType {
countEnd = 4,
}
export enum Debuff {
export enum DebuffAttr {
STUN = 1, //眩晕
SILENCE = 2, //沉默
SLOW = 2, //减速
FROST = 3, //冰冻
POISON = 4, //中毒
BURN = 5, //燃烧
BLEED = 6, //流血
SLOW = 7, //减
SPEED = 8, //加速
BURN = 4, //易伤
DECD = 5, //减cd
DEHP = 6, //减hp
DEATK = 7, //减atk
DEDEF = 8, //减def
DECOUNT = 9, //减攻击次数
}
export enum Buff {
SHIELD = 1, //护盾
HEAL = 2, //治疗
DOUBLE_ATK = 3, //双倍攻击
THREE_ATK = 4, //三倍攻击
export const geDebuffNum=()=>{
return {
STUN:0,
SLOW:0,
FROST:0,
BURN:0,
DECD:0,
DEHP:0,
DEATK:0,
DEDEF:0,
DECOUNT:0,
}
}
export enum BuffAttr {
ATK = 1, // 攻击力
ATK_COUNT = 2, // 攻击个数
ATK_CD = 3, // 攻击速度
HP = 4, // 生命值
DEF = 5, // 免伤
SKILL_DMG = 6, // 技能效果
SKILL_CD = 7, // 技能冷却缩减
CARD_EFFECT = 8, // 卡牌效果
CARD_COUNT = 8, // 卡牌起效次数,每3次多起效一次
}
export const getBuffNum=()=>{
return {
ATK:0, // 攻击力
ATK_COUNT:0, // 攻击个数
ATK_CD:0, // 攻击速度
HP:0, // 生命值
DEF:0, // 免伤
SKILL_DMG:0, // 技能效果
SKILL_CD:0, // 技能冷却缩减
CARD_EFFECT:0, // 卡牌效果
CARD_COUNT:0, // 卡牌起效次数,每3次多起效一次
}
}
/*
path: 图片地址

View File

@@ -48,17 +48,17 @@ export const MonSet = {
2:{pos:v3(320,-10,0)},
}
export const HeroInfo = {
5001:{uuid:5001,name:"神圣守护",path:"k2", lv:3,kind:1,type:0,hp:5,ap:10,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1,speed:50,skills:[6001],tals:"说明"},
5002:{uuid:5002,name:"幻影剑豪",path:"k1", lv:3,kind:2,type:0,hp:5,ap:10,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1,speed:50,skills:[6001],tals:"说明"},
5003:{uuid:5003,name:"战争领主",path:"k5", lv:3,kind:2,type:0,hp:5,ap:10,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1,speed:50,skills:[6001],tals:"说明"},
5004:{uuid:5004,name:"混沌法师",path:"zh1", lv:3,kind:2,type:2,hp:5,ap:10,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1.5,speed:50,skills:[6001],tals:"说明"},
5005:{uuid:5005,name:"火焰法师",path:"zh2", lv:3,kind:2,type:2,hp:5,ap:15,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1.5,speed:50,skills:[6001],tals:"说明"},
5006:{uuid:5006,name:"风暴精灵",path:"m4", lv:3,kind:2,type:2,hp:5,ap:15,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1.5,speed:50,skills:[6001],tals:"说明"},
5007:{uuid:5007,name:"生命圣者",path:"d1", lv:3,kind:2,type:2,hp:5,ap:10,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1.5,speed:50,skills:[6001],tals:"说明"},
5008:{uuid:5008,name:"战争祭祀",path:"d2", lv:3,kind:2,type:2,hp:5,ap:10,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1.5,speed:50,skills:[6001],tals:"说明"},
5009:{uuid:5009,name:"暴风射手",path:"a5", lv:3,kind:2,type:1,hp:5,ap:15,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1.2,speed:50,skills:[6006],tals:"说明"},
5010:{uuid:5010,name:"苍穹射手",path:"a3", lv:3,kind:1,type:1,hp:5,ap:15,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1.2,speed:50,skills:[6006],tals:"说明"},
5011:{uuid:5011,name:"幽灵射手",path:"a4", lv:3,kind:2,type:1,hp:5,ap:15,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1.2,speed:50,skills:[6006],tals:"说明"},
5001:{uuid:5001,name:"神圣守护",path:"k2", lv:3,kind:1,type:0,hp:50,ap:10,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1,speed:50,skills:[6001],tals:"说明"},
5002:{uuid:5002,name:"幻影剑豪",path:"k1", lv:3,kind:2,type:0,hp:50,ap:10,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1,speed:50,skills:[6001],tals:"说明"},
5003:{uuid:5003,name:"战争领主",path:"k5", lv:3,kind:2,type:0,hp:50,ap:10,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1,speed:50,skills:[6001],tals:"说明"},
5004:{uuid:5004,name:"混沌法师",path:"zh1", lv:3,kind:2,type:2,hp:50,ap:10,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1.5,speed:50,skills:[6001],tals:"说明"},
5005:{uuid:5005,name:"火焰法师",path:"zh2", lv:3,kind:2,type:2,hp:50,ap:15,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1.5,speed:50,skills:[6001],tals:"说明"},
5006:{uuid:5006,name:"风暴精灵",path:"m4", lv:3,kind:2,type:2,hp:50,ap:15,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1.5,speed:50,skills:[6001],tals:"说明"},
5007:{uuid:5007,name:"生命圣者",path:"d1", lv:3,kind:2,type:2,hp:50,ap:10,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1.5,speed:50,skills:[6001],tals:"说明"},
5008:{uuid:5008,name:"战争祭祀",path:"d2", lv:3,kind:2,type:2,hp:50,ap:10,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1.5,speed:50,skills:[6001],tals:"说明"},
5009:{uuid:5009,name:"暴风射手",path:"a5", lv:3,kind:2,type:1,hp:50,ap:15,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1.2,speed:50,skills:[6006],tals:"说明"},
5010:{uuid:5010,name:"苍穹射手",path:"a3", lv:3,kind:1,type:1,hp:50,ap:15,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1.2,speed:50,skills:[6006],tals:"说明"},
5011:{uuid:5011,name:"幽灵射手",path:"a4", lv:3,kind:2,type:1,hp:50,ap:15,ap_u:0,ap_ur:0,hp_up:0,dis:700,a_cd:1.2,speed:50,skills:[6006],tals:"说明"},
5201:{uuid:5201,name:"兽人战士",path:"mor1", lv:1,kind:1,type:0,hp:200,ap:1,ap_u:0,ap_ur:0,hp_up:0,dis:400,a_cd:1,speed:50,skills:[6001],tals:"说明"},
5202:{uuid:5202,name:"兽人刺客",path:"mor2", lv:1,kind:1,type:0,hp:200,ap:1,ap_u:0,ap_ur:0,hp_up:0,dis:400,a_cd:1,speed:50,skills:[6001],tals:"说明"},
5203:{uuid:5203,name:"兽人护卫",path:"mor3", lv:1,kind:1,type:1,hp:200,ap:1,ap_u:0,ap_ur:0,hp_up:0,dis:400,a_cd:1.2,speed:50,skills:[6001],tals:"说明"},

View File

@@ -28,7 +28,9 @@ export class BattleMoveSystem extends ecs.ComblockSystem implements ecs.ISystemU
this.updateRenderOrder(e);
// 同步状态
if (!shouldStop&&view.fac==1) {
// if (!shouldStop&&view.fac==1) { //在攻击范围内停止移动 取消这个判断
if(view.fac==1){
if(view.is_stop||view.is_dead) return //停止移动或者死亡不移动
// 计算移动量
const delta = (view.speed/3) * this.dt * move.direction;

View File

@@ -4,7 +4,7 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
import { smc } from "../common/SingletonModuleComp";
import { HeroModelComp } from "./HeroModelComp";
import { HeroViewComp } from "./HeroViewComp";
import { BoxSet } from "../common/config/BoxSet";
import { BoxSet, FacSet } from "../common/config/BoxSet";
import { HeroInfo } from "../common/config/heroSet";
import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp";
import { SkillConComp } from "./SkillConComp";
@@ -41,7 +41,7 @@ export class Hero extends ecs.Entity {
var hv = node.getComponent(HeroViewComp)!;
let hero= HeroInfo[uuid] // 共用英雄数据
hv.scale = 1;
hv.fac = 0;
hv.fac = FacSet.HERO;
hv.is_master=true;
hv.type = hero.type;
hv.box_group = box_group;
@@ -75,7 +75,7 @@ export class Hero extends ecs.Entity {
var hv = node.getComponent(HeroViewComp)!;
let hero= HeroInfo[uuid] // 共用英雄数据
hv.scale = scale;
hv.fac = 0;
hv.fac = FacSet.HERO;
hv.fight_pos=fight_pos
hv.type = hero.type;
hv.box_group = box_group;

View File

@@ -3,7 +3,7 @@ import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/O
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { smc } from "../common/SingletonModuleComp";
import { HeroViewComp } from "./HeroViewComp";
import { BoxSet } from "../common/config/BoxSet";
import { BoxSet, FacSet } from "../common/config/BoxSet";
import { HeroInfo } from "../common/config/heroSet";
import { MonModelComp } from "./MonModelComp";
import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp";
@@ -56,7 +56,7 @@ export class Monster extends ecs.Entity {
// console.log("hero_init",buff)
let hero= HeroInfo[uuid] // 共用英雄数据
hv.scale = scale;
hv.fac = 1;
hv.fac = FacSet.MON;
hv.type = hero.type;
hv.is_boss = is_boss;
hv.box_group = box_group;

View File

@@ -5,7 +5,7 @@ import { Skill } from '../skills/Skill';
import { ecs } from 'db://oops-framework/libs/ecs/ECS';
import { oops } from 'db://oops-framework/core/Oops';
import { GameEvent } from '../common/config/GameEvent';
import { BoxSet } from '../common/config/BoxSet';
import { BoxSet, FacSet } from '../common/config/BoxSet';
import { smc } from '../common/SingletonModuleComp';
import { CCComp } from 'db://oops-framework/module/common/CCComp';
import { FightConComp } from '../map/FightConComp';
@@ -36,16 +36,27 @@ export class SkillConComp extends CCComp {
update(dt: number) {
if(!smc.mission.play||smc.mission.pause) return
this.HeroView.at += dt;
if (this.HeroView.is_atking &&this.HeroView.at > this.HeroView.cd) {
let cd = this.HeroView.cd
let count=1
if(this.HeroView.fac==FacSet.HERO){
if(this.HeroView.is_master){
count+=this.FIGHTCON.hero.ATK_COUNT+this.FIGHTCON.ally.ATK_COUNT-this.FIGHTCON.hero_debuff.DECOUNT-this.FIGHTCON.ally_debuff.DECOUNT
cd=this.HeroView.cd*(100-this.FIGHTCON.hero.ATK_CD-this.FIGHTCON.ally.ATK_CD+this.FIGHTCON.hero_debuff.DECD+this.FIGHTCON.ally_debuff.DECD)/100
}else{
count+=this.FIGHTCON.friend.ATK_COUNT+this.FIGHTCON.ally.ATK_COUNT-this.FIGHTCON.friend_debuff.DECOUNT-this.FIGHTCON.ally_debuff.DECOUNT
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
}
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)
if (this.HeroView.is_atking &&(this.HeroView.at > cd)) {
const config = SkillSet[this.HeroView.atk_skill];
if (!config) return;
let count=1
if(this.HeroView.is_master){
count+=this.FIGHTCON.hero.ATK_COUNT+this.FIGHTCON.ally.ATK_COUNT
}else{
count+=this.FIGHTCON.friend.ATK_COUNT+this.FIGHTCON.ally.ATK_COUNT
}
console.log(this.HeroView.hero_name+(this.HeroView.is_master?"[主]":"[从]")+"=>"+config.name+"=>"+count)
console.log(this.HeroView.hero_name+(this.HeroView.is_master?"[主]":"[从] 释放")+"=>"+config.name+"=>"+count)
this.castSkill(config,count);
this.HeroView.at = 0;
}
@@ -121,7 +132,7 @@ export class SkillConComp extends CCComp {
private selectEnemyTargets(config: typeof SkillSet[keyof typeof SkillSet]): ecs.Entity[] {
const team = this.HeroView.fac;
const isEnemyTeam = team === 0 ? 1 : 0;
const isEnemyTeam = team === FacSet.HERO ? FacSet.MON : FacSet.HERO;
const candidates= ecs.query(ecs.allOf(HeroViewComp)).filter(e => e.get(HeroViewComp).fac !== team);
return this.filterFrontRow(candidates, isEnemyTeam);
}

View File

@@ -2,7 +2,8 @@ import { _decorator, Component, Node, resources, Sprite, SpriteAtlas } from 'cc'
import { oops } from 'db://oops-framework/core/Oops';
import { GameEvent } from '../common/config/GameEvent';
import { smc } from '../common/SingletonModuleComp';
import { EquipInfo, EquipType, EquipAttr, EquipAttrTarget } from '../common/config/Equips';
import { EquipInfo, EquipType, EquipAttrTarget} from '../common/config/Equips';
import { BuffAttr, getBuffNum } from '../common/config/SkillSet';
const { ccclass, property } = _decorator;
@ccclass('EquipsComp')
@@ -15,50 +16,10 @@ export class EquipsComp extends Component {
skill3:any=null
boxs:Node=null
attrs:any={
hero:{
ATK:0, // 攻击力
ATK_COUNT:0, // 攻击个数
ATK_CD:0, // 攻击速度
HP:0, // 生命值
DEF:0, // 免伤
SKILL_DMG:0, // 技能效果
SKILL_CD:0, // 技能冷却缩减
CARD_EFFECT:0, // 卡牌效果
CARD_COUNT:0, // 卡牌起效次数,每3次多起效一次
},
ally:{
ATK:0, // 攻击力
ATK_COUNT:0, // 攻击个数
ATK_CD:0, // 攻击速度
HP:0, // 生命值
DEF:0, // 免伤
SKILL_DMG:0, // 技能效果
SKILL_CD:0, // 技能冷却缩减
CARD_EFFECT:0, // 卡牌效果
CARD_COUNT:0, // 卡牌起效次数,每3次多起效一次
},
enemy:{
ATK:0, // 攻击力
ATK_COUNT:0, // 攻击个数
ATK_CD:0, // 攻击速度
HP:0, // 生命值
DEF:0, // 免伤
SKILL_DMG:0, // 技能效果
SKILL_CD:0, // 技能冷却缩减
CARD_EFFECT:0, // 卡牌效果
CARD_COUNT:0, // 卡牌起效次数,每3次多起效一次
},
friend:{
ATK:0, // 攻击力
ATK_COUNT:0, // 攻击个数
ATK_CD:0, // 攻击速度
HP:0, // 生命值
DEF:0, // 免伤
SKILL_DMG:0, // 技能效果
SKILL_CD:0, // 技能冷却缩减
CARD_EFFECT:0, // 卡牌效果
CARD_COUNT:0, // 卡牌起效次数,每3次多起效一次
}
hero:getBuffNum(),
ally:getBuffNum(),
enemy:getBuffNum(),
friend:getBuffNum(),
}
/** 视图层逻辑代码分离演示 */
onLoad() {
@@ -166,31 +127,31 @@ export class EquipsComp extends Component {
if (targetKey) {
switch (attr.type) {
case EquipAttr.ATK:
case BuffAttr.ATK:
this.attrs[targetKey].ATK += attr.value;
break;
case EquipAttr.ATK_COUNT:
case BuffAttr.ATK_COUNT:
this.attrs[targetKey].ATK_COUNT += attr.value;
break;
case EquipAttr.ATK_CD:
case BuffAttr.ATK_CD:
this.attrs[targetKey].ATK_CD += attr.value;
break;
case EquipAttr.HP:
case BuffAttr.HP:
this.attrs[targetKey].HP += attr.value;
break;
case EquipAttr.DEF:
case BuffAttr.DEF:
this.attrs[targetKey].DEF += attr.value;
break;
case EquipAttr.SKILL_DMG:
case BuffAttr.SKILL_DMG:
this.attrs[targetKey].SKILL_DMG += attr.value;
break;
case EquipAttr.SKILL_CD:
case BuffAttr.SKILL_CD:
this.attrs[targetKey].SKILL_CD += attr.value;
break;
case EquipAttr.CARD_EFFECT:
case BuffAttr.CARD_EFFECT:
this.attrs[targetKey].CARD_EFFECT += attr.value;
break;
case EquipAttr.CARD_COUNT:
case BuffAttr.CARD_COUNT:
this.attrs[targetKey].CARD_COUNT += attr.value;
break;
}
@@ -202,11 +163,7 @@ export class EquipsComp extends Component {
// 重置所有属性为0
private reset_attrs() {
Object.keys(this.attrs).forEach(key => {
Object.keys(this.attrs[key]).forEach(attrKey => {
this.attrs[key][attrKey] = 0;
});
});
this.attrs.hero=this.attrs.ally=this.attrs.enemy=this.attrs.friend=getBuffNum()
}
// 根据目标类型获取对应的key

View File

@@ -1,54 +1,29 @@
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:{
ATK:0, // 攻击力
ATK_COUNT:0, // 攻击个数
ATK_CD:0, // 攻击速度
HP:0, // 生命值
DEF:0, // 免伤
SKILL_DMG:0, // 技能效果
SKILL_CD:0, // 技能冷却缩减
CARD_EFFECT:0, // 卡牌效果
CARD_COUNT:0, // 卡牌起效次数,每3次多起效一次
}
ally:{
ATK:0, // 攻击力
ATK_COUNT:0, // 攻击个数
ATK_CD:0, // 攻击速度
HP:0, // 生命值
DEF:0, // 免伤
SKILL_DMG:0, // 技能效果
SKILL_CD:0, // 技能冷却缩减
CARD_EFFECT:0, // 卡牌效果
CARD_COUNT:0, // 卡牌起效次数,每3次多起效一次
}
enemy:{
ATK:0, // 攻击力
ATK_COUNT:0, // 攻击个数
ATK_CD:0, // 攻击速度
HP:0, // 生命值
DEF:0, // 免伤
SKILL_DMG:0, // 技能效果
SKILL_CD:0, // 技能冷却缩减
CARD_EFFECT:0, // 卡牌效果
CARD_COUNT:0, // 卡牌起效次数,每3次多起效一次
}
friend:{
ATK:0, // 攻击力
ATK_COUNT:0, // 攻击个数
ATK_CD:0, // 攻击速度
HP:0, // 生命值
DEF:0, // 免伤
SKILL_DMG:0, // 技能效果
SKILL_CD:0, // 技能冷却缩减
CARD_EFFECT:0, // 卡牌效果
CARD_COUNT:0, // 卡牌起效次数,每3次多起效一次
}
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.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();
onLoad(){
// console.log("fight con start")
@@ -56,24 +31,71 @@ export class FightConComp extends Component {
oops.message.on(GameEvent.FightReady,this.fight_ready,this)
}
equip_change(e:GameEvent,equip:any){
private equip_change(e:GameEvent,equip:any){
this.hero=equip.hero
this.ally=equip.ally
this.enemy=equip.enemy
this.friend=equip.friend
}
fight_ready(e:GameEvent){
this.hero=this.ally=this.enemy=this.friend={
ATK:0, // 攻击力
ATK_COUNT:0, // 攻击个数
ATK_CD:0, // 攻击速度
HP:0, // 生命值
DEF:0, // 免伤
SKILL_DMG:0, // 技能效果
SKILL_CD:0, // 技能冷却缩减
CARD_EFFECT:0, // 卡牌效果
CARD_COUNT:0, // 卡牌起效次数,每3次多起效一次
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)
}
// 添加临时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 getInitTempBuffDebuff() {
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 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();
}
update(deltaTime: number) {
@@ -82,3 +104,5 @@ export class FightConComp extends Component {
}

View File

@@ -65,6 +65,7 @@ export class SkillCom extends CCComp {
// bm.speed=700
if(this.group==BoxSet.MONSTER) bm.controlPointSide=-1
bm.moveTo(this.targetPos)
}
// let dir_x = this.targetPos.x > this.node.position.x ? 1 : -1
@@ -240,16 +241,25 @@ export class SkillCom extends CCComp {
update(deltaTime: number) {
if(smc.mission.pause) return;
this.toDestroy();
if(this.animType==AnimType.linear) this.startLinearMove(deltaTime);
if (!this.node || !this.node.isValid) return;
if(this.animType == AnimType.linear) this.startLinearMove(deltaTime);
this.toDestroy();
}
toDestroy() {
if(this.is_destroy){
this.ent.destroy()
if (this.ent) {
this.ent.destroy();
} else {
// 如果ent不存在直接销毁节点
if (this.node && this.node.isValid) {
this.node.destroy();
}
}
}
}
doDestroy(){
console.log("doDestroy")
this.is_destroy=true
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */