27 lines
601 B
TypeScript
27 lines
601 B
TypeScript
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.open();
|
|
}
|
|
|
|
public close() {
|
|
this._gate.active = true;
|
|
}
|
|
|
|
public open() {
|
|
this._gate.active = false;
|
|
}
|
|
}
|