import { HttpStateType, ReveData } from "../../../../util/CHttp"; import FMap from "../../map/FMap"; import FAltarLight from "./FAltarLight"; const SpineName = { IDLE: "idle", IDLE2: "idle2", CLOSE: "close", OPEN: "open" } /** * 事件机关 */ const { ccclass, property } = cc._decorator; @ccclass export default class FAltarGear extends cc.Component { @property({ displayName: '对应的地图物件' }) public mapGoodId: string = '27'; @property({ type: [cc.Node], displayName: '祭坛灯柱' }) public altarLight: Array = []; /** * 控制的栅栏机关 */ @property({ displayName: '控制的机关', type: [cc.Node], }) mFenceTrigger: Array = []; private map: FMap = null; onLoad() { this.map = this.node.parent.parent.getComponent(FMap); } /** * 检查灯柱点亮情况 */ public check() { for (let i = 0; i < this.altarLight.length; i++) { const element = this.altarLight[i]; let altarLight = element.getComponent(FAltarLight) if (!altarLight.spine.active) { return false; } } this.openGear(); return true } private openGear() { let ff = this.map.ff; ff.pauseSprite(true); this.moveCamera(() => { this.mFenceTrigger.forEach(element => { let spine = element.children[0].getComponent(sp.Skeleton); if (spine) { spine.setAnimation(0, SpineName.OPEN, false); spine.setCompleteListener(() => { spine.setCompleteListener(null); element.zIndex = -9999; element.getComponent(cc.PhysicsBoxCollider).enabled = false; }) } }); }); } private moveCamera(callFunc: Function) { let map = this.map; let camera = map.mCamera; let pos = cc.v2(); let winsize = cc.winSize; pos.x = this.node.x - winsize.width / 2; pos.y = this.node.y - winsize.height / 2; cc.tween(camera.node).sequence( cc.moveTo(1, pos).easing(cc.easeOut(1)), cc.callFunc(() => { callFunc && callFunc(); }), cc.delayTime(1), cc.callFunc(() => { map.ff.pauseSprite(false); }) ).start() } }