mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-10-09 08:36:14 +00:00
Item manager
This commit is contained in:
10
assets/Scripts/Game/Items/PickupEffect/PickupEffect.ts
Normal file
10
assets/Scripts/Game/Items/PickupEffect/PickupEffect.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Animation, Component, _decorator } from "cc";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("PickupEffect")
|
||||
export class PickupEffect extends Component {
|
||||
@property(Animation) private animation: Animation;
|
||||
public init(): void {
|
||||
this.animation.play("PickBonus");
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "0f2b2cd0-1d1e-4862-821f-5fcb83c4ec23",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
import { _decorator, Component, Node, Prefab, Vec3 } from "cc";
|
||||
import { ObjectPool } from "../../../Services/ObjectPool";
|
||||
import { delay } from "../../../Services/Utils/AsyncUtils";
|
||||
import { PickupEffect } from "./PickupEffect";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("PickupEffectManager")
|
||||
export class PickupEffectManager extends Component {
|
||||
@property(Prefab) private pickupEffect: Prefab;
|
||||
|
||||
private effectPool: ObjectPool<PickupEffect>;
|
||||
|
||||
public init(): void {
|
||||
this.effectPool = new ObjectPool(this.pickupEffect, this.node, 5, "PickupEffect");
|
||||
}
|
||||
|
||||
public async showEffect(position: Vec3): Promise<void> {
|
||||
const effect = this.effectPool.borrow();
|
||||
effect.node.setWorldPosition(position);
|
||||
effect.node.active = true;
|
||||
|
||||
await delay(450);
|
||||
|
||||
this.effectPool.return(effect);
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "65b4121f-a4cf-47e1-97d4-1e0d3fc72eec",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
Reference in New Issue
Block a user