mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-09-24 04:39:05 +00:00
game runner
This commit is contained in:
@@ -13,12 +13,14 @@ export class Enemy extends Component {
|
||||
private movementType: EnemyMovementType;
|
||||
private health: UnitHealth = new UnitHealth(1);
|
||||
private deathEvent: Signal<Enemy> = new Signal<Enemy>();
|
||||
private speed: number;
|
||||
private speedX: number;
|
||||
private speedY: number;
|
||||
|
||||
public setup(position: Vec3, movementType: EnemyMovementType): void {
|
||||
this.movementType = movementType;
|
||||
this.health = new UnitHealth(1);
|
||||
this.speed = randomRange(40, 90);
|
||||
this.speedX = randomRange(40, 90);
|
||||
this.speedY = randomRange(40, 90);
|
||||
this.node.setWorldPosition(position);
|
||||
this.node.active = true;
|
||||
}
|
||||
@@ -52,8 +54,8 @@ export class Enemy extends Component {
|
||||
|
||||
public moveBy(move: Vec3, deltaTime: number): void {
|
||||
const newPosition: Vec3 = this.node.worldPosition;
|
||||
newPosition.x += move.x * this.speed * deltaTime;
|
||||
newPosition.y += move.y * this.speed * deltaTime;
|
||||
newPosition.x += move.x * this.speedX * deltaTime;
|
||||
newPosition.y += move.y * this.speedY * deltaTime;
|
||||
|
||||
this.node.setWorldPosition(newPosition);
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ export class WaveEnemyMover extends EnemyMover {
|
||||
let direction: Vec3 = new Vec3();
|
||||
|
||||
// if the enemy is added soon enough, move as a single group towards one direction
|
||||
if (Vec3.distance(this.lastTargetPosition, this.targetNode.worldPosition) < 10) {
|
||||
if (Vec3.equals(this.lastTargetPosition, this.targetNode.worldPosition)) {
|
||||
direction = this.lastDirection;
|
||||
} else {
|
||||
direction = Vec3.subtract(direction, this.targetNode.worldPosition, enemy.node.worldPosition);
|
||||
|
@@ -15,7 +15,7 @@ export class IndividualEnemySpawner {
|
||||
if (this.spawnTimer.tryFinishPeriod()) {
|
||||
const posX: number = randomRange(300, 600) * randomPositiveOrNegative();
|
||||
const posY: number = randomRange(300, 600) * randomPositiveOrNegative();
|
||||
this.enemySpawner.spawnNewEnemy(posX, posY, EnemyMovementType.Launch);
|
||||
this.enemySpawner.spawnNewEnemy(posX, posY, EnemyMovementType.Follow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -48,8 +48,8 @@ export class WaveEnemySpawner {
|
||||
|
||||
private trySpawnNewGroup(): void {
|
||||
if (this.spawnTimer.tryFinishPeriod()) {
|
||||
const defaultPosX: number = 200 * randomPositiveOrNegative();
|
||||
const defaultPosY: number = 200 * randomPositiveOrNegative();
|
||||
const defaultPosX: number = (500 + randomRange(0, 100)) * randomPositiveOrNegative();
|
||||
const defaultPosY: number = randomRange(0, 500) * randomPositiveOrNegative();
|
||||
|
||||
const enemies: Enemy[] = [];
|
||||
const side: number = Math.ceil(Math.sqrt(this.enemiesPerWave));
|
||||
|
Reference in New Issue
Block a user