import { _decorator, Component, Node } from 'cc'; import { EventManger } from '../Manager/EventManger'; import GameEvent from '../Events/GameEvent'; const { ccclass, property } = _decorator; @ccclass('Gate') export class Gate extends Component { @property({ type: Node, visible: true }) private _gate: Node; protected onLoad(): void { EventManger.instance.on(GameEvent.BallOut, this.reset, this); } private reset() { this.close(); } public close() { this._gate.active = true; } public open() { this._gate.active = false; } }