This commit is contained in:
pan
2024-08-20 18:27:34 +08:00
parent 87a445c225
commit b9edfd7001
17 changed files with 407 additions and 143 deletions

View File

@@ -13,11 +13,12 @@ const { ccclass, property } = _decorator;
@ecs.register('HeroCardView', false)
export class HeroCardViewComp extends CCComp {
card_name:string = "hero_card";
card_type:string = "hero";
card_uid:number = 1000;
in_destroy:boolean = false;
pos_x:number = 0;
pos_y:number = 0;
card_type:number = 1;
card_level:number = 1;
protected onLoad(): void {
this.node.on(NodeEventType.TOUCH_START, this.onTouchMove, this);
@@ -31,7 +32,7 @@ export class HeroCardViewComp extends CCComp {
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("level").getChildByName("level").getComponent(Label).string = this.card_level.toString();
this.node.getChildByName("name").getComponent(Label).string = this.card_name
}
@@ -97,14 +98,30 @@ export class HeroCardViewComp extends CCComp {
}
use_card(){
if(smc.vm_data.gold.min >= smc.vm_data.cards.ref_cost){
if(smc.vm_data.gold.min >= this.card_level){
this.in_destroy = true;
oops.message.dispatchEvent("do_add_hero",{uuid:this.card_uid})
this.do_use_card()
this.ent.destroy();
smc.vm_data.gold.min -= smc.vm_data.cards.ref_cost;
smc.vm_data.gold.min -= this.card_level;
}else{
oops.gui.toast("金币不够");
this.node.setPosition(this.pos_x,this.pos_y);
}
}
do_use_card(){
switch (this.card_type) { // 添加括号并修正语法
case 1:
oops.message.dispatchEvent("do_add_hero", { uuid: this.card_uid }); // 添加分号
break;
case 2:
oops.message.dispatchEvent("do_use_skill", { uuid: this.card_uid }); // 添加分号
// console.log("do_use_skill",this.card_uid)
break;
default:
break;
}
}
}