// 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 MapConroler from "../Map";
import NumberToImage from "../NumberToImage";

const { ccclass, property } = cc._decorator;



@ccclass
export default class Lock extends cc.Component {
    static _instance: any;
    time: number = 0;

    // mapInfo: number[][] = [];

    onLoad() {

    }

    start() {
    }

    init(time) {
        if (time) this.time = time;
        this.node.getChildByName("time").active = true;
        NumberToImage.numberToImageNodes(this.time, 20, 8, "lock_", this.node.getChildByName("time"), false);

    }

    reduce() {
        this.time -= 1;
        NumberToImage.numberToImageNodes(this.time, 20, 8, "lock_", this.node.getChildByName("time"), false);
        if (this.time <= 0) {
            if (this.node.parent) this.node.parent.getComponent("Block").type = 0;
            this.node.destroy();
            this.node.removeFromParent();
        }
    }

    // update (dt) {}
}
