Start implementing lair

This commit is contained in:
2021-11-10 20:55:21 +01:00
parent 8f214e93bf
commit a048e3615c
30 changed files with 238 additions and 77 deletions

View File

@@ -25,6 +25,13 @@ export default class Game {
this.output.say(string);
}
async tell(lines, time) {
for (let line of lines) {
this.print(line);
await this.wait(time);
}
}
init(data) {
this.rooms = data.rooms.map((room) => {
room.context = this;

View File

@@ -10,6 +10,7 @@ export default class Output {
}
say(string) {
if (string === "") return;
this.sound.play(`assets/scroll.wav`);
const node = document.createElement("p");
string.split("\n").forEach((line) => {
@@ -18,7 +19,7 @@ export default class Output {
// this.tts.speak(line, false);
});
this.history.appendChild(node);
this.tts.speak(string);
// this.tts.speak(string);
}
play(file) {

View File

@@ -9,6 +9,8 @@ export default class Sound {
this.ambienceVolume = 1;
this.musicVolume = 1;
this.sfxVolume = 1;
this.previousAmbience = "";
this.previousMusic = "";
}
play(file) {
@@ -18,6 +20,7 @@ export default class Sound {
}
async setAmbience(file) {
if (file === this.previousAmbience) return;
if (this.ambience) {
const previousAmbience = this.ambience;
this.ambience = null;
@@ -25,6 +28,7 @@ export default class Sound {
setTimeout(() => previousAmbience.destroy(), 6000);
}
if (!file) return;
this.previousAmbience = file;
this.ambience = this.res.stream(file, 0);
this.ambience.setVolume(this.ambienceVolume);
this.ambience.play();
@@ -33,12 +37,14 @@ export default class Sound {
}
setMusic(file) {
if (file === this.previousMusic) return;
if (this.music) {
const previousMusic = this.music;
setTimeout(() => previousMusic.fadeOut(2), 500);
setTimeout(() => previousMusic.destroy(), 2000);
}
if (!file) return;
this.previousMusic = file;
this.music = this.res.stream(file, 1);
this.music.setVolume(this.musicVolume);
this.music.play();

View File

@@ -1,9 +1,17 @@
import Stone from './stone';
import Torch from './torch';
import Cup from './cup';
import Statue1 from './statue1';
import statue2 from './statue2';
import statue3 from './statue3';
import statue4 from './statue4';
export default [
Stone,
Torch,
Cup
Cup,
Statue1,
statue2,
statue3,
statue4
]

14
src/game/items/statue1.js Normal file
View File

@@ -0,0 +1,14 @@
import ItemBuilder from '../../engine/builders/item';
export default new ItemBuilder()
.withID("statue1")
.withName("a huge ant statue")
.withDescription(
`Before you stands a big ant statue. One of its six legs is extended outwards, attached to a round device.`
)
.isTakeable(false)
.isUsable(true)
.withUseCallback(async function (context) {
context.print(`You press the button on the round device attached to the statue's arm.`)
})
.create();

14
src/game/items/statue2.js Normal file
View File

@@ -0,0 +1,14 @@
import ItemBuilder from '../../engine/builders/item';
export default new ItemBuilder()
.withID("statue2")
.withName("a huge ant statue")
.withDescription(
`Before you stands a big ant statue. Two of its six legs is extended outwards, attached to a rectangular device.`
)
.isTakeable(false)
.isUsable(true)
.withUseCallback(async function (context) {
context.print(`You press the button on the rectangular device attached to the statue's arm.`)
})
.create();

14
src/game/items/statue3.js Normal file
View File

@@ -0,0 +1,14 @@
import ItemBuilder from '../../engine/builders/item';
export default new ItemBuilder()
.withID("statue3")
.withName("a huge ant statue")
.withDescription(
`Before you stands a big ant statue. Three of its six legs are extended outwards, attached to a round stone tablet.`
)
.isTakeable(false)
.isUsable(true)
.withUseCallback(async function (context) {
context.print(`You examine the stone tablet in the statue's hands. There appear to be symbols on it which you can make out.`);
})
.create();

14
src/game/items/statue4.js Normal file
View File

@@ -0,0 +1,14 @@
import ItemBuilder from '../../engine/builders/item';
export default new ItemBuilder()
.withID("statue4")
.withName("a huge ant statue")
.withDescription(
`Before you is a big statue of an ant, in the process of falling over. All of its legs are bent at the joints.`
)
.isTakeable(false)
.isUsable(true)
.withUseCallback(async function (context) {
context.print(`You can't seem to figure out what to do with this yet.`)
})
.create();

View File

@@ -1,9 +1,5 @@
import Start from './start';
import Tunnel1 from './tunnel1';
import tunnel2 from './tunnel2';
import Lair from './lair';
export default [
Start,
Tunnel1,
tunnel2
...Lair
];

View File

@@ -0,0 +1,20 @@
import RoomBuilder from "../../../engine/builders/room";
export default new RoomBuilder()
.withID("central1")
.withTitle("A large spherical chamber")
.withFirstDescription(
`You exit the tunnel into a large, spherical chamber.
There are many more threads across the walls and ceiling here, the glow enveloping you fully in its unnatural light.
The chamber appears to be large, able to fit hundreds of you inside.
To the northeast, northwest, southeast and southwest you notice large statues representing ants. Threads seem to lead right into them.`
)
.withDescription(
`A large, spherical chamber. Glowing threads criss-cross the walls and ceiling. Around you, statues of ants.`
)
.withExit("northwest", "statue1")
.withExit("northeast", "statue2")
.withExit("southwest", "statue3")
.withExit("southeast", "statue4")
.withExit("south", "tunnel1")
.create();

View File

@@ -0,0 +1,17 @@
import Start from './start';
import Tunnel1 from './tunnel1';
import central1 from './central1';
import statue1 from './statue1';
import statue2 from './statue2';
import statue3 from './statue3';
import statue4 from '../../items/statue4';
export default [
Start,
Tunnel1,
central1,
statue1,
statue2,
statue3,
statue4
];

View File

@@ -0,0 +1,35 @@
import RoomBuilder from '../../../engine/builders/room';
export default new RoomBuilder()
.withID("start")
.withTitle("A small spherical alcove")
.withFirstDescription(
`You find yourself in a small, spherical alcove. It feels cold and dark, save from a dim glow which seems to be eluminating the area from the north.
The surface appears to be unnaturally smooth, as if melted away using acidic means. It's warm to the touch.`
)
.withDescription(
`A spherical alcove. The smooth surface appears to be melted away using acidic means. There's a dim glow shining in from the north.`
)
.withExit("north", "tunnel1")
.withEnterCallback(async function(context) {
if (context.state.get("start.awoken")) return;
const { output, wait } = context;
context.enableCommandInput(false);
await context.tell([
"You slowly wake up.",
"you're not sure if you were ever conscious about waking up, but right now, you're clearly aware that you were previously asleep.",
"In fact, a lot of your thoughts seem foreign to you.",
"You're not sure how to feel about this.",
"God the headache...",
"OK, time to think about this.",
"Huh, something else you never did before.",
"Where are you?",
"You reach up and touch your head.",
"OK, that seems to be in order. Your antennae are still there, your mouth parts seem in tact...",
"Hmm. All this is strange.",
"No use sitting around. You get up and slowly examine your surroundings."
], 3000);
context.enableCommandInput(true);
context.state.set("start.awoken", true);
})
.create();

View File

@@ -0,0 +1,15 @@
import RoomBuilder from "../../../engine/builders/room";
export default new RoomBuilder()
.withID("statue1")
.withTitle("The northwestern part of the central chamber")
.withFirstDescription(
`You walk over to the northwestern part of the central chamber.
It is almost entirely taken up by a huge ant statue. One of its six legs are extended outwards, attached to which is a small, round device.`
)
.withDescription(
``
)
.withExit("southeast", "central1")
.withItem("statue1")
.create();

View File

@@ -0,0 +1,15 @@
import RoomBuilder from "../../../engine/builders/room";
export default new RoomBuilder()
.withID("statue2")
.withTitle("The northeastern part of the central chamber")
.withFirstDescription(
`You walk over to the northeastern part of the central chamber.
It is almost entirely taken up by a huge ant statue. Two of its six legs are extended outwards, attached to which is a large, rectangular device.`
)
.withDescription(
``
)
.withExit("southwest", "central1")
.withItem("statue2")
.create();

View File

@@ -0,0 +1,15 @@
import RoomBuilder from "../../../engine/builders/room";
export default new RoomBuilder()
.withID("statue3")
.withTitle("The southwestern part of the central chamber")
.withFirstDescription(
`You walk over to the southwestern part of the central chamber.
It is almost entirely taken up by a huge ant statue. Three of its six legs are extended outwards, attached to which is a round stone tablet.`
)
.withDescription(
``
)
.withExit("northeast", "central1")
.withItem("statue3")
.create();

View File

@@ -0,0 +1,15 @@
import RoomBuilder from "../../../engine/builders/room";
export default new RoomBuilder()
.withID("statue4")
.withTitle("The southeastern part of the central chamber")
.withFirstDescription(
`You walk over to the southeastern part of the central chamber.
It is almost entirely taken up by the statue of a huge ant, which appears to be in the process of falling over. All of its six legs are slightly bent at each joint.`
)
.withDescription(
``
)
.withExit("northwest", "central1")
.withItem("statue4")
.create();

View File

@@ -0,0 +1,15 @@
import RoomBuilder from '../../../engine/builders/room';
export default new RoomBuilder()
.withID("tunnel1")
.withTitle("A long dark tunnel")
.withFirstDescription(
`You slowly make your way out of the little alcove, heading north into a smooth, tube-shaped tunnel.
You notice razor thin threads coming out of the ceiling, weaving and slithering along the length of the tunnel towards the north. Thery provide a dim glow, which must have been the light you saw before.`
)
.withDescription(
`A tube-shaped tunnel. Thin threads seem to exit the ceiling here, eminating a soft glow.`
)
.withExit("south", "start")
.withExit("north", "central1")
.create();

View File

@@ -1,33 +0,0 @@
import RoomBuilder from '../../engine/builders/room';
export default new RoomBuilder()
.withID("start")
.withTitle("The starting room")
.withFirstDescription(
`You set foot in your very first ever room.
You're not quite sure what you were supposed to expect, but it definitely wasn't this.
I mean who would expect a boring old room like this one? Ugh.
Just... make it stop. Please.`
)
.withDescription("The first room. Nothing special about it.")
.withExit("north", "tunnel_1")
.withExit("northwest", "tunnel_2")
.withEnterCallback(async function(context) {
if (context.state.get("start.awoken")) return;
const { output, wait } = context;
context.enableCommandInput(false);
output.say("You slowly wake up");
await wait(5000);
output.say("It's strange. You never used to be able to be conscious about the fact that you were waking up.");
await wait(5000);
output.say("Yet here we are.");
context.enableCommandInput(true);
context.state.set("start.awoken", true);
})
.withItem("stone")
.withItem("cup")
.withItem("torch")
.withAmbience("assets/cave1.wav")
.withMusic("assets/music1.wav")
.withImpulse("assets/Greek7EchoHall.wav")
.create();

View File

@@ -1,12 +0,0 @@
import RoomBuilder from '../../engine/builders/room';
export default new RoomBuilder()
.withID("tunnel_1")
.withTitle("A long dark tunnel")
.withFirstDescription("You first step foot in this dark loomy tunnel.")
.withDescription("The walls are wet. Everything is wet. Ugh. Why do you even.")
.withExit("south", "start")
.withAmbience("assets/windy1.wav")
.withMusic("assets/music2.wav")
.withImpulse("assets/parkingGarage.wav")
.create();

View File

@@ -1,13 +0,0 @@
import RoomBuilder from "../../engine/builders/room";
export default new RoomBuilder()
.withID("tunnel_2")
.withTitle("A long, winding tunnel")
// .withFirstDescription(
// `You step out from your hidy hole into a thin, winding tunnel. The walls and ceiling appear to get thinner and thinner, space slowly dwindling away to nothing.`
// )
.withDescription(
`A tunnel that ends in a bowl shape.`
)
.withExit("southeast", "start")
.create();