继续完善,todo herocard 点击后显示信息

This commit is contained in:
2024-12-02 16:46:31 +08:00
parent 69ec6c93fc
commit 31b181eb87
10 changed files with 530 additions and 1879 deletions

View File

@@ -113,6 +113,8 @@ export class SingletonModuleComp extends ecs.Comp {
},
heros:{
9001:{uuid:9001,lv:1,exp:0,slv:1,stone:0},
9002:{uuid:9002,lv:2,exp:0,slv:2,stone:0},
9003:{uuid:9003,lv:3,exp:0,slv:3,stone:0},
},
talent:{
1001:{uuid:1001,lv:0,},

View File

@@ -1,23 +1,31 @@
export const HeroInfo = {
9001: {
uuid:9001,name: "骑士·白",path:"k1",type:1,hp: 10, hp_up:10,def:10,def_up:1,ap:20,ap_up:2,atp:1,vun:0,crit:20,crit_add:0,dodge:0,dis:100,a_cd:1.5,
uuid:9001,name: "圣盾骑士",path:"k1",type:1,hp: 10, hp_up:10,def:10,def_up:1,ap:20,ap_up:2,atp:1,vun:0,crit:20,crit_add:0,dodge:0,dis:100,a_cd:1.5,
lvexp:2,slvexp:2, speed: 100,aep:1,uaep:1,dep:10,sk1:[9001,9001,9001,9001,9001],sk2: [2002,2002,2002,2002,2002],pw:0,pwm:15,pws:1,
akr:[10,20,30,40,50],akc:[1,1,1,1,1],uar:[10,20,30,40,50],uac:[1,1,1,1,1],dgr:[10,20,30,40,50],dgc:[1,1,1,1,1],crr:[10,20,30,40,50],crc:[1,1,1,1,1],
abh:0,abc:0,uabh:0,uabc:0,cbh:0,cbc:0,aua:0,auc:0,uaua:0,uauc:0,cua:0,cuc:0,wp:1001,arm:2001,ring:3001,shoes:4001,
},
9002: {
uuid:9001,name: "狂暴骑士",path:"k2",type:1,hp: 10, hp_up:10,def:10,def_up:1,ap:20,ap_up:2,atp:1,vun:0,crit:20,crit_add:0,dodge:0,dis:100,a_cd:1.5,
lvexp:2,slvexp:2, speed: 100,aep:1,uaep:1,dep:10,sk1:[9001,9001,9001,9001,9001],sk2: [2002,2002,2002,2002,2002],pw:0,pwm:15,pws:1,
akr:[10,20,30,40,50],akc:[1,1,1,1,1],uar:[10,20,30,40,50],uac:[1,1,1,1,1],dgr:[10,20,30,40,50],dgc:[1,1,1,1,1],crr:[10,20,30,40,50],crc:[1,1,1,1,1],
abh:0,abc:0,uabh:0,uabc:0,cbh:0,cbc:0,aua:0,auc:0,uaua:0,uauc:0,cua:0,cuc:0,wp:1001,arm:2001,ring:3001,shoes:4001,
},
9003: {
uuid:9001,name: "防御骑士",path:"k3",type:1,hp: 10, hp_up:10,def:10,def_up:1,ap:20,ap_up:2,atp:1,vun:0,crit:20,crit_add:0,dodge:0,dis:100,a_cd:1.5,
lvexp:2,slvexp:2, speed: 100,aep:1,uaep:1,dep:10,sk1:[9001,9001,9001,9001,9001],sk2: [2002,2002,2002,2002,2002],pw:0,pwm:15,pws:1,
akr:[10,20,30,40,50],akc:[1,1,1,1,1],uar:[10,20,30,40,50],uac:[1,1,1,1,1],dgr:[10,20,30,40,50],dgc:[1,1,1,1,1],crr:[10,20,30,40,50],crc:[1,1,1,1,1],
abh:0,abc:0,uabh:0,uabc:0,cbh:0,cbc:0,aua:0,auc:0,uaua:0,uauc:0,cua:0,cuc:0,wp:1001,arm:2001,ring:3001,shoes:4001,
},
}
export const HeroList = [9001,9002,9003]
export const MonSet = {
5001: {
uuid: 5001, path: "boss1", type: 1, level: 1,cost:2, name: "骷髅王", atk: 30, hp: 150, atk_dis: 200, a_cd: 2, power: 0, power_max: 10, speed: 7,
max_skill: "精准打击", skill_uuid: 1001, max_skill_uuid: 1002, atktype: 1
},
}
export const MonSet = {
}
export const HeroSet = {
StartPos:{

View File

@@ -0,0 +1,41 @@
import { instantiate, Label, Prefab, resources, Sprite, SpriteAtlas } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { HeroCardComp } from "./HeroCardComp";
import { smc } from "../common/SingletonModuleComp";
/** HeroCard 模块 */
@ecs.register(`HeroCard`)
export class HeroCard extends ecs.Entity {
protected init() {
// this.addComponents<ecs.Comp>();
}
load(uuid:number=101,parent:any) {
// var path = "game/monster/"+prefab_path;
var path = "game/gui/hero_card";
var icon_path = "game/heros/herois"
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
node.parent = parent;
node.getChildByName("name").getComponent(Label).string = smc.heros[uuid].name
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
const sprite = node.getChildByName("Mask").getChildByName("hero").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(smc.heros[uuid].path);
});
node.getChildByName("lv").getComponent(Label).string = smc.vmdata.heros[uuid].lv.toString();
if(smc.vmdata.heros[uuid].slv>=1) node.getChildByName("slv").getChildByName("s1").active=true;
if(smc.vmdata.heros[uuid].slv>=2) node.getChildByName("slv").getChildByName("s2").active=true;
if(smc.vmdata.heros[uuid].slv>=3) node.getChildByName("slv").getChildByName("s3").active=true;
if(smc.vmdata.heros[uuid].slv>=4) node.getChildByName("slv").getChildByName("s4").active=true;
if(smc.vmdata.heros[uuid].slv>=5) node.getChildByName("slv").getChildByName("s5").active=true;
let hcc = node.getComponent(HeroCardComp)!;
hcc.hcc_uuid = uuid;
this.add(hcc);
}
/** 模块资源释放 */
destroy() {
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
super.destroy();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "d7e27567-5e31-483e-bd8e-c4efd272660c",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,37 @@
import { _decorator } 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 { HeroHomeComp } from "../map/HeroHomeComp";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('HeroCardComp')
@ecs.register('HeroCardComp', false)
export class HeroCardComp extends CCComp {
@property(HeroHomeComp)
hcc_home: HeroHomeComp = null!;
hcc_uuid: number = 0;
/** 视图层逻辑代码分离演示 */
start() {
this.hcc_home=this.node.parent.parent.parent.parent.getComponent(HeroHomeComp);
// console.log("hero_card hcc_home",this.hcc_home)
}
show_info(){
this.hcc_home.hero_show(this.hcc_uuid)
}
/** 全局消息逻辑处理 */
// private onHandler(event: string, args: any) {
// switch (event) {
// case ModuleEvent.Cmd:
// break;
// }
// }
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "e50aeebc-0c92-4f72-ab68-4979e639c193",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -1,17 +1,8 @@
import { _decorator,Button,EventHandler,EventTouch,Label,NodeEventType,resources,Sprite,SpriteAtlas,UITransform,v3 } from "cc";
import { _decorator,Button,EventHandler,EventTouch,instantiate,Label,NodeEventType,Prefab,resources,Sprite,SpriteAtlas,UITransform,v3 } 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 { smc } from "../common/SingletonModuleComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
import { SkillSet } from "../common/config/SkillSet";
import { HeroModelComp } from "../hero/HeroModelComp";
import { RewardSet } from "../common/config/RewardSet";
import { GameSet } from "../common/config/BoxSet";
import { GameMap } from "./GameMap";
import { MapModelComp } from "./model/MapModelComp";
import { Talent } from "../Role/Talent";
import { Talents } from "../common/config/TalentSet";
import { HeroList } from "../common/config/heroSet";
import { HeroCard } from "../hero/HeroCard";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@@ -23,35 +14,26 @@ export class HeroHomeComp extends CCComp {
}
start() {
// this.load_talents()
console.log("hero_home start")
this.loads()
}
load_talents(){
let y=-70
let pos = v3(0,y)
let talents:any= Talents
let parent= this.node.getChildByName("talents").getChildByName("view").getChildByName("content")
console.log("talents:",talents,)
const keys = Object.keys(talents);
if (keys.length === 0) {
console.log("No talents to process.");
} else {
for (const key of keys) {
const talentData = talents[key];
let talent = ecs.getEntity<Talent>(Talent);
console.log("talent:", talentData);
let uuid = talentData.uuid;
talent.load(pos, uuid, parent);
pos.y -= 140; // 更新位置
}
loads(){
let heros:any=HeroList
let hc:number =HeroList.length
console.log("hero_home heros:",heros,hc)
let parent= this.node.getChildByName("heros").getChildByName("view").getChildByName("content")
parent.getComponent(UITransform).width=hc*150
console.log("parent:",parent)
for (let i = 0; i < hc; i++) {
let hcc =ecs.getEntity<HeroCard>(HeroCard)
hcc.load(HeroList[i],parent)
}
let hero_talent_content=parent.getComponent(UITransform)
hero_talent_content.height=2000
console.log("hero_talent_content:",parent)
}
/** 视图对象通过 ecs.Entity.remove(ControllerComp) 删除组件是触发组件处理自定义释放逻辑 */
hero_show(uuid:number) {
console.log("hero_home hero_show:",uuid)
}
reset() {
this.node.destroy();
}