cb/assets/Script/prop/Question.ts
2026-03-09 16:32:19 +08:00

89 lines
3.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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 Question extends cc.Component {
static _instance: any;
time: number = 60;
@property(cc.Material)
freeze: cc.Material = null;
@property(cc.Prefab)
ice: cc.Prefab = null;
// mapInfo: number[][] = [];
onLoad() {
}
start() {
}
init(time, type) {
if (time) this.time = time;
this.node.getChildByName("time").active = true;
NumberToImage.numberToImageNodes(this.time, 40, 25, "ice_", this.node.getChildByName("time"), false);
// this.node.getChildByName("time").getComponent(cc.Label).string = this.time.toString();
}
reduce(number) {
if (this.node.parent) {
if (this.node.parent.getComponent("Block").block_Info.floor) {
console.log("__________问号块减少时还在地板下面");
return;
}
}
this.time -= number;
if (this.time <= 0) this.time = 0
NumberToImage.numberToImageNodes(this.time, 40, 25, "ice_", this.node.getChildByName("time"), false);
cc.fx.GameTool.numberScaleAction(this.node.getChildByName("time"));
// this.node.getChildByName("time").scaleX = 1.2;
// this.node.getChildByName("time").scaleY = 1.2;
// this.node.getChildByName("time").getComponent(cc.Label).string = this.time.toString();
if (this.time <= 0) {
this.node.getChildByName("bingkuai").active = true;
const skeleton = this.node.getChildByName("bingkuai").getComponent(sp.Skeleton);
skeleton.setAnimation(1, "bingkuai", false);
this.node.getChildByName("icon").active = true;
this.node.getChildByName("time").active = false;
if (this.node) {
if (this.node.parent) this.node.parent.getComponent("Block").resetQuestionColor();
}
cc.tween(this.node.getChildByName("icon"))
.to(0.5, { opacity: 0 })
.start();
// cc.fx.AudioManager._instance.playEffect("freezeBlock", null);
// this.node.getChildByName("icon").getComponent(cc.Sprite).setMaterial(0,this.freeze);
// this.node.children.forEach(element => {
// element.destroy();
// });
setTimeout(() => {
if (this.node) {
// if (this.node.parent) this.node.parent.getComponent("Block").resetQuestionColor();
this.node.destroy();
this.node.removeFromParent();
}
}, 500);
}
}
// update (dt) {}
}