This commit is contained in:
walkpan
2024-08-18 23:38:55 +08:00
parent e8dbb9bab3
commit 8f57f57c1d
1004 changed files with 234067 additions and 16087 deletions

View File

@@ -1,4 +1,4 @@
import { _decorator ,Label} from "cc";
import { _decorator ,Label,NodeEventType,EventTouch} 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 { data } from "../data/data";
@@ -16,16 +16,49 @@ export class HeroCardViewComp extends CCComp {
card_type:string = "hero";
card_uid:number = 1000;
in_destroy:boolean = false;
pos_x:number = 0;
pos_y:number = 0;
protected onLoad(): void {
// this.node.on(NodeEventType.TOUCH_START, this.onTouch, 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);
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() {
this.pos_x=this.node.position.x;
this.pos_y=this.node.position.y;
this.node.getChildByName("level").getChildByName("level").getComponent(Label).string = CardSet[this.card_uid].level.toString();
this.node.getChildByName("name").getComponent(Label).string = this.card_name
}
/** 全局消息逻辑处理 */
// private onHandler(event: string, args: any) {
// switch (event) {
// case ModuleEvent.Cmd:
// break;
// }
// }
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.in_destroy = false;
this.node.destroy();
}
onTouchMove(event: EventTouch) {
let delta = event.getDelta();
this.node.setPosition(this.node.position.x+delta.x,this.node.position.y+delta.y);
}
onTouchEnd(){
if(this.node.position.y-this.pos_y > 150){
this.use_card()
}else{
this.node.setPosition(this.pos_x,this.pos_y);
}
}
private do_active_card_eid(event: string, args: any) {
console.log("active_card_eid",args,this.ent.eid)
if(this.ent.eid != args.eid){
@@ -36,19 +69,19 @@ export class HeroCardViewComp extends CCComp {
do_active(){
// console.log(this.node.getChildByName("active"),this.node.getChildByName("use"), this.node.getChildByName("bag"))
let active = this.node.getChildByName("active")
let use = this.node.getChildByName("use")
let bag = this.node.getChildByName("bag")
// let use = this.node.getChildByName("use")
// let bag = this.node.getChildByName("bag")
active.active = !active.active
use.active = !use.active
bag.active = !bag.active
// use.active = !use.active
// bag.active = !bag.active
}
no_active(){
let active = this.node.getChildByName("active")
let use = this.node.getChildByName("use")
let bag = this.node.getChildByName("bag")
// let use = this.node.getChildByName("use")
// let bag = this.node.getChildByName("bag")
active.active = false
use.active = false
bag.active = false
// use.active = false
// bag.active = false
}
doit(){
// this.do_active()
@@ -71,26 +104,7 @@ export class HeroCardViewComp extends CCComp {
smc.vm_data.gold.min -= CardSet[this.card_uid].level;
}else{
oops.gui.toast("金币不够");
this.node.setPosition(this.pos_x,this.pos_y);
}
}
/** 视图层逻辑代码分离演示 */
start() {
this.node.getChildByName("level").getChildByName("level").getComponent(Label).string = CardSet[this.card_uid].level.toString();
}
/** 全局消息逻辑处理 */
// private onHandler(event: string, args: any) {
// switch (event) {
// case ModuleEvent.Cmd:
// break;
// }
// }
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.in_destroy = false;
this.node.destroy();
}
}