环境技能继续

This commit is contained in:
2024-12-11 10:54:40 +08:00
parent 4ef7abf374
commit ec83f6506b
14 changed files with 4822 additions and 5396 deletions

View File

@@ -34,12 +34,3 @@ export class HCard extends ecs.Entity {
super.destroy();
}
}
/** HCard 模块业务逻辑系统组件,如无业务逻辑处理可删除此对象 */
export class EcsHCardSystem extends ecs.System {
constructor() {
super();
// this.add(new ecs.ComblockSystem());
}
}

View File

@@ -31,21 +31,17 @@ export class HeroHomeComp extends CCComp {
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)
this.h_uuid=uuid
this.role=smc.heros[uuid]
this.hero=HeroInfo[uuid]
console.log("hero_home hero:",this.hero)
let tal=this.node.getChildByName("sk").getChildByName("tal");
let sk_node= this.node.getChildByName("sk");
let skill = SkillSet[this.hero.sk2[0]]
@@ -160,7 +156,6 @@ export class HeroHomeComp extends CCComp {
lv_up(){
console.log("升级",smc.vmdata.items[1001],((LvUp[0]+this.hero.lvexp)*this.role.lv))
if(smc.vmdata.items[1001] < ((LvUp[0]+this.hero.lvexp)*this.role.lv)||smc.vmdata.gold < (UpGold.LvUp*this.role.lv)){
oops.gui.toast("资源不足,升级失败");
return

View File

@@ -0,0 +1,38 @@
import { instantiate, Prefab } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { MSCardComp } from "./MSCardComp";
import { smc } from "../common/SingletonModuleComp";
/** MSCard 模块 */
@ecs.register(`MSCard`)
export class MSCard extends ecs.Entity {
/** 实始添加的数据层组件 */
protected init() {
// this.addComponents<ecs.Comp>();
}
load(uuid:number=1001,parent:any) {
var path = "game/gui/MSCard";
// var icon_path = "game/heros/herois"
// resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
// const sprite = node.getChildByName("Mask").getChildByName("icon").getComponent(Sprite);
// sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[uuid].path);
// });
var prefab: Prefab = oops.res.get(path, Prefab)!;
console.log("load_hcard",prefab)
var node = instantiate(prefab);
node.parent = parent
var msc = node.getComponent(MSCardComp)!;
msc.s_uuid= uuid
if(smc.mskill==uuid) msc.is_selected=true
this.add(msc)
}
/** 模块资源释放 */
destroy() {
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
super.destroy();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "b808913f-7dc0-4dbf-9e74-12b5338a39ee",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,30 @@
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";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('MSCardComp')
@ecs.register('MSCardComp', false)
export class MSCardComp extends CCComp {
s_uuid: number = 0;
is_updated: boolean = false;
is_select: boolean = false;
is_selected: boolean = false;
/** 视图层逻辑代码分离演示 */
start() {
console.log("MSCardComp start");
if(this.is_updated){ this.node.getChildByName("update").active=true }else{ this.node.getChildByName("update").active=false }
if(this.is_select){ this.node.getChildByName("select").active=true }else{ this.node.getChildByName("select").active=false }
if(this.is_selected){ this.node.getChildByName("selected").active=true }else{ this.node.getChildByName("selected").active=false }
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "f7a30834-31c8-405a-9f9d-70555981d611",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -33,7 +33,7 @@ export class MissionHomeComp extends CCComp {
}
start_mission(e:any,args:any) {
console.log("start_mission")
console.log("mission home start_mission")
for(let i=0;i<this.heros.length;i++){
this.heros[i].to_destroy()
}
@@ -55,7 +55,6 @@ export class MissionHomeComp extends CCComp {
}
}
select_hero(h_uuid:number){
console.log("select_hero",h_uuid)
for(let i=0;i<4;i++){
if(this.heros_pos[i].uuid==0){
this.heros_pos[i].uuid=h_uuid
@@ -63,17 +62,14 @@ export class MissionHomeComp extends CCComp {
break
}
}
console.log("select_hero",this.heros_pos)
}
cancel_hero(h_uuid:number){
console.log("cancel_hero",h_uuid)
for(let i=0;i<4;i++){
if(this.heros_pos[i].uuid==h_uuid){
this.heros_pos[i].uuid=0
this.destory_hero(h_uuid)
}
}
console.log("cancel_hero",this.heros_pos)
}
call_hero(h_uuid:number,index:number){
var path = "game/heros/uiheros/"+HeroInfo[h_uuid].path;
@@ -83,10 +79,8 @@ export class MissionHomeComp extends CCComp {
node.parent = scene.entityLayer!.node!
node.setPosition(this.heros_pos[index].px,BoxSet.GAME_LINE,0);
let comp = node.getComponent(UiHeroComp)
console.log("call_hero",node)
comp.h_uuid = h_uuid
this.heros.push(comp)
console.log("call heros",this.heros)
}
destory_hero(h_uuid:number){
console.log("destory hero",this.heros)