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:
@@ -1,4 +1,5 @@
|
||||
import { Animation, Node, BoxCollider2D, Collider2D, Component, Vec2, Vec3, _decorator, Details } from "cc";
|
||||
import { Animation, Node, BoxCollider2D, Collider2D, Component, Vec2, Vec3, _decorator, Details, Sprite, Color } from "cc";
|
||||
import { delay } from "../../../Services/Utils/AsyncUtils";
|
||||
import { IInput } from "../../Input/IInput";
|
||||
import { UnitHealth } from "../UnitHealth";
|
||||
import { UnitLevel } from "../UnitLevel";
|
||||
@@ -15,6 +16,7 @@ export class Player extends Component {
|
||||
@property(Weapon) private weapon: Weapon;
|
||||
@property(Node) private playerGraphics: Node;
|
||||
@property(Animation) private animation: Animation;
|
||||
@property(Sprite) private sprite: Sprite;
|
||||
|
||||
private input: IInput;
|
||||
private health: UnitHealth;
|
||||
@@ -32,7 +34,7 @@ export class Player extends Component {
|
||||
this.speed = data.speed;
|
||||
|
||||
this.weapon.init(data.strikeDelay, data.damage);
|
||||
|
||||
this.health.HealthPointsChangeEvent.on(this.animateHurt, this);
|
||||
this.playerUI.init(this.health);
|
||||
}
|
||||
|
||||
@@ -91,6 +93,12 @@ export class Player extends Component {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async animateHurt(): Promise<void> {
|
||||
this.sprite.color = Color.RED;
|
||||
await delay(100);
|
||||
this.sprite.color = Color.WHITE;
|
||||
}
|
||||
}
|
||||
|
||||
export class PlayerData {
|
||||
|
Reference in New Issue
Block a user