mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-10-09 08:36:14 +00:00
Progress
This commit is contained in:
@@ -3,6 +3,7 @@ import { GroupType } from "../GroupType";
|
||||
import { Player } from "../Player/Player";
|
||||
import { GameTimer } from "../../Services/GameTimer";
|
||||
import { Enemy } from "../Enemy/Enemy";
|
||||
import { XP } from "../XP/XP";
|
||||
|
||||
export class PlayerCollisionSystem {
|
||||
private playerContacts: Collider2D[] = [];
|
||||
@@ -20,6 +21,7 @@ export class PlayerCollisionSystem {
|
||||
this.collisionTimer = new GameTimer(collisionDelay);
|
||||
|
||||
this.groupToResolver.set(GroupType.ENEMY, this.resolveEnemyContact.bind(this));
|
||||
this.groupToResolver.set(GroupType.XP, this.resolveXpContact.bind(this));
|
||||
}
|
||||
|
||||
public gameTick(deltaTime: number): void {
|
||||
@@ -60,4 +62,12 @@ export class PlayerCollisionSystem {
|
||||
console.log("Collided with enemy: Damage: " + damage);
|
||||
this.player.Health.damage(damage);
|
||||
}
|
||||
|
||||
private resolveXpContact(xpCollider: Collider2D): void {
|
||||
const xp: XP = xpCollider.node.getComponent(XP);
|
||||
this.player.addXp(xp.Value);
|
||||
xp.pickup();
|
||||
|
||||
console.log("Collided with xp: " + xp);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user