装备特殊加成 继续完善

This commit is contained in:
panw
2025-06-17 16:19:02 +08:00
parent 0a1e2b7813
commit d7b6dd375a
11 changed files with 171 additions and 113 deletions

View File

@@ -1,23 +1,26 @@
import { oops } from "db://oops-framework/core/Oops";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { VM } from "../../../../extensions/oops-plugin-framework/assets/libs/model-view/ViewModel";
import { GameEvent } from "../common/config/GameEvent";
/** 数据层对象 */
@ecs.register('FriendModel')
export class FriendModelComp extends ecs.Comp {
/** 提供 MVVM 组件使用的数据 */
private vm: any = {};
onLoad(){
oops.message.on(GameEvent.ChangeATK_EQUIP_SPECIAL_ATTR,this.change_equip_special_attr,this)
/** 显示数据添加到 MVVM 框架中监视 */
vmAdd() {
VM.add(this.vm, "FriendModel");
}
change_equip_special_attr(e:GameEvent,data:any){
console.log("[FriendModel]:change_equip_special_attr",data)
/** 显示数据从 MVVM 框架中移除 */
vmRemove() {
VM.remove("FriendModel");
}
/** 数据层组件移除时,重置所有数据为默认值 */
reset() {
for (var key in this.vm) {
delete this.vm[key];
}
}
}

View File

@@ -2,7 +2,7 @@
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "8f0b0fe4-fa69-4f5b-95d1-833eaafa2103",
"uuid": "bffcbaf3-0abd-46c9-b297-da0667e9b7f3",
"files": [],
"subMetas": {},
"userData": {}

View File

@@ -8,6 +8,8 @@ import { BoxSet, FacSet } from "../common/config/BoxSet";
import { HeroInfo, HeroPos } from "../common/config/heroSet";
import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp";
import { SkillConComp } from "./SkillConComp";
import { FriendModelComp } from "./FriendModel";
import { MasterModelComp } from "./MasterModel";
/** 角色实体 */
@ecs.register(`Hero`)
@@ -26,6 +28,12 @@ export class Hero extends ecs.Entity {
destroy(): void {
this.remove(HeroViewComp);
this.remove(HeroModelComp);
if(this.get(FriendModelComp)){
this.remove(FriendModelComp);
}
if(this.get(MasterModelComp)){
this.remove(MasterModelComp);
}
super.destroy();
}
hart_load(uuid:number=5004) {
@@ -57,6 +65,7 @@ export class Hero extends ecs.Entity {
hv.atk_skill=hero.skills[0]
console.log(hv.hero_name+"dis=>"+hv.dis)
this.add(hv);
this.addComponents<ecs.Comp>(MasterModelComp)
}
/** 加载角色 */
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,info:any={ap:0,hp:0},fight_pos:number=1) {
@@ -88,6 +97,7 @@ export class Hero extends ecs.Entity {
hv.hp_up=hero.hp_up
hv.atk_skill=hero.skills[0]
this.add(hv);
this.addComponents<ecs.Comp>(FriendModelComp);
const move = this.get(BattleMoveComp);
move.direction = 1; // 向右移动
move.targetX = 800; // 右边界'

View File

@@ -13,6 +13,8 @@ import { FightConComp } from "../map/FightConComp";
import { EquipSpecialAttr } from "../common/config/Equips";
import { FightSet } from "../common/config/Mission";
import { HeroPos } from "../common/config/heroSet";
import { FriendModelComp } from "./FriendModel";
import { MasterModelComp } from "./MasterModel";
const { ccclass, property } = _decorator;
@@ -69,7 +71,7 @@ export class HeroViewComp extends CCComp {
atk_count: number = 0;
atked_count: number = 0;
atk_add_count:number=0;
stop_cd: number = 0; /*停止倒计时*/
yun_cd: number = 0; //眩晕倒计时
ice_cd: number = 0; //冰冻倒计时
@@ -91,7 +93,8 @@ export class HeroViewComp extends CCComp {
this.as = this.getComponent(HeroSpine);
this.FIGHTCON=this.node.parent.getComponent(FightConComp);
console.log("[HeroViewComp]:hero view comp ",this.FIGHTCON)
this.on(GameEvent.ChangeATK,this.change_atk,this)
this.on(GameEvent.ChangeATK_EQUIP_SPECIAL_ATTR,this.change_atk,this)
// let anm = this.node.getChildByName("anm")
// anm.setScale(anm.scale.x*0.8,anm.scale.y*0.8);
}
@@ -138,24 +141,18 @@ export class HeroViewComp extends CCComp {
this.processDamageQueue();
}
change_atk(e:GameEvent,data:any){
switch(data){
case EquipSpecialAttr.ICE:
this.atk_skill=6001
break
case EquipSpecialAttr.FIRE:
this.atk_skill=6002
break
case EquipSpecialAttr.WIND:
this.atk_skill=6003
break
default:
this.atk_skill=6001
break
if(data.ice){
this.atk_skill=6001
}else if(data.fire){
this.atk_skill=6002
}else if(data.wind){
this.atk_skill=6003
}else{
this.atk_skill=6001
}
}
get isActive() {
return this.ent.has(HeroViewComp) && this.node?.isValid;
}
@@ -251,7 +248,48 @@ export class HeroViewComp extends CCComp {
}
}
}
master_count_atk_count(){ //主将攻击次数 主要有装备加成,需要单独处理
if(!this.is_master) return
this.atk_count+=1
if(this.atk_count< FightSet.ATK_ADD_FRIEND_COUNT) return
if(this.FIGHTCON.atk_add_glod >0) smc.mission.add_gold(this.FIGHTCON.atk_add_glod)
this.do_friend_atk_add()
this.do_master_atk_add()
this.atk_count=0
}
friend_count_atk_count(){ //伙伴攻击次数 有装备加成,需要单独处理
if(this.is_master) return
if(this.atk_add_count==0) return
this.atk_count+=1
if(this.atk_count < this.atk_add_count) return
}
do_friend_atk_add(){
let friends=ecs.query(ecs.allOf(FriendModelComp))
friends.forEach(friend=>{
let friend_view=friend.get(HeroViewComp)
if(this.FIGHTCON.atk_add_friend_atk>0) {
friend_view.add_ap(this.FIGHTCON.atk_add_friend_atk)
}
if(this.FIGHTCON.atk_add_friend_hp>0) {
friend_view.add_hp_max(this.FIGHTCON.atk_add_friend_hp)
}
})
}
do_master_atk_add(){
let master=ecs.query(ecs.allOf(MasterModelComp))
master.forEach(master=>{
let master_view=master.get(HeroViewComp)
if(this.FIGHTCON.atk_add_master_atk>0) {
master_view.add_ap(this.FIGHTCON.atk_add_master_atk)
}
if(this.FIGHTCON.atk_add_master_hp>0) {
master_view.add_hp_max(this.FIGHTCON.atk_add_master_hp)
}
})
}
do_change(){
this.BUFFCOMP.update_info_ap()
this.BUFFCOMP.update_info_hp()
@@ -266,7 +304,7 @@ export class HeroViewComp extends CCComp {
do_dead(){
this.Friend_alive_cd=new Timer(this.FIGHTCON.Friend_alive_cd)
this.Friend_alive_cd=new Timer(this.FIGHTCON.friend_alive_cd)
console.log("[HeroViewComp]:角色死亡",this.hero_uuid)
if(this.is_master){
console.log("[HeroViewComp]:英雄死亡")

View File

@@ -1,25 +1,26 @@
import { _decorator, Component, Node } from 'cc';
import { GameEvent } from '../common/config/GameEvent';
import { oops } from 'db://oops-framework/core/Oops';
import { ecs } from 'db://oops-framework/libs/ecs/ECS';
const { ccclass, property } = _decorator;
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { VM } from "../../../../extensions/oops-plugin-framework/assets/libs/model-view/ViewModel";
/** 数据层对象 */
@ecs.register('MasterModel')
export class MasterModelComp extends ecs.Comp {
/** 提供 MVVM 组件使用的数据 */
private vm: any = {};
onLoad(){
oops.message.on(GameEvent.ChangeATK_EQUIP_SPECIAL_ATTR,this.change_equip_special_attr,this)
/** 显示数据添加到 MVVM 框架中监视 */
vmAdd() {
VM.add(this.vm, "MasterModel");
}
change_equip_special_attr(e:GameEvent,data:any){
console.log("[MasterModel]:change_equip_special_attr",data)
/** 显示数据从 MVVM 框架中移除 */
vmRemove() {
VM.remove("MasterModel");
}
update(deltaTime: number) {
}
reset(): void {
}
}
/** 数据层组件移除时,重置所有数据为默认值 */
reset() {
for (var key in this.vm) {
delete this.vm[key];
}
}
}

View File

@@ -2,7 +2,7 @@
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "70abe143-ca41-4c22-b645-63a6035aba95",
"uuid": "8b5cf0cb-bab1-4084-bfe5-21fc74914b2f",
"files": [],
"subMetas": {},
"userData": {}

View File

@@ -47,9 +47,12 @@ export class SkillConComp extends CCComp {
if (!config) return;
// console.log(this.HeroView.hero_name+(this.HeroView.is_master?"[主]":"[从] 释放")+"=>"+config.name+"=>"+count)
this.castSkill(config,count);
this.HeroView.master_count_atk_count()
this.HeroView.friend_count_atk_count()
this.HeroView.at = 0;
}
}
get_cd(cd:number,view:HeroViewComp){
if(view.fac==FacSet.HERO){
if(view.is_master){