mirror of
https://github.com/Sheldan/canvas.git
synced 2026-04-15 20:16:33 +00:00
survivors: moving shoot interval to weapon stats
changing weapon stats
This commit is contained in:
@@ -48,7 +48,6 @@ export abstract class BasicWeapon implements Weapon {
|
|||||||
export abstract class RangeWeapon extends BasicWeapon {
|
export abstract class RangeWeapon extends BasicWeapon {
|
||||||
|
|
||||||
protected projectiles: [Projectile] = []
|
protected projectiles: [Projectile] = []
|
||||||
protected shootInterval: number;
|
|
||||||
protected shootCooldown: number = 0;
|
protected shootCooldown: number = 0;
|
||||||
|
|
||||||
abstract createProjectile(): boolean;
|
abstract createProjectile(): boolean;
|
||||||
@@ -56,7 +55,7 @@ export abstract class RangeWeapon extends BasicWeapon {
|
|||||||
act() {
|
act() {
|
||||||
if(this.shootCooldown <= 0) {
|
if(this.shootCooldown <= 0) {
|
||||||
if(this.createProjectile()) {
|
if(this.createProjectile()) {
|
||||||
this.shootCooldown = this.shootInterval;
|
this.shootCooldown = this.stats.shootInterval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.shootCooldown -= 1;
|
this.shootCooldown -= 1;
|
||||||
@@ -95,13 +94,13 @@ export class HomingPistol extends RangeWeapon {
|
|||||||
offset = new Vector(5, 5)
|
offset = new Vector(5, 5)
|
||||||
}
|
}
|
||||||
let stats = new WeaponStats()
|
let stats = new WeaponStats()
|
||||||
.withProjectileSpeed(3)
|
.withProjectileSpeed(1)
|
||||||
.withDamage(5)
|
.withDamage(3)
|
||||||
|
.withShootInterval(50)
|
||||||
let pistol = new HomingPistol(world, stats)
|
let pistol = new HomingPistol(world, stats)
|
||||||
pistol.offset = offset;
|
pistol.offset = offset;
|
||||||
pistol.size = 5;
|
pistol.size = 5;
|
||||||
pistol.color = 'yellow';
|
pistol.color = 'yellow';
|
||||||
pistol.shootInterval = 50;
|
|
||||||
return pistol;
|
return pistol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,13 +133,13 @@ export class Pistol extends RangeWeapon {
|
|||||||
offset = new Vector(5, 5)
|
offset = new Vector(5, 5)
|
||||||
}
|
}
|
||||||
let stats = new WeaponStats()
|
let stats = new WeaponStats()
|
||||||
.withProjectileSpeed(5)
|
.withProjectileSpeed(2)
|
||||||
.withDamage(5)
|
.withDamage(4)
|
||||||
|
.withShootInterval(25)
|
||||||
let pistol = new Pistol(world, stats)
|
let pistol = new Pistol(world, stats)
|
||||||
pistol.offset = offset;
|
pistol.offset = offset;
|
||||||
pistol.size = 5;
|
pistol.size = 5;
|
||||||
pistol.color = 'brown';
|
pistol.color = 'brown';
|
||||||
pistol.shootInterval = 50;
|
|
||||||
return pistol;
|
return pistol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,6 +152,7 @@ export class WeaponStats {
|
|||||||
private _projectileSpeed: number;
|
private _projectileSpeed: number;
|
||||||
private _projectilePiercings: number;
|
private _projectilePiercings: number;
|
||||||
private _damage: number;
|
private _damage: number;
|
||||||
|
private _shootInterval: number;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this._weaponRangeFactor = 1
|
this._weaponRangeFactor = 1
|
||||||
@@ -173,13 +173,16 @@ export class WeaponStats {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
withShootInterval(value: number) {
|
||||||
|
this._shootInterval = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
withProjectilePiercings(value: number) {
|
withProjectilePiercings(value: number) {
|
||||||
this._projectilePiercings = value;
|
this._projectilePiercings = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
withDamage(value: number) {
|
withDamage(value: number) {
|
||||||
this._damage = value;
|
this._damage = value;
|
||||||
return this;
|
return this;
|
||||||
@@ -206,6 +209,10 @@ export class WeaponStats {
|
|||||||
return this._projectileSpeed;
|
return this._projectileSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get shootInterval(): number {
|
||||||
|
return this._shootInterval;
|
||||||
|
}
|
||||||
|
|
||||||
get effectiveWeaponRange(): number {
|
get effectiveWeaponRange(): number {
|
||||||
return this._weaponRange * this._weaponRangeFactor
|
return this._weaponRange * this._weaponRangeFactor
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user