dd
This commit is contained in:
@@ -3,7 +3,8 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { data } from "../data/data";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { CardSet } from "../common/config/CardSet";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@@ -39,22 +40,40 @@ export class HeroCardViewComp extends CCComp {
|
||||
}
|
||||
|
||||
onTouchMove(event: EventTouch) {
|
||||
smc.vm_data.cards.eid = this.ent.eid;
|
||||
let parent = this.node.parent;
|
||||
let active = parent.getChildByName("active");
|
||||
active.setPosition(this.node.position.x,this.node.position.y)
|
||||
active.active = true;
|
||||
console.log(parent);
|
||||
// if(this.ent.eid == smc.vm_data.cards.eid){
|
||||
// this.node.getChildByName("active").active = true;
|
||||
// }else{
|
||||
// this.node.getChildByName("active").active = false;
|
||||
// }
|
||||
console.log("onTouchMove");
|
||||
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 > 50){
|
||||
let parent = this.node.parent;
|
||||
let active = parent.getChildByName("active");
|
||||
active.setPosition(this.pos_x,this.pos_y)
|
||||
if(this.node.position.y-this.pos_y > 110){
|
||||
active.active = false;
|
||||
this.use_card()
|
||||
}else{
|
||||
this.node.setPosition(this.pos_x,this.pos_y);
|
||||
}
|
||||
console.log(ecs.query(ecs.allOf(HeroCardViewComp)))
|
||||
|
||||
}
|
||||
use_card(){
|
||||
oops.message.dispatchEvent("do_add_hero",this.ent)
|
||||
this.ent.destroy();
|
||||
if(smc.vm_data.gold.min >= CardSet[this.card_uid].level){
|
||||
oops.message.dispatchEvent("do_add_hero",this.ent)
|
||||
this.ent.destroy();
|
||||
smc.vm_data.gold.min -= CardSet[this.card_uid].level;
|
||||
}else{
|
||||
this.node.setPosition(this.pos_x,this.pos_y);
|
||||
}
|
||||
}
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
|
||||
Reference in New Issue
Block a user