-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
165 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Container } from "pixi.js"; | ||
import { GameWorld } from "../../world"; | ||
import { Coordinate, MetersValue } from "../../utils/coodinate"; | ||
import { WormInstance } from "../../logic"; | ||
import { EntityType } from "../type"; | ||
import { Grenade } from "./grenade"; | ||
import { getConditionTint, PlayableCondition } from "../playable/conditions"; | ||
|
||
/** | ||
* Grenade projectile. | ||
*/ | ||
export class GasGrenade extends Grenade { | ||
static create( | ||
parent: Container, | ||
world: GameWorld, | ||
position: Coordinate, | ||
initialForce: { x: number; y: number }, | ||
timerSecs = 3, | ||
worm?: WormInstance, | ||
) { | ||
const ent = new GasGrenade( | ||
position, | ||
initialForce, | ||
world, | ||
parent, | ||
timerSecs, | ||
worm, | ||
); | ||
parent.addChild(ent.sprite, ent.wireframe.renderable); | ||
return ent; | ||
} | ||
|
||
private constructor( | ||
position: Coordinate, | ||
initialForce: { x: number; y: number }, | ||
world: GameWorld, | ||
parent: Container, | ||
timerSecs: number, | ||
owner?: WormInstance, | ||
) { | ||
super(position, initialForce, world, parent, timerSecs, owner, { | ||
applyCondition: PlayableCondition.Sickness, | ||
maxDamage: 10, | ||
explosionRadius: new MetersValue(3), | ||
damagesTerrain: false, | ||
explosionHue: getConditionTint([PlayableCondition.Sickness]) ?? 0xFFFFF, | ||
forceMultiplier: 0.25, | ||
}); | ||
} | ||
|
||
recordState() { | ||
return { | ||
...super.recordState(), | ||
type: EntityType.GasGrenade, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Container, Point } from "pixi.js"; | ||
import { | ||
FireOpts, | ||
IWeaponCode, | ||
IWeaponDefiniton, | ||
projectileWeaponHelper, | ||
} from "./weapon"; | ||
import { Worm } from "../entities/playable/worm"; | ||
import { GameWorld } from "../world"; | ||
import icon from "../assets/grenade.png"; | ||
import { GasGrenade } from "../entities/phys/gas-grenade"; | ||
|
||
export const WeaponGasGrenade: IWeaponDefiniton = { | ||
name: "Gas Grenade", | ||
icon, | ||
code: IWeaponCode.GasGrenade, | ||
maxDuration: 50, | ||
allowGetaway: true, | ||
timerAdjustable: true, | ||
showTargetGuide: true, | ||
loadAssets(assets) { | ||
this.sprite = { | ||
texture: assets.textures.grenade, | ||
scale: new Point(0.33, 0.33), | ||
offset: new Point(3, -10), | ||
}; | ||
}, | ||
fireFn(parent: Container, world: GameWorld, worm: Worm, opts: FireOpts) { | ||
if (!opts.duration) { | ||
throw Error("Duration expected but not given"); | ||
} | ||
if (!opts.timer) { | ||
throw Error("Timer expected but not given"); | ||
} | ||
if (opts.angle === undefined) { | ||
throw Error("Angle expected but not given"); | ||
} | ||
const { position, force } = projectileWeaponHelper( | ||
worm.position, | ||
opts.duration, | ||
opts.angle, | ||
); | ||
return GasGrenade.create( | ||
parent, | ||
world, | ||
position, | ||
force, | ||
opts.timer, | ||
worm.wormIdent, | ||
); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters