去掉hartmodel

This commit is contained in:
2025-06-06 16:26:13 +08:00
parent f9b3f56a04
commit fee9fc9852
7 changed files with 73 additions and 136 deletions

View File

@@ -1,39 +0,0 @@
import { oops } from "db://oops-framework/core/Oops";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { HeroViewComp } from "./HeroViewComp";
import { GameEvent } from "../common/config/GameEvent";
import { CCComp } from "db://oops-framework/module/common/CCComp";
import { MissionEvent } from "../common/config/MissionEvent";
import { SkillConComp } from "./SkillConComp";
import { SkillSet } from "../common/config/SkillSet";
import { _decorator } from "cc";
const { ccclass, property } = _decorator;
/**
* 角色属性数据
*/
@ccclass('HartMode')
@ecs.register('HartModelComp')
export class HartModelComp extends CCComp {
SkillCon:SkillConComp
onLoad(){
console.log("HartModel加载",this)
this.on(GameEvent.FightReady,this.start,this)
this.on(GameEvent.CastHeroSkill,this.cast_skill,this)
}
start(){
this.SkillCon=this.node.getComponent(SkillConComp)
console.log("hart start",this.SkillCon)
}
cast_skill(e:string,uuid:any){
console.log("hart cast_skill",uuid ,e)
const config = SkillSet[uuid];
this.SkillCon.castSkill(config)
}
reset() {
}
}

View File

@@ -1 +0,0 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"a32cd4cd-7797-4ef0-bf2d-bd3168fbd0cc","files":[],"subMetas":{},"userData":{}}

View File

@@ -7,7 +7,6 @@ import { HeroViewComp } from "./HeroViewComp";
import { BoxSet } from "../common/config/BoxSet";
import { HeroInfo } from "../common/config/heroSet";
import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp";
import { HartModelComp } from "./HartModelComp";
import { SkillConComp } from "./SkillConComp";
/** 角色实体 */
@ecs.register(`Hero`)
@@ -29,10 +28,10 @@ export class Hero extends ecs.Entity {
this.remove(HeroModelComp);
super.destroy();
}
hart_load() {
hart_load(uuid:number=5001) {
console.log("主体加载")
let box_group=BoxSet.HERO
var path = "game/heros/hart";
var path = "game/heros/"+HeroInfo[uuid].path;
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
var scene = smc.map.MapView.scene;
@@ -40,24 +39,25 @@ export class Hero extends ecs.Entity {
let pos=v3(-277,0,0)
node.setPosition(pos)
var hv = node.getComponent(HeroViewComp)!;
let hero= HeroInfo[uuid] // 共用英雄数据
hv.scale = 1;
hv.fac = 0;
hv.type = 0;
hv.is_master=true;
hv.type = hero.type;
hv.box_group = box_group;
hv.hero_uuid= 9999;
hv.hero_name= "主体";
hv.speed =hv.ospeed = 0;
hv.dis = 0;
hv.hp= hv.hp_max =5;
hv.ap = 0;
hv.lv=0
hv.cd = 9999
hv.ap_u=0
hv.ap_ur=0
hv.hp_up=0
hv.atk_skill=0
hv.hero_uuid= uuid;
hv.hero_name= hero.name;
hv.speed =hv.ospeed = hero.speed;
hv.dis = hero.dis;
hv.hp= hv.hp_max =hero.hp;
hv.ap = hero.ap;
hv.lv=1
hv.cd = hero.a_cd
hv.ap_u=hero.ap_u
hv.ap_ur=hero.ap_ur
hv.hp_up=hero.hp_up
hv.atk_skill=hero.skills[0]
this.add(hv);
this.add(HartModelComp)
}
/** 加载角色 */
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,info:any={ap:0,hp:0},fight_pos:number=0) {

View File

@@ -17,13 +17,8 @@ const { ccclass, property } = _decorator;
@ecs.register('HeroView', false) // 定义为 ECS 组件
export class HeroViewComp extends CCComp {
BUFFCOMP:BuffComp=null!
enemy_pos:Vec3=null!
// enemy:any=null!;
as: HeroSpine = null!
anm_timer:Timer = new Timer(0.3);
anm_name="idle"
status:String = "idle"
hero_uuid:number = 1001;
hero_name : string = "hero";
fight_pos:number=0;
@@ -36,12 +31,13 @@ export class HeroViewComp extends CCComp {
box_group:number = BoxSet.HERO;
is_dead:boolean = false; //是否摧毁
is_stop:boolean = false;
is_atking:boolean = false;
is_boss:boolean = false;
is_big_boss:boolean = false;
is_master:boolean =false;
ap_u:number=0;
ap_ur:number=0;
hp_up:number=0;
@@ -258,8 +254,8 @@ export class HeroViewComp extends CCComp {
do_dead(){
console.log("角色死亡",this.hero_uuid)
if(this.hero_uuid == 9999){
console.log("任务失败")
if(this.is_master){
console.log("英雄死亡")
oops.message.dispatchEvent(GameEvent.FightEnd,this)
}
}

View File

@@ -23,11 +23,11 @@ export class SkillConComp extends CCComp {
}
onLoad(){
this.HeroView=this.node.getComponent(HeroViewComp)
console.log(this.HeroView.uuid+"=>"+this.HeroView.hero_name+"=> SkillConComp onLoad")
// console.log(this.HeroView.uuid+"=>"+this.HeroView.hero_name+"=> SkillConComp onLoad")
this.on(GameEvent.CastHeroSkill,this.cast_master_skill,this)
}
start() {
this.HeroView=this.node.getComponent(HeroViewComp)
console.log(this.HeroView.uuid+"=>"+this.HeroView.hero_name+"=> SkillConComp start")
// console.log(this.HeroView.uuid+"=>"+this.HeroView.hero_name+"=> SkillConComp start")
this.HeroEntity=this.HeroView.ent
}
@@ -41,6 +41,14 @@ export class SkillConComp extends CCComp {
}
}
cast_master_skill(e:string,uuid:any){
if(!this.HeroView) return
if(!this.HeroView.is_master) return
console.log("hart cast_skill",uuid ,e)
const config = SkillSet[uuid];
this.castSkill(config)
}
/** 施放技能 */
castSkill(config: typeof SkillSet[keyof typeof SkillSet]) {
// console.log(view.uuid+"=>"+view.hero_name+"施放技能:"+config.uuid);

View File

@@ -1,19 +1,13 @@
import { _decorator, resources, Sprite, SpriteAtlas, SpriteFrame, v3, Vec3 } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { BoxSet, } from "../common/config/BoxSet";
import { HeroInfo, HeroList, HeroPos, HeroSet, HeroUpInfo } from "../common/config/heroSet";
import { Hero } from "../hero/Hero";
import { smc } from "../common/SingletonModuleComp";
import { Timer } from "db://oops-framework/core/common/timer/Timer";
import { RandomManager } from "db://oops-framework/core/common/random/RandomManager";
import { GameEvent } from "../common/config/GameEvent";
import { HeroModelComp } from "../hero/HeroModelComp";
import { HeroViewComp } from "../hero/HeroViewComp";
import { oops } from "db://oops-framework/core/Oops";
import { FightSet } from "../common/config/Mission";
import { HartModelComp } from "../hero/HartModelComp";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@@ -46,45 +40,45 @@ export class MissionHeroCompComp extends CCComp {
test_call(){
this.addHero(5010)
}
show_heros_pos(event: string, args: any){
console.log("show_heros_pos",args)
this.current_hero_uuid=args.uuid
this.update_fight_hero_info()
this.node.getChildByName("location").active=true
}
update_fight_hero_info(){
var icon_path = "game/heros/herois"
this.node.getChildByName("location").getChildByName("herospos").getChildByName("heropos1").getChildByName("hero").active=false
this.node.getChildByName("location").getChildByName("herospos").getChildByName("heropos2").getChildByName("hero").active=false
this.node.getChildByName("location").getChildByName("herospos").getChildByName("heropos3").getChildByName("hero").active=false
// show_heros_pos(event: string, args: any){
// console.log("show_heros_pos",args)
// this.current_hero_uuid=args.uuid
// this.update_fight_hero_info()
// this.node.getChildByName("location").active=true
// }
// update_fight_hero_info(){
// var icon_path = "game/heros/herois"
// this.node.getChildByName("location").getChildByName("herospos").getChildByName("heropos1").getChildByName("hero").active=false
// this.node.getChildByName("location").getChildByName("herospos").getChildByName("heropos2").getChildByName("hero").active=false
// this.node.getChildByName("location").getChildByName("herospos").getChildByName("heropos3").getChildByName("hero").active=false
let heros=ecs.query(ecs.allOf(HeroModelComp).excludeOf(HartModelComp))
for(let hero of heros){
let hv = hero.get(HeroViewComp)
if(hv.fight_pos==0){
this.node.getChildByName("location").getChildByName("herospos").getChildByName("heropos1").getChildByName("hero").active=true
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
const sprite = this.node.getChildByName("location").getChildByName("herospos").getChildByName("heropos1").getChildByName("hero").getChildByName("icon").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[hv.hero_uuid].path);
});
}
if(hv.fight_pos==1){
this.node.getChildByName("location").getChildByName("herospos").getChildByName("heropos2").getChildByName("hero").active=true
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
const sprite = this.node.getChildByName("location").getChildByName("herospos").getChildByName("heropos2").getChildByName("hero").getChildByName("icon").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[hv.hero_uuid].path);
});
}
if(hv.fight_pos==2){
this.node.getChildByName("location").getChildByName("herospos").getChildByName("heropos3").getChildByName("hero").active=true
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
const sprite = this.node.getChildByName("location").getChildByName("herospos").getChildByName("heropos3").getChildByName("hero").getChildByName("icon").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[hv.hero_uuid].path);
});
}
// let heros=ecs.query(ecs.allOf(HeroModelComp))
// for(let hero of heros){
// let hv = hero.get(HeroViewComp)
// if(hv.fight_pos==0){
// this.node.getChildByName("location").getChildByName("herospos").getChildByName("heropos1").getChildByName("hero").active=true
// resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
// const sprite = this.node.getChildByName("location").getChildByName("herospos").getChildByName("heropos1").getChildByName("hero").getChildByName("icon").getComponent(Sprite);
// sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[hv.hero_uuid].path);
// });
// }
// if(hv.fight_pos==1){
// this.node.getChildByName("location").getChildByName("herospos").getChildByName("heropos2").getChildByName("hero").active=true
// resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
// const sprite = this.node.getChildByName("location").getChildByName("herospos").getChildByName("heropos2").getChildByName("hero").getChildByName("icon").getComponent(Sprite);
// sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[hv.hero_uuid].path);
// });
// }
// if(hv.fight_pos==2){
// this.node.getChildByName("location").getChildByName("herospos").getChildByName("heropos3").getChildByName("hero").active=true
// resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
// const sprite = this.node.getChildByName("location").getChildByName("herospos").getChildByName("heropos3").getChildByName("hero").getChildByName("icon").getComponent(Sprite);
// sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[hv.hero_uuid].path);
// });
// }
}
}
// }
// }
call_hero(event: string, args: any){
// this.node.getChildByName("location").active=false
// console.log("call_hero",args)
@@ -113,10 +107,10 @@ export class MissionHeroCompComp extends CCComp {
get_info_and_remove(fight_pos:number,uuid:number){
let info:any={ap:0,hp:0,lv:0}
let heros=ecs.query(ecs.allOf(HeroModelComp).excludeOf(HartModelComp))
let heros=ecs.query(ecs.allOf(HeroModelComp))
for(let hero of heros){
if(hero.get(HeroViewComp).fight_pos==fight_pos){
let hv = hero.get(HeroViewComp)
let hv = hero.get(HeroViewComp)
if(hv.fight_pos==fight_pos&&!hv.is_master){
// let AP_UP_RATE = hv.hero_uuid === uuid ? FightSet.AP_UPDATE_RATE : FightSet.AP_CHANGE_RATE;
// let heroUpData = HeroUpInfo[hv.hero_uuid] || {}
// let o_ap_rate = heroUpData.ap_up_rate || 0 //被替换 升级的英雄额外被替换攻击增长比率