// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import PoolMgr, { NODEPOOLPREFABTYPE } from "../../mgr/PoolMgr";
import ArtNum from "../../util/common/ArtNum";

const { ccclass, property } = cc._decorator;

@ccclass
export default class GetScore extends cc.Component {
    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start() {

    }

    // update (dt) {}

    public init(pos: cc.Vec2, rewardNum: number) {
       
        this.getComponent(ArtNum).init(rewardNum);
        this.node.opacity = 255;
        this.node.scaleX = this.node.scaleY = 2;
        this.node.setPosition(pos.x, pos.y);
        //礼物
        let levelUp_end_y = this.node.y + 50;
        cc.tween(this.node)
            .to(0.2, { scale: 1 }, { easing: "smooth" })
            .to(0.5, { y: levelUp_end_y, opacity: 0 }, { easing: "smooth" })
            .call(() => {
                PoolMgr.Inst.recyclePoolPrefab(NODEPOOLPREFABTYPE.GetScore, this.node);
            })
            .start();
    }
}
