mirror of
https://github.com/Sheldan/canvas.git
synced 2026-01-01 14:58:51 +00:00
survivors: adding pull range upgrade
renaming dagger to chain ball increasing returning speed for chain ball
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type {ChanceEntry, Item} from "./interfaces.ts";
|
||||
import {Player} from "./Player.ts";
|
||||
import {randomItem} from "./utils.ts";
|
||||
import {Dagger, HomingPistol, Pistol, SpreadWeapon} from "./weapons.ts";
|
||||
import {ChainBall, HomingPistol, Pistol, SpreadWeapon} from "./weapons.ts";
|
||||
import type {World} from "./World.ts";
|
||||
|
||||
export enum Rarity {
|
||||
@@ -40,7 +40,8 @@ export class ItemManagement {
|
||||
this.ITEMS.push(new HomingPistolItem())
|
||||
this.ITEMS.push(new PistolItem())
|
||||
this.ITEMS.push(new SpreadWeaponItem())
|
||||
this.ITEMS.push(new DaggerWeaponItem())
|
||||
this.ITEMS.push(new ChainBallWeaponItem())
|
||||
this.ITEMS.push(new PullRangeUp())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +97,21 @@ export class SpeedUp extends BaseItem {
|
||||
}
|
||||
}
|
||||
|
||||
export class PullRangeUp extends BaseItem {
|
||||
pickup(player: Player, world: World) {
|
||||
player.stats.pullRange *= 1.1
|
||||
super.pickup(player, world)
|
||||
}
|
||||
|
||||
name() {
|
||||
return 'pull range'
|
||||
}
|
||||
|
||||
getRarity(): Rarity {
|
||||
return Rarity.COMMON;
|
||||
}
|
||||
}
|
||||
|
||||
export class HealthUp extends BaseItem {
|
||||
pickup(player: Player, world: World) {
|
||||
player.stats.health += 1
|
||||
@@ -156,14 +172,14 @@ export class SpreadWeaponItem extends BaseItem {
|
||||
}
|
||||
}
|
||||
|
||||
export class DaggerWeaponItem extends BaseItem {
|
||||
export class ChainBallWeaponItem extends BaseItem {
|
||||
pickup(player: Player, world: World) {
|
||||
player.addWeapon(Dagger.createDagger(world))
|
||||
player.addWeapon(ChainBall.createChainBall(world))
|
||||
super.pickup(player, world)
|
||||
}
|
||||
|
||||
name() {
|
||||
return 'dagger'
|
||||
return 'chain ball'
|
||||
}
|
||||
|
||||
getRarity(): Rarity {
|
||||
|
||||
@@ -167,6 +167,7 @@ export class WeaponProjectile extends Projectile {
|
||||
this.position = straightMove(this.position, this.speedVec)
|
||||
if(this.position.distanceTo(this.target) < this.stats.size) {
|
||||
this.movingBack = true;
|
||||
this.speedVec = this.speedVec.multiply(3)
|
||||
}
|
||||
} else {
|
||||
this.position = moveInDirectionOf(this.position, this.world.player.position, this.speedVec.vecLength())
|
||||
|
||||
@@ -31,9 +31,9 @@ export class PlayerInfo implements DrawContainer {
|
||||
this.statLabels = [
|
||||
new StatLabel(() => 'Money', () => this.world.player.status.wealth),
|
||||
new StatLabel(() => 'Level', () => this.world.player.status.level),
|
||||
new StatLabel(() => 'Speed', () => this.world.player.stats.speed),
|
||||
new StatLabel(() => 'Pull range', () => this.world.player.stats.pullRange),
|
||||
new StatLabel(() => 'Weapon range', () => this.world.player.stats.effectiveWeaponRange)
|
||||
new StatLabel(() => 'Speed', () => Math.floor(this.world.player.stats.speed)),
|
||||
new StatLabel(() => 'Pull range', () => Math.floor(this.world.player.stats.pullRange)),
|
||||
new StatLabel(() => 'Weapon range', () => Math.floor(this.world.player.stats.effectiveWeaponRange))
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ export abstract class MeleeWeapon extends RangeWeapon {
|
||||
this.shootCooldown = 0
|
||||
}
|
||||
}
|
||||
export class Dagger extends MeleeWeapon {
|
||||
export class ChainBall extends MeleeWeapon {
|
||||
|
||||
createProjectile(): boolean {
|
||||
let range = this.calculateRange()
|
||||
@@ -112,7 +112,7 @@ export class Dagger extends MeleeWeapon {
|
||||
}
|
||||
}
|
||||
|
||||
static createDagger(world: World, offset?: Vector) {
|
||||
static createChainBall(world: World, offset?: Vector) {
|
||||
if(!offset) {
|
||||
offset = new Vector(5, 5)
|
||||
}
|
||||
@@ -120,7 +120,7 @@ export class Dagger extends MeleeWeapon {
|
||||
.withProjectileSpeed(3)
|
||||
.withDamage(15)
|
||||
.withShootInterval(50)
|
||||
let pistol = new Dagger(world, stats)
|
||||
let pistol = new ChainBall(world, stats)
|
||||
pistol.offset = offset;
|
||||
pistol.size = 4;
|
||||
pistol.color = 'gray';
|
||||
|
||||
Reference in New Issue
Block a user