cb/assets/Script/prop/Lock.ts
2025-07-01 19:39:23 +08:00

48 lines
1.2 KiB
TypeScript

// 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){
this.node.parent.getComponent("Block").type = 0;
this.node.destroy();
this.node.removeFromParent();
}
}
// update (dt) {}
}