继续完善,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

@@ -27,6 +27,9 @@
{
"__id__": 22
},
{
"__id__": 28
},
{
"__id__": 34
},
@@ -41,10 +44,16 @@
},
{
"__id__": 76
},
{
"__id__": 78
},
{
"__id__": 80
}
],
"_prefab": {
"__id__": 78
"__id__": 83
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -521,22 +530,18 @@
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 23
}
],
"_children": [],
"_active": true,
"_components": [
{
"__id__": 29
"__id__": 23
},
{
"__id__": 31
"__id__": 25
}
],
"_prefab": {
"__id__": 33
"__id__": 27
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -567,31 +572,117 @@
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 22
},
"_enabled": true,
"__prefab": {
"__id__": 24
},
"_contentSize": {
"__type__": "cc.Size",
"width": 89,
"height": 89
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "7aA4ZvlQpNear6ycFqd468"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 22
},
"_enabled": true,
"__prefab": {
"__id__": 26
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "f87f53f9-2fba-4a5b-968a-79a593311ab2@008c0",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "b7uI2M3YdGj6VIy7UY4akz"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "e8i10bRRRABphjmj2v+NEC",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_name": "lv",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 22
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 24
"__id__": 29
},
{
"__id__": 26
"__id__": 31
}
],
"_prefab": {
"__id__": 28
"__id__": 33
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"x": -45.97999999999999,
"y": 61.15300000000002,
"z": 0
},
"_lrot": {
@@ -603,8 +694,8 @@
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"x": 0.4,
"y": 0.4,
"z": 1
},
"_mobility": 0,
@@ -623,11 +714,11 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 23
"__id__": 28
},
"_enabled": true,
"__prefab": {
"__id__": 25
"__id__": 30
},
"_contentSize": {
"__type__": "cc.Size",
@@ -651,11 +742,11 @@
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 23
"__id__": 28
},
"_enabled": true,
"__prefab": {
"__id__": 27
"__id__": 32
},
"_customMaterial": null,
"_srcBlendFactor": 2,
@@ -726,92 +817,6 @@
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 22
},
"_enabled": true,
"__prefab": {
"__id__": 30
},
"_contentSize": {
"__type__": "cc.Size",
"width": 89,
"height": 89
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "7aA4ZvlQpNear6ycFqd468"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 22
},
"_enabled": true,
"__prefab": {
"__id__": 32
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "f87f53f9-2fba-4a5b-968a-79a593311ab2@008c0",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "b7uI2M3YdGj6VIy7UY4akz"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "e8i10bRRRABphjmj2v+NEC",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_name": "name",
@@ -973,7 +978,7 @@
},
{
"__type__": "cc.Node",
"_name": "stars",
"_name": "slv",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
@@ -1043,7 +1048,7 @@
"__id__": 40
},
"_children": [],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 42
@@ -1179,7 +1184,7 @@
"__id__": 40
},
"_children": [],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 48
@@ -1315,7 +1320,7 @@
"__id__": 40
},
"_children": [],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 54
@@ -1451,7 +1456,7 @@
"__id__": 40
},
"_children": [],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 60
@@ -1587,7 +1592,7 @@
"__id__": 40
},
"_children": [],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 66
@@ -1825,6 +1830,95 @@
"__type__": "cc.CompPrefabInfo",
"fileId": "32bpMN2RNIXbFGf0XrTQcR"
},
{
"__type__": "e50ae68DJJPcqtoSXnmOcGT",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 79
},
"hcc_home": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "7cMkGEWuhL85u6N6BcnP89"
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 81
},
"clickEvents": [
{
"__id__": 82
}
],
"_interactable": true,
"_transition": 3,
"_normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_hoverColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_pressedColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_normalSprite": null,
"_hoverSprite": null,
"_pressedSprite": null,
"_disabledSprite": null,
"_duration": 0.1,
"_zoomScale": 1.2,
"_target": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "4eYZzd0tZCnaXQJvFU/nxf"
},
{
"__type__": "cc.ClickEvent",
"target": {
"__id__": 1
},
"component": "",
"_componentId": "e50ae68DJJPcqtoSXnmOcGT",
"handler": "show_info",
"customEventData": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {

File diff suppressed because it is too large Load Diff

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()
}
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)
}
}
hero_show(uuid:number) {
console.log("hero_home hero_show:",uuid)
}
}
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; // 更新位置
}
}
let hero_talent_content=parent.getComponent(UITransform)
hero_talent_content.height=2000
console.log("hero_talent_content:",parent)
}
/** 视图对象通过 ecs.Entity.remove(ControllerComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}