mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-12-14 00:29:21 +00:00
Item manager
This commit is contained in:
24
assets/Scripts/Game/Items/Gold/Gold.ts
Normal file
24
assets/Scripts/Game/Items/Gold/Gold.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Component, Vec3, _decorator } from "cc";
|
||||
import { ISignal } from "../../../Services/EventSystem/ISignal";
|
||||
import { Signal } from "../../../Services/EventSystem/Signal";
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user