55 lines
1.6 KiB
TypeScript
55 lines
1.6 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;
|
|
type: string = "block"
|
|
// mapInfo: number[][] = [];
|
|
|
|
onLoad() {
|
|
|
|
}
|
|
|
|
start() {
|
|
}
|
|
|
|
init(time, type) {
|
|
if (time) this.time = time;
|
|
if (type) this.type = type;
|
|
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.type == "block") {
|
|
if (this.node.parent) this.node.parent.getComponent("Block").type = 0;
|
|
}
|
|
else if (this.type == "wall") {
|
|
if (this.node.parent) this.node.parent.getChildByName("wall").getComponent("Wall").special = 0;
|
|
if (this.node.parent) this.node.parent.getChildByName("wall").getComponent("Wall").specialBackup = 0;
|
|
}
|
|
this.node.destroy();
|
|
this.node.removeFromParent();
|
|
}
|
|
}
|
|
|
|
// update (dt) {}
|
|
}
|