mirror of
https://github.com/Sheldan/canvas.git
synced 2026-04-22 05:51:23 +00:00
survivors: chainBall now attacks the furthest away enemy within range
refactoring player stats a bit changing schedule the enemies are spawned
This commit is contained in:
@@ -162,12 +162,21 @@ export class PlayerStatus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class PlayerStats {
|
export class PlayerStats {
|
||||||
constructor(private _speed: number,
|
|
||||||
private _size: number,
|
private _speed: number;
|
||||||
private _health: number,
|
private _size: number;
|
||||||
private _pullRange: number,
|
private _health: number;
|
||||||
private _weaponRange: number,
|
private _pullRange: number;
|
||||||
private _weaponRangeFactor: number) {
|
private _weaponRange: number;
|
||||||
|
private _weaponRangeFactor: number;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this._speed = 3;
|
||||||
|
this._size = 5;
|
||||||
|
this._health = 10;
|
||||||
|
this._pullRange = 150;
|
||||||
|
this._weaponRange = 250;
|
||||||
|
this._weaponRangeFactor = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
increaseLevel() {
|
increaseLevel() {
|
||||||
@@ -228,6 +237,6 @@ export class PlayerStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static defaultPlayerStats(): PlayerStats {
|
public static defaultPlayerStats(): PlayerStats {
|
||||||
return new PlayerStats(3, 5, 10, 150, 250, 1);
|
return new PlayerStats();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,6 +90,24 @@ export class World {
|
|||||||
return this.getClosestTargetToButNot(point, undefined, range)
|
return this.getClosestTargetToButNot(point, undefined, range)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFarthestTargetButWithin(point: Vector, range?: number): [number, Placeable | undefined] | undefined {
|
||||||
|
let currentTarget;
|
||||||
|
let currentDistance = Number.MAX_SAFE_INTEGER;
|
||||||
|
this._enemies.items.forEach(enemy => {
|
||||||
|
let distance = point.distanceTo(enemy.getPosition());
|
||||||
|
if(range && distance > range) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if((range - distance) < currentDistance) {
|
||||||
|
currentDistance = distance;
|
||||||
|
currentTarget = enemy
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(currentTarget) {
|
||||||
|
return [currentDistance, currentTarget];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getClosestTargetToButNot(point: Vector, placeable?: Placeable, range?: number): [number, Placeable | undefined] | undefined {
|
getClosestTargetToButNot(point: Vector, placeable?: Placeable, range?: number): [number, Placeable | undefined] | undefined {
|
||||||
return this.getClosestTargetToButNotArray(point, [placeable], range)
|
return this.getClosestTargetToButNotArray(point, [placeable], range)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,9 +110,12 @@ docReady(function () {
|
|||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
BasicEnemy.spawnBasicEnemy(world)
|
BasicEnemy.spawnBasicEnemy(world)
|
||||||
ShootingEnemy.spawnShootingEnemy(world)
|
|
||||||
}, 1_000)
|
}, 1_000)
|
||||||
|
|
||||||
|
setInterval(() => {
|
||||||
|
ShootingEnemy.spawnShootingEnemy(world)
|
||||||
|
}, 3_000)
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
HealthEnemy.spawnHealthEnemy(world)
|
HealthEnemy.spawnHealthEnemy(world)
|
||||||
}, 15_000)
|
}, 15_000)
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ export abstract class Projectile implements Acting, Placeable {
|
|||||||
this.status.collisionCooldown.resetCooldown()
|
this.status.collisionCooldown.resetCooldown()
|
||||||
}
|
}
|
||||||
} else if(this.parent === this.world.player) {
|
} else if(this.parent === this.world.player) {
|
||||||
// TODO think why this was done, why do I need to calculate the newest target on _each_ act?
|
|
||||||
let closestTargetTo = this.world.getClosestTargetToButNot(this.position, this.lastColliding);
|
let closestTargetTo = this.world.getClosestTargetToButNot(this.position, this.lastColliding);
|
||||||
if(closestTargetTo !== undefined && closestTargetTo[1] !== undefined) {
|
if(closestTargetTo !== undefined && closestTargetTo[1] !== undefined) {
|
||||||
let target: Placeable = closestTargetTo[1]!;
|
let target: Placeable = closestTargetTo[1]!;
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ export class ChainBall extends MeleeWeapon {
|
|||||||
|
|
||||||
createProjectile(): boolean {
|
createProjectile(): boolean {
|
||||||
let range = this.calculateRange()
|
let range = this.calculateRange()
|
||||||
let closestTargetTo = this.world.getClosestTargetTo(this.world.player.position, range);
|
let closestTargetTo = this.world.getFarthestTargetButWithin(this.world.player.position, range);
|
||||||
if(closestTargetTo !== undefined && closestTargetTo[1] !== undefined) {
|
if(closestTargetTo !== undefined && closestTargetTo[1] !== undefined) {
|
||||||
let stats = new ProjectileStats()
|
let stats = new ProjectileStats()
|
||||||
.withPiercings(1000)
|
.withPiercings(1000)
|
||||||
@@ -267,6 +267,11 @@ export class WeaponStats {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this._weaponRangeFactor = 1
|
this._weaponRangeFactor = 1
|
||||||
|
this._weaponRange = 0
|
||||||
|
this._projectilePiercings = 0
|
||||||
|
this._projectileSpeed = 100
|
||||||
|
this._damage = 1
|
||||||
|
this._shootInterval = 50
|
||||||
}
|
}
|
||||||
|
|
||||||
increase() {
|
increase() {
|
||||||
|
|||||||
Reference in New Issue
Block a user