25 lines
661 B
TypeScript
Raw Normal View History

2022-12-19 15:50:24 +01:00
import { Component, Vec3, _decorator } from "cc";
2022-12-20 11:27:51 +01:00
import { ISignal } from "../../../Services/EventSystem/ISignal";
import { Signal } from "../../../Services/EventSystem/Signal";
2022-12-19 15:50:24 +01:00
const { ccclass, property } = _decorator;
@ccclass("Gold")
export class Gold extends Component {
private pickUpEvent: Signal<Gold> = new Signal<Gold>();
public setup(position: Vec3): void {
this.node.setWorldPosition(position);
this.node.active = true;
}
public get PickupEvent(): ISignal<Gold> {
return this.pickUpEvent;
}
public pickup(): void {
this.pickUpEvent.trigger(this);
this.node.active = false;
}
}