This commit is contained in:
2024-09-10 17:52:32 +08:00
parent 90350d0503
commit 77a168628a
8 changed files with 818 additions and 607 deletions

View File

@@ -1,50 +0,0 @@
import { instantiate, Prefab, Vec3 } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { InfoBoxCom } from "./InfoBoxCom";
import { smc } from "../common/SingletonModuleComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
/** InfoBox 模块 */
@ecs.register(`InfoBox`)
export class InfoBox extends ecs.Entity {
/** ---------- 数据层 ---------- */
// InfoBoxModel!: InfoBoxModelComp;
/** ---------- 业务层 ---------- */
// InfoBoxBll!: InfoBoxBllComp;
/** ---------- 视图层 ---------- */
InfoBoxView!: InfoBoxCom
/** 实始添加的数据层组件 */
protected init() {
// this.addComponents<ecs.Comp>();
}
load(pos: Vec3 = Vec3.ZERO,uuid:number=101,prefab_path:string) {
var path = "game/gui/"+prefab_path;
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
var scene = smc.map.MapView.scene;
node.parent = scene.SkillLayer!.node!;
node.setPosition(pos)
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
// const url = 'game/heros/player';
// resources.load(url, SpriteAtlas, (err: any, atlas) => {
// const sprite = node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
// sprite.spriteFrame = atlas.getSpriteFrame(RoleSet[uuid].path);
// });
// var rv = node.getComponent(MonsterViewComp)!;
// this.add(rv);
var mv = node.getComponent(InfoBoxCom)!;
this.add(mv);
}
/** 模块资源释放 */
destroy() {
// 注: 自定义释放逻辑,视图层实现 ecs.IComp 接口的 ecs 组件需要手动释放
this.remove(InfoBoxCom);
super.destroy();
}
}

View File

@@ -1,43 +0,0 @@
import { _decorator ,Node} 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('InfoBoxCom')
@ecs.register('InfoBox', false)
export class InfoBoxCom extends CCComp {
@property(Node)
n_name:Node =null!
@property(Node)
n_hp:Node =null!
@property(Node)
n_atk:Node =null!
@property(Node)
n_info:Node =null!
@property(Node)
n_atk_cd:Node =null!
@property(Node)
n_skillcd:Node =null!
n_type:number=0; // 0:技能 1 精灵
/** 视图层逻辑代码分离演示 */
start() {
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
console.log("InfoBoxCom start");
}
/** 全局消息逻辑处理 */
// private onHandler(event: string, args: any) {
// switch (event) {
// case ModuleEvent.Cmd:
// break;
// }
// }
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}

View File

@@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "20c2c0dd-188e-41da-b74e-fdacae24b337",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,70 @@
import { _decorator, Component, EventTouch, Node, NodeEventType } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('ShowInfoCom')
export class ShowInfoCom extends Component {
protected onLoad(): void {
this.node.on(NodeEventType.TOUCH_START, this.onTouchMove, this);
this.node.on(NodeEventType.TOUCH_MOVE, this.onTouchMove, this);
this.node.on(NodeEventType.TOUCH_END, this.onTouchEnd, this);
this.node.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this);
// oops.message.on("active_card_eid", this.do_active_card_eid, this);
}
start() {
}
onTouchMove(event: EventTouch) {
let delta = event.getDelta();
this.node.setPosition(this.node.position.x+delta.x,this.node.position.y+delta.y);
this.show_info()
}
show_info(uuid:number,card_type:number){
console.log("show_info",this.card_uid)
let parent = this.node.parent.parent
let node =parent.getChildByName("item_box")
if(this.card_type == 2){
smc.vm_data.item_box.info = SkillSet[this.card_uid].info
smc.vm_data.item_box.name = SkillSet[this.card_uid].name
smc.vm_data.item_box.skillcd = SkillSet[this.card_uid].cd
smc.vm_data.item_box.skillsd = SkillSet[this.card_uid].sd
smc.vm_data.item_box.atk = SkillSet[this.card_uid].atk
smc.vm_data.item_box.hp = SkillSet[this.card_uid].hp
node.active=true
}
if(this.card_type == 3){
console.log(SkillSet[this.card_uid])
smc.vm_data.item_box.info = SkillSet[this.card_uid].info
smc.vm_data.item_box.name = SkillSet[this.card_uid].name
smc.vm_data.item_box.skillcd = SkillSet[this.card_uid].cd
smc.vm_data.item_box.skillsd = SkillSet[this.card_uid].sd
smc.vm_data.item_box.atk = SkillSet[this.card_uid].atk
smc.vm_data.item_box.hp = SkillSet[this.card_uid].hp
smc.vm_data.item_box.shield = SkillSet[this.card_uid].shield
node.active=true
if(SkillSet[this.card_uid].shield > 0){
node.getChildByName("data").getChildByName("shield").active=true
}
if(SkillSet[this.card_uid].hp > 0){
node.getChildByName("data").getChildByName("hp").active=true
}
}
}
onTouchEnd(){
if(this.node.position.y-this.pos_y > 150){
this.use_card()
}else{
this.node.setPosition(this.pos_x,this.pos_y);
}
let parent = this.node.parent.parent
let node = parent.getChildByName("item_box")
node.active=false
node.getChildByName("data").getChildByName("shield").active=false
node.getChildByName("data").getChildByName("hp").active=false
}
update(deltaTime: number) {
}
}

View File

@@ -2,7 +2,7 @@
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "b64b5d93-6a68-402a-a7ab-bf89db4a153b",
"uuid": "d612b0f7-dcf2-499a-993f-8b42291faa18",
"files": [],
"subMetas": {},
"userData": {}