51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
import { _decorator, Animation, Component, Label, Node, resources, Sprite, SpriteAtlas, tween, v3 } from 'cc';
|
|
import { SuperCards, SuperCardsType } from '../common/config/CardSet';
|
|
import { SkillSet } from '../common/config/SkillSet';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('LuckCardComp')
|
|
export class LuckCardComp extends Component {
|
|
timer:number=3;
|
|
start() {
|
|
this.timer=2
|
|
console.log("[LuckCardComp]:start")
|
|
}
|
|
|
|
update(deltaTime: number) {
|
|
this.timer-=deltaTime
|
|
if(this.timer<=0){
|
|
let anim=this.node.getComponent(Animation)
|
|
if(anim) anim.play("luckcardend")
|
|
this.do_destroy()
|
|
this.timer=2
|
|
}
|
|
}
|
|
show_card(card:any){
|
|
var icon_path = "game/heros/cards"
|
|
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
|
const sprite = this.node.getChildByName("icon").getComponent(Sprite);
|
|
sprite.spriteFrame = atlas.getSpriteFrame(SuperCards[card.uuid].path);
|
|
});
|
|
this.node.getChildByName("name").getComponent(Label).string=SuperCards[card.uuid].name
|
|
switch(SuperCards[card.uuid].type){
|
|
case SuperCardsType.BUFF:
|
|
this.node.getChildByName("val").getComponent(Label).string="+"+SuperCards[card.uuid].value2
|
|
break
|
|
case SuperCardsType.AOE:
|
|
this.node.getChildByName("val").getComponent(Label).string=SkillSet[SuperCards[card.uuid].value1].name+"X"+SuperCards[card.uuid].value2
|
|
break
|
|
}
|
|
}
|
|
do_destroy(){
|
|
tween(this.node)
|
|
.to(0.2, {
|
|
scale: v3(2,2,0),
|
|
}, {onComplete:()=>{
|
|
this.node.destroy()
|
|
}})
|
|
.start();
|
|
}
|
|
}
|
|
|
|
|