mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-01-15 07:21:27 +00:00
28 lines
810 B
TypeScript
28 lines
810 B
TypeScript
|
import { Animation, Component, Vec3, _decorator } from "cc";
|
||
|
import { ISignal } from "../../../Services/EventSystem/ISignal";
|
||
|
import { Signal } from "../../../Services/EventSystem/Signal";
|
||
|
|
||
|
const { ccclass, property } = _decorator;
|
||
|
|
||
|
@ccclass("HealthPotion")
|
||
|
export class HealthPotion extends Component {
|
||
|
@property(Animation) private animation: Animation;
|
||
|
|
||
|
private pickUpEvent: Signal<HealthPotion> = new Signal<HealthPotion>();
|
||
|
|
||
|
public setup(position: Vec3): void {
|
||
|
this.node.setWorldPosition(position);
|
||
|
this.node.active = true;
|
||
|
this.animation.play("DropStart");
|
||
|
}
|
||
|
|
||
|
public get PickupEvent(): ISignal<HealthPotion> {
|
||
|
return this.pickUpEvent;
|
||
|
}
|
||
|
|
||
|
public pickup(): void {
|
||
|
this.pickUpEvent.trigger(this);
|
||
|
this.node.active = false;
|
||
|
}
|
||
|
}
|