Run prettier
This commit is contained in:
parent
b45f81e6c6
commit
d9a7b5094c
@ -57,6 +57,6 @@ export function addButton(
|
|||||||
},
|
},
|
||||||
new Rect(topLeftPadded, sizePadded),
|
new Rect(topLeftPadded, sizePadded),
|
||||||
enabled,
|
enabled,
|
||||||
{onClick: cbClick},
|
{ onClick: cbClick },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,12 @@ import { D, I } from "./engine/public.ts";
|
|||||||
import { Rect } from "./engine/datatypes.ts";
|
import { Rect } from "./engine/datatypes.ts";
|
||||||
|
|
||||||
export type Handlers = {
|
export type Handlers = {
|
||||||
onClick?: () => void,
|
onClick?: () => void;
|
||||||
onSqueeze?: () => void,
|
onSqueeze?: () => void;
|
||||||
}
|
};
|
||||||
|
|
||||||
export class DrawPile {
|
export class DrawPile {
|
||||||
#draws: { depth: number; op: () => void; handlers?: Handlers, }[];
|
#draws: { depth: number; op: () => void; handlers?: Handlers }[];
|
||||||
#hoveredIndex: number | null;
|
#hoveredIndex: number | null;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -30,9 +30,9 @@ export class DrawPile {
|
|||||||
rect: Rect,
|
rect: Rect,
|
||||||
enabled: boolean,
|
enabled: boolean,
|
||||||
handlers: {
|
handlers: {
|
||||||
onClick?: () => void,
|
onClick?: () => void;
|
||||||
onSqueeze?: () => void,
|
onSqueeze?: () => void;
|
||||||
}
|
},
|
||||||
) {
|
) {
|
||||||
let position = I.mousePosition?.offset(D.camera);
|
let position = I.mousePosition?.offset(D.camera);
|
||||||
let hovered = false;
|
let hovered = false;
|
||||||
|
@ -348,7 +348,7 @@ export class EndgameModal {
|
|||||||
} else {
|
} else {
|
||||||
this.#selectedSuccessor = ix;
|
this.#selectedSuccessor = ix;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -402,7 +402,6 @@ export class EndgameModal {
|
|||||||
generalRect,
|
generalRect,
|
||||||
enabled,
|
enabled,
|
||||||
{
|
{
|
||||||
|
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
if (this.#selectedWish == ix) {
|
if (this.#selectedWish == ix) {
|
||||||
this.#selectedWish = null;
|
this.#selectedWish = null;
|
||||||
@ -410,7 +409,7 @@ export class EndgameModal {
|
|||||||
this.#selectedWish = ix;
|
this.#selectedWish = ix;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ export class Point {
|
|||||||
snap(x: number, y: number) {
|
snap(x: number, y: number) {
|
||||||
return new Point(
|
return new Point(
|
||||||
lerp(x, Math.floor(this.x), Math.ceil(this.x)),
|
lerp(x, Math.floor(this.x), Math.ceil(this.x)),
|
||||||
lerp(y, Math.floor(this.y), Math.ceil(this.y))
|
lerp(y, Math.floor(this.y), Math.ceil(this.y)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,7 +141,6 @@ export class Rect {
|
|||||||
return `Rect(${this.top},${this.size})`;
|
return `Rect(${this.top},${this.size})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
offset(offset: Point) {
|
offset(offset: Point) {
|
||||||
return new Rect(this.top.offset(offset), this.size);
|
return new Rect(this.top.offset(offset), this.size);
|
||||||
}
|
}
|
||||||
@ -303,4 +302,4 @@ export function lerp(amt: number, lo: number, hi: number) {
|
|||||||
return hi;
|
return hi;
|
||||||
}
|
}
|
||||||
return lo + (hi - lo) * amt;
|
return lo + (hi - lo) * amt;
|
||||||
};
|
}
|
||||||
|
@ -23,20 +23,22 @@ export class GridArt {
|
|||||||
this.#floorCenter = atPixel.offset(CENTER);
|
this.#floorCenter = atPixel.offset(CENTER);
|
||||||
this.#ceilingCenter = at.scale(CEILING_CELL_SIZE).offset(CENTER);
|
this.#ceilingCenter = at.scale(CEILING_CELL_SIZE).offset(CENTER);
|
||||||
|
|
||||||
this.#floorTl = atPixel.offset(new Point(-FLOOR_CELL_SIZE.w / 2, -FLOOR_CELL_SIZE.h / 2))
|
this.#floorTl = atPixel
|
||||||
|
.offset(new Point(-FLOOR_CELL_SIZE.w / 2, -FLOOR_CELL_SIZE.h / 2))
|
||||||
.offset(CENTER);
|
.offset(CENTER);
|
||||||
this.#ceilingTl = at
|
this.#ceilingTl = at
|
||||||
.offset(new Point(-0.5, -0.5))
|
.offset(new Point(-0.5, -0.5))
|
||||||
.scale(CEILING_CELL_SIZE)
|
.scale(CEILING_CELL_SIZE)
|
||||||
.offset(CENTER)
|
.offset(CENTER)
|
||||||
.snap(0, 0)
|
.snap(0, 0);
|
||||||
this.#floorBr = atPixel.offset(new Point(FLOOR_CELL_SIZE.w / 2, FLOOR_CELL_SIZE.h / 2))
|
this.#floorBr = atPixel
|
||||||
|
.offset(new Point(FLOOR_CELL_SIZE.w / 2, FLOOR_CELL_SIZE.h / 2))
|
||||||
.offset(CENTER);
|
.offset(CENTER);
|
||||||
this.#ceilingBr = at
|
this.#ceilingBr = at
|
||||||
.offset(new Point(0.5, 0.5))
|
.offset(new Point(0.5, 0.5))
|
||||||
.scale(CEILING_CELL_SIZE)
|
.scale(CEILING_CELL_SIZE)
|
||||||
.offset(CENTER)
|
.offset(CENTER)
|
||||||
.snap(0, 0)
|
.snap(0, 0);
|
||||||
|
|
||||||
// console.log(`floorTl: ${this.#floorTl}`)
|
// console.log(`floorTl: ${this.#floorTl}`)
|
||||||
// console.log(`floorBr: ${this.#floorBr}`)
|
// console.log(`floorBr: ${this.#floorBr}`)
|
||||||
@ -102,14 +104,18 @@ export class GridArt {
|
|||||||
if (this.#atPixel.y < -FLOOR_CELL_SIZE.h / 2) {
|
if (this.#atPixel.y < -FLOOR_CELL_SIZE.h / 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new GridArt(this.#atPixel.offset(new Point(0, FLOOR_CELL_SIZE.h))).#drawWallTop(color);
|
new GridArt(
|
||||||
|
this.#atPixel.offset(new Point(0, FLOOR_CELL_SIZE.h)),
|
||||||
|
).#drawWallTop(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawWallRight(color: Color) {
|
drawWallRight(color: Color) {
|
||||||
if (this.#atPixel.x < -FLOOR_CELL_SIZE.w / 2) {
|
if (this.#atPixel.x < -FLOOR_CELL_SIZE.w / 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new GridArt(this.#atPixel.offset(new Point(FLOOR_CELL_SIZE.w, 0))).#drawWallLeft(color);
|
new GridArt(
|
||||||
|
this.#atPixel.offset(new Point(FLOOR_CELL_SIZE.w, 0)),
|
||||||
|
).#drawWallLeft(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawMouldingTop(color: Color) {
|
drawMouldingTop(color: Color) {
|
||||||
@ -118,11 +124,7 @@ export class GridArt {
|
|||||||
let x1 = this.#ceilingBr.x;
|
let x1 = this.#ceilingBr.x;
|
||||||
let y1 = this.#ceilingTl.y;
|
let y1 = this.#ceilingTl.y;
|
||||||
|
|
||||||
D.fillRect(
|
D.fillRect(new Point(x0, y0), new Size(x1 - x0, y1 - y0), color);
|
||||||
new Point(x0, y0),
|
|
||||||
new Size(x1 - x0, y1 - y0),
|
|
||||||
color
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drawMouldingTopLeft(color: Color) {
|
drawMouldingTopLeft(color: Color) {
|
||||||
@ -131,11 +133,7 @@ export class GridArt {
|
|||||||
let x1 = this.#ceilingTl.x;
|
let x1 = this.#ceilingTl.x;
|
||||||
let y1 = this.#ceilingTl.y;
|
let y1 = this.#ceilingTl.y;
|
||||||
|
|
||||||
D.fillRect(
|
D.fillRect(new Point(x0, y0), new Size(x1 - x0, y1 - y0), color);
|
||||||
new Point(x0, y0),
|
|
||||||
new Size(x1 - x0, y1 - y0),
|
|
||||||
color
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drawMouldingLeft(color: Color) {
|
drawMouldingLeft(color: Color) {
|
||||||
@ -144,11 +142,7 @@ export class GridArt {
|
|||||||
let x1 = this.#ceilingTl.x;
|
let x1 = this.#ceilingTl.x;
|
||||||
let y1 = this.#ceilingBr.y;
|
let y1 = this.#ceilingBr.y;
|
||||||
|
|
||||||
D.fillRect(
|
D.fillRect(new Point(x0, y0), new Size(x1 - x0, y1 - y0), color);
|
||||||
new Point(x0, y0),
|
|
||||||
new Size(x1 - x0, y1 - y0),
|
|
||||||
color
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drawMouldingTopRight(color: Color) {
|
drawMouldingTopRight(color: Color) {
|
||||||
@ -157,11 +151,7 @@ export class GridArt {
|
|||||||
let x1 = this.#ceilingBr.x + MOULDING_SZ.w;
|
let x1 = this.#ceilingBr.x + MOULDING_SZ.w;
|
||||||
let y1 = this.#ceilingTl.y;
|
let y1 = this.#ceilingTl.y;
|
||||||
|
|
||||||
D.fillRect(
|
D.fillRect(new Point(x0, y0), new Size(x1 - x0, y1 - y0), color);
|
||||||
new Point(x0, y0),
|
|
||||||
new Size(x1 - x0, y1 - y0),
|
|
||||||
color
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drawMouldingBottom(color: Color) {
|
drawMouldingBottom(color: Color) {
|
||||||
@ -170,11 +160,7 @@ export class GridArt {
|
|||||||
let x1 = this.#ceilingBr.x;
|
let x1 = this.#ceilingBr.x;
|
||||||
let y1 = this.#ceilingBr.y + MOULDING_SZ.h;
|
let y1 = this.#ceilingBr.y + MOULDING_SZ.h;
|
||||||
|
|
||||||
D.fillRect(
|
D.fillRect(new Point(x0, y0), new Size(x1 - x0, y1 - y0), color);
|
||||||
new Point(x0, y0),
|
|
||||||
new Size(x1 - x0, y1 - y0),
|
|
||||||
color
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drawMouldingBottomLeft(color: Color) {
|
drawMouldingBottomLeft(color: Color) {
|
||||||
@ -183,11 +169,7 @@ export class GridArt {
|
|||||||
let x1 = this.#ceilingTl.x;
|
let x1 = this.#ceilingTl.x;
|
||||||
let y1 = this.#ceilingBr.y + MOULDING_SZ.h;
|
let y1 = this.#ceilingBr.y + MOULDING_SZ.h;
|
||||||
|
|
||||||
D.fillRect(
|
D.fillRect(new Point(x0, y0), new Size(x1 - x0, y1 - y0), color);
|
||||||
new Point(x0, y0),
|
|
||||||
new Size(x1 - x0, y1 - y0),
|
|
||||||
color,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drawMouldingRight(color: Color) {
|
drawMouldingRight(color: Color) {
|
||||||
@ -196,11 +178,7 @@ export class GridArt {
|
|||||||
let x1 = this.#ceilingBr.x + MOULDING_SZ.w;
|
let x1 = this.#ceilingBr.x + MOULDING_SZ.w;
|
||||||
let y1 = this.#ceilingBr.y;
|
let y1 = this.#ceilingBr.y;
|
||||||
|
|
||||||
D.fillRect(
|
D.fillRect(new Point(x0, y0), new Size(x1 - x0, y1 - y0), color);
|
||||||
new Point(x0, y0),
|
|
||||||
new Size(x1 - x0, y1 - y0),
|
|
||||||
color
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drawMouldingBottomRight(color: Color) {
|
drawMouldingBottomRight(color: Color) {
|
||||||
@ -209,11 +187,7 @@ export class GridArt {
|
|||||||
let x1 = this.#ceilingBr.x + MOULDING_SZ.w;
|
let x1 = this.#ceilingBr.x + MOULDING_SZ.w;
|
||||||
let y1 = this.#ceilingBr.y + MOULDING_SZ.h;
|
let y1 = this.#ceilingBr.y + MOULDING_SZ.h;
|
||||||
|
|
||||||
D.fillRect(
|
D.fillRect(new Point(x0, y0), new Size(x1 - x0, y1 - y0), color);
|
||||||
new Point(x0, y0),
|
|
||||||
new Size(x1 - x0, y1 - y0),
|
|
||||||
color
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drawCeiling(color: Color) {
|
drawCeiling(color: Color) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {Point, Rect, Size} from "./engine/datatypes.ts";
|
import { Point, Rect, Size } from "./engine/datatypes.ts";
|
||||||
import {DrawPile} from "./drawpile.ts";
|
import { DrawPile } from "./drawpile.ts";
|
||||||
import {D, I} from "./engine/public.ts";
|
import { D, I } from "./engine/public.ts";
|
||||||
import {sprThrallLore} from "./sprites.ts";
|
import { sprThrallLore } from "./sprites.ts";
|
||||||
import {
|
import {
|
||||||
BG_INSET,
|
BG_INSET,
|
||||||
BG_WALL_OR_UNREVEALED,
|
BG_WALL_OR_UNREVEALED,
|
||||||
@ -11,11 +11,11 @@ import {
|
|||||||
FG_TEXT_ENDORSED,
|
FG_TEXT_ENDORSED,
|
||||||
FG_TOO_EXPENSIVE,
|
FG_TOO_EXPENSIVE,
|
||||||
} from "./colors.ts";
|
} from "./colors.ts";
|
||||||
import {getPlayerProgress} from "./playerprogress.ts";
|
import { getPlayerProgress } from "./playerprogress.ts";
|
||||||
import {Architecture, LoadedNewMap} from "./newmap.ts";
|
import { Architecture, LoadedNewMap } from "./newmap.ts";
|
||||||
import {FLOOR_CELL_SIZE, GridArt} from "./gridart.ts";
|
import { FLOOR_CELL_SIZE, GridArt } from "./gridart.ts";
|
||||||
import {shadowcast} from "./shadowcast.ts";
|
import { shadowcast } from "./shadowcast.ts";
|
||||||
import {withCamera} from "./layout.ts";
|
import { withCamera } from "./layout.ts";
|
||||||
|
|
||||||
export class HuntMode {
|
export class HuntMode {
|
||||||
map: LoadedNewMap;
|
map: LoadedNewMap;
|
||||||
@ -49,9 +49,13 @@ export class HuntMode {
|
|||||||
|
|
||||||
get pixelPlayer(): Point {
|
get pixelPlayer(): Point {
|
||||||
return new Point(
|
return new Point(
|
||||||
Math.floor(this.floatingPlayer.x * FLOOR_CELL_SIZE.w - FLOOR_CELL_SIZE.w / 2),
|
Math.floor(
|
||||||
Math.floor(this.floatingPlayer.y * FLOOR_CELL_SIZE.h - FLOOR_CELL_SIZE.h / 2),
|
this.floatingPlayer.x * FLOOR_CELL_SIZE.w - FLOOR_CELL_SIZE.w / 2,
|
||||||
)
|
),
|
||||||
|
Math.floor(
|
||||||
|
this.floatingPlayer.y * FLOOR_CELL_SIZE.h - FLOOR_CELL_SIZE.h / 2,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getDepth() {
|
getDepth() {
|
||||||
@ -126,9 +130,7 @@ export class HuntMode {
|
|||||||
this.frame += 1;
|
this.frame += 1;
|
||||||
this.drawpile.clear();
|
this.drawpile.clear();
|
||||||
|
|
||||||
let globalOffset = this.pixelPlayer.offset(
|
let globalOffset = this.pixelPlayer.offset(new Point(-192, -192));
|
||||||
new Point(-192, -192)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.#updatePlayer();
|
this.#updatePlayer();
|
||||||
this.#updateFov();
|
this.#updateFov();
|
||||||
@ -136,9 +138,9 @@ export class HuntMode {
|
|||||||
|
|
||||||
for (let y = 0; y < this.map.size.h; y += 1) {
|
for (let y = 0; y < this.map.size.h; y += 1) {
|
||||||
for (let x = 0; x < this.map.size.w; x += 1) {
|
for (let x = 0; x < this.map.size.w; x += 1) {
|
||||||
let offsetInPixels = new Point(x, y).scale(FLOOR_CELL_SIZE).offset(
|
let offsetInPixels = new Point(x, y)
|
||||||
this.pixelPlayer.negate()
|
.scale(FLOOR_CELL_SIZE)
|
||||||
);
|
.offset(this.pixelPlayer.negate());
|
||||||
this.#drawMapCell(offsetInPixels, new Point(x, y));
|
this.#drawMapCell(offsetInPixels, new Point(x, y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,10 +157,18 @@ export class HuntMode {
|
|||||||
|
|
||||||
let amt = 0.005;
|
let amt = 0.005;
|
||||||
|
|
||||||
if (I.isKeyDown("w")) { dy -= amt; }
|
if (I.isKeyDown("w")) {
|
||||||
if (I.isKeyDown("s")) { dy += amt; }
|
dy -= amt;
|
||||||
if (I.isKeyDown("a")) { dx -= amt; }
|
}
|
||||||
if (I.isKeyDown("d")) { dx += amt; }
|
if (I.isKeyDown("s")) {
|
||||||
|
dy += amt;
|
||||||
|
}
|
||||||
|
if (I.isKeyDown("a")) {
|
||||||
|
dx -= amt;
|
||||||
|
}
|
||||||
|
if (I.isKeyDown("d")) {
|
||||||
|
dx += amt;
|
||||||
|
}
|
||||||
|
|
||||||
dx *= 0.9;
|
dx *= 0.9;
|
||||||
dy *= 0.9;
|
dy *= 0.9;
|
||||||
@ -174,8 +184,8 @@ export class HuntMode {
|
|||||||
|
|
||||||
let bbox = new Rect(
|
let bbox = new Rect(
|
||||||
newXy.offset(new Point(-szX / 2, -szY / 2)),
|
newXy.offset(new Point(-szX / 2, -szY / 2)),
|
||||||
new Size(szX, szY)
|
new Size(szX, szY),
|
||||||
)
|
);
|
||||||
|
|
||||||
for (let cell of bbox.overlappedCells(new Size(1, 1)).values()) {
|
for (let cell of bbox.overlappedCells(new Size(1, 1)).values()) {
|
||||||
if (this.#blocksMovement(cell.top)) {
|
if (this.#blocksMovement(cell.top)) {
|
||||||
@ -189,8 +199,8 @@ export class HuntMode {
|
|||||||
|
|
||||||
bbox = new Rect(
|
bbox = new Rect(
|
||||||
newXy.offset(new Point(-szX / 2, -szY / 2)),
|
newXy.offset(new Point(-szX / 2, -szY / 2)),
|
||||||
new Size(szX, szY)
|
new Size(szX, szY),
|
||||||
)
|
);
|
||||||
|
|
||||||
for (let cell of bbox.overlappedCells(new Size(1, 1)).values()) {
|
for (let cell of bbox.overlappedCells(new Size(1, 1)).values()) {
|
||||||
if (this.#blocksMovement(cell.top)) {
|
if (this.#blocksMovement(cell.top)) {
|
||||||
@ -326,8 +336,8 @@ export class HuntMode {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pickup?.onSqueeze(cellData);
|
pickup?.onSqueeze(cellData);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (pickup != null) {
|
if (pickup != null) {
|
||||||
|
@ -4,9 +4,11 @@ import { choose, shuffle } from "./utils.ts";
|
|||||||
import { standardVaultTemplates, VaultTemplate } from "./vaulttemplate.ts";
|
import { standardVaultTemplates, VaultTemplate } from "./vaulttemplate.ts";
|
||||||
import { ALL_STATS } from "./datatypes.ts";
|
import { ALL_STATS } from "./datatypes.ts";
|
||||||
import {
|
import {
|
||||||
BreakableBlockPickup, ExperiencePickupCallbacks,
|
BreakableBlockPickup,
|
||||||
|
ExperiencePickupCallbacks,
|
||||||
LadderPickup,
|
LadderPickup,
|
||||||
LockPickup, StatPickupCallbacks,
|
LockPickup,
|
||||||
|
StatPickupCallbacks,
|
||||||
ThrallItemPickup,
|
ThrallItemPickup,
|
||||||
ThrallPickup,
|
ThrallPickup,
|
||||||
} from "./pickups.ts";
|
} from "./pickups.ts";
|
||||||
@ -278,21 +280,27 @@ function carveVault(knife: Knife, room: Rect, vaultTemplate: VaultTemplate) {
|
|||||||
if (!(a.contains(xy) || b.contains(xy))) {
|
if (!(a.contains(xy) || b.contains(xy))) {
|
||||||
stat = vaultTemplate.stats.secondary;
|
stat = vaultTemplate.stats.secondary;
|
||||||
}
|
}
|
||||||
knife.map.get(xy).pickup = new BreakableBlockPickup(new StatPickupCallbacks(stat));
|
knife.map.get(xy).pickup = new BreakableBlockPickup(
|
||||||
|
new StatPickupCallbacks(stat),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let dy = 0; dy < c.size.h; dy++) {
|
for (let dy = 0; dy < c.size.h; dy++) {
|
||||||
for (let dx = 0; dx < c.size.w; dx++) {
|
for (let dx = 0; dx < c.size.w; dx++) {
|
||||||
let xy = c.top.offset(new Point(dx, dy));
|
let xy = c.top.offset(new Point(dx, dy));
|
||||||
knife.map.get(xy).pickup = new BreakableBlockPickup(new StatPickupCallbacks(vaultTemplate.stats.primary));
|
knife.map.get(xy).pickup = new BreakableBlockPickup(
|
||||||
|
new StatPickupCallbacks(vaultTemplate.stats.primary),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let dy = 0; dy < d.size.h; dy++) {
|
for (let dy = 0; dy < d.size.h; dy++) {
|
||||||
for (let dx = 0; dx < d.size.w; dx++) {
|
for (let dx = 0; dx < d.size.w; dx++) {
|
||||||
let xy = d.top.offset(new Point(dx, dy));
|
let xy = d.top.offset(new Point(dx, dy));
|
||||||
knife.map.get(xy).pickup = new BreakableBlockPickup(new StatPickupCallbacks(vaultTemplate.stats.primary));
|
knife.map.get(xy).pickup = new BreakableBlockPickup(
|
||||||
|
new StatPickupCallbacks(vaultTemplate.stats.primary),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,10 +402,18 @@ function carveRoom(knife: Knife, room: Rect, label?: string) {
|
|||||||
new Point(room.size.w - dx - 1, room.size.h - dy - 1),
|
new Point(room.size.w - dx - 1, room.size.h - dy - 1),
|
||||||
);
|
);
|
||||||
let stat = choose(ALL_STATS);
|
let stat = choose(ALL_STATS);
|
||||||
knife.map.get(xy0).pickup = new BreakableBlockPickup(new StatPickupCallbacks(stat));
|
knife.map.get(xy0).pickup = new BreakableBlockPickup(
|
||||||
knife.map.get(xy1).pickup = new BreakableBlockPickup(new StatPickupCallbacks(stat));
|
new StatPickupCallbacks(stat),
|
||||||
knife.map.get(xy2).pickup = new BreakableBlockPickup(new StatPickupCallbacks(stat));
|
);
|
||||||
knife.map.get(xy3).pickup = new BreakableBlockPickup(new StatPickupCallbacks(stat));
|
knife.map.get(xy1).pickup = new BreakableBlockPickup(
|
||||||
|
new StatPickupCallbacks(stat),
|
||||||
|
);
|
||||||
|
knife.map.get(xy2).pickup = new BreakableBlockPickup(
|
||||||
|
new StatPickupCallbacks(stat),
|
||||||
|
);
|
||||||
|
knife.map.get(xy3).pickup = new BreakableBlockPickup(
|
||||||
|
new StatPickupCallbacks(stat),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,17 +62,17 @@ export class LockPickup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update() { }
|
update() {}
|
||||||
|
|
||||||
onClick(cell: CellView): boolean {
|
onClick(cell: CellView): boolean {
|
||||||
getCheckModal().show(this.check, () => (cell.pickup = null));
|
getCheckModal().show(this.check, () => (cell.pickup = null));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSqueeze() { }
|
onSqueeze() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const RECOVERY_PER_TICK: number = 0.10;
|
const RECOVERY_PER_TICK: number = 0.1;
|
||||||
export class BreakableBlockPickup {
|
export class BreakableBlockPickup {
|
||||||
callbacks: StatPickupCallbacks | ExperiencePickupCallbacks;
|
callbacks: StatPickupCallbacks | ExperiencePickupCallbacks;
|
||||||
breakProgress: number;
|
breakProgress: number;
|
||||||
@ -133,21 +133,29 @@ export class BreakableBlockPickup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSqueeze(_cellData: CellView) {
|
onSqueeze(_cellData: CellView) {
|
||||||
this.breakProgress = Math.min(this.breakProgress + 0.02 + RECOVERY_PER_TICK, 1.0);
|
this.breakProgress = Math.min(
|
||||||
|
this.breakProgress + 0.02 + RECOVERY_PER_TICK,
|
||||||
|
1.0,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class StatPickupCallbacks {
|
export class StatPickupCallbacks {
|
||||||
#stat: Stat
|
#stat: Stat;
|
||||||
|
|
||||||
constructor(stat: Stat) { this.#stat = stat; }
|
constructor(stat: Stat) {
|
||||||
|
this.#stat = stat;
|
||||||
|
}
|
||||||
|
|
||||||
obtain() {
|
obtain() {
|
||||||
getPlayerProgress().add(this.#stat, 1);
|
getPlayerProgress().add(this.#stat, 1);
|
||||||
getPlayerProgress().purloinItem();
|
getPlayerProgress().purloinItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
draw(at: Point, options: {xScale?: number, yScale?: number, angle?: number}) {
|
draw(
|
||||||
|
at: Point,
|
||||||
|
options: { xScale?: number; yScale?: number; angle?: number },
|
||||||
|
) {
|
||||||
let statIndex = ALL_STATS.indexOf(this.#stat);
|
let statIndex = ALL_STATS.indexOf(this.#stat);
|
||||||
if (statIndex == -1) {
|
if (statIndex == -1) {
|
||||||
return;
|
return;
|
||||||
@ -158,14 +166,17 @@ export class StatPickupCallbacks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class ExperiencePickupCallbacks {
|
export class ExperiencePickupCallbacks {
|
||||||
constructor() { }
|
constructor() {}
|
||||||
|
|
||||||
obtain() {
|
obtain() {
|
||||||
getPlayerProgress().addExperience(250);
|
getPlayerProgress().addExperience(250);
|
||||||
getPlayerProgress().purloinItem();
|
getPlayerProgress().purloinItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
draw(at: Point, options: {xScale?: number, yScale?: number, angle?: number}) {
|
draw(
|
||||||
|
at: Point,
|
||||||
|
options: { xScale?: number; yScale?: number; angle?: number },
|
||||||
|
) {
|
||||||
D.drawSprite(sprResourcePickup, at, 0, options);
|
D.drawSprite(sprResourcePickup, at, 0, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,7 +210,7 @@ export class LadderPickup {
|
|||||||
}
|
}
|
||||||
drawInAir() {}
|
drawInAir() {}
|
||||||
|
|
||||||
update() { }
|
update() {}
|
||||||
|
|
||||||
onClick(): boolean {
|
onClick(): boolean {
|
||||||
getPlayerProgress().addBlood(1000);
|
getPlayerProgress().addBlood(1000);
|
||||||
@ -207,7 +218,7 @@ export class LadderPickup {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSqueeze() { }
|
onSqueeze() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ThrallPickup {
|
export class ThrallPickup {
|
||||||
@ -246,7 +257,7 @@ export class ThrallPickup {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
update() { }
|
update() {}
|
||||||
|
|
||||||
onClick(cell: CellView): boolean {
|
onClick(cell: CellView): boolean {
|
||||||
let data = getThralls().get(this.thrall);
|
let data = getThralls().get(this.thrall);
|
||||||
@ -257,7 +268,7 @@ export class ThrallPickup {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSqueeze() { }
|
onSqueeze() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ThrallPosterPickup {
|
export class ThrallPosterPickup {
|
||||||
@ -296,7 +307,7 @@ export class ThrallPosterPickup {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
update() { }
|
update() {}
|
||||||
|
|
||||||
onClick(cell: CellView): boolean {
|
onClick(cell: CellView): boolean {
|
||||||
let data = getThralls().get(this.thrall);
|
let data = getThralls().get(this.thrall);
|
||||||
@ -304,7 +315,7 @@ export class ThrallPosterPickup {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSqueeze() { }
|
onSqueeze() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ThrallRecruitedPickup {
|
export class ThrallRecruitedPickup {
|
||||||
@ -359,7 +370,7 @@ export class ThrallRecruitedPickup {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
update() { }
|
update() {}
|
||||||
|
|
||||||
onClick(_cell: CellView): boolean {
|
onClick(_cell: CellView): boolean {
|
||||||
this.spokenTo = true;
|
this.spokenTo = true;
|
||||||
@ -408,7 +419,7 @@ export class ThrallRecruitedPickup {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSqueeze() { }
|
onSqueeze() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ThrallCollectionPlatePickup {
|
export class ThrallCollectionPlatePickup {
|
||||||
@ -476,7 +487,7 @@ export class ThrallCollectionPlatePickup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update() { }
|
update() {}
|
||||||
|
|
||||||
onClick(_cell: CellView): boolean {
|
onClick(_cell: CellView): boolean {
|
||||||
let lifeStage = getPlayerProgress().getThrallLifeStage(this.thrall);
|
let lifeStage = getPlayerProgress().getThrallLifeStage(this.thrall);
|
||||||
@ -536,7 +547,7 @@ export class ThrallCollectionPlatePickup {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSqueeze() { }
|
onSqueeze() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ThrallItemPickup {
|
export class ThrallItemPickup {
|
||||||
@ -575,7 +586,7 @@ export class ThrallItemPickup {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
update() { }
|
update() {}
|
||||||
|
|
||||||
onClick(cell: CellView): boolean {
|
onClick(cell: CellView): boolean {
|
||||||
let data = getThralls().get(this.thrall);
|
let data = getThralls().get(this.thrall);
|
||||||
@ -592,5 +603,5 @@ export class ThrallItemPickup {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSqueeze() { }
|
onSqueeze() {}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ export class SkillsModal {
|
|||||||
onClick: () => {
|
onClick: () => {
|
||||||
this.#skillSelection = skill;
|
this.#skillSelection = skill;
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
y += 16;
|
y += 16;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user