|
@@ -30,6 +30,8 @@ import { buildCanvasText } from './library/canvastext.js'
|
|
|
import { hideGameStatusUI, updateGameStatusUI } from './ui/gamestatusui.js'
|
|
|
import { gameOverUI, showGameOverUI } from './ui/gameoverui.js'
|
|
|
import { closeMarketUI, marketUI, openMarketUI } from './ui/marketui.js'
|
|
|
+import { creditsUI, hideCreditsUI } from './ui/creditsui.js'
|
|
|
+import { hideOptionsUI, optionsUI } from './ui/optionsui.js'
|
|
|
|
|
|
export const GAME_SAVE_KEY = "spookonomics-v1"
|
|
|
const raycast = new THREE.Raycaster()
|
|
@@ -111,7 +113,7 @@ async function beginBrew(game, stageData) {
|
|
|
|
|
|
stageData.cauldronUniforms.uBlendTime.value = 0.0
|
|
|
setTimeout(() => {
|
|
|
- stageData.soundEffects['audio/bubbling.mp3'].volume(0.5)
|
|
|
+
|
|
|
stageData.soundEffects['audio/bubbling.mp3'].play()
|
|
|
stageData.bubbleParticles.visible = true
|
|
|
gsap.to(stageData.cauldronUniforms.uBlendTime, {
|
|
@@ -131,7 +133,10 @@ async function beginBrew(game, stageData) {
|
|
|
stageData.selectedIngredients = []
|
|
|
|
|
|
stageData.bottle1.position.set(0, -1.5, 0)
|
|
|
- stageData.soundEffects['audio/bubbling.mp3'].fade(1, 0, 300)
|
|
|
+ stageData.soundEffects['audio/bubbling.mp3'].fade(1, 0, 300).on('fade', () => {
|
|
|
+ stageData.soundEffects['audio/bubbling.mp3'].stop()
|
|
|
+ stageData.soundEffects['audio/bubbling.mp3'].volume(0.5)
|
|
|
+ })
|
|
|
stageData.brewWitch.stir = false
|
|
|
stageData.brewWitch.bounce = false
|
|
|
stageData.spoon.visible = false
|
|
@@ -294,6 +299,8 @@ export function clearSaveData(stageData) {
|
|
|
|
|
|
stageData.ingredientInventory = ["mushroom", "mushroom", "pumpkin", "tomato", "tomato", "lettuce", "lettuce"]
|
|
|
localStorage.setItem(`${GAME_SAVE_KEY}-ingredient-inventory`, JSON.stringify(stageData.ingredientInventory))
|
|
|
+
|
|
|
+ updateGameStatusUI(game, stageData)
|
|
|
|
|
|
}
|
|
|
|
|
@@ -331,7 +338,7 @@ export function loadSaveData(stageData) {
|
|
|
let ingredientInventoryString = localStorage.getItem(`${GAME_SAVE_KEY}-ingredient-inventory`)
|
|
|
if (!ingredientInventoryString) {
|
|
|
localStorage.setItem(`${GAME_SAVE_KEY}-ingredient-inventory`, JSON.stringify([]))
|
|
|
- stageData.ingredientInventory = []
|
|
|
+ stageData.ingredientInventory = ["mushroom", "mushroom", "pumpkin", "tomato", "tomato", "lettuce", "lettuce"]
|
|
|
} else {
|
|
|
stageData.ingredientInventory = JSON.parse(ingredientInventoryString)
|
|
|
stageData.ingredientInventory.sort()
|
|
@@ -412,7 +419,8 @@ export async function init(inGame) {
|
|
|
|
|
|
soundEffects['audio/doorClose_4.ogg'].volume(0.5)
|
|
|
soundEffects['audio/doorOpen_1.ogg'].volume(0.5)
|
|
|
- stageData.soundEffects['audio/store-entrance-bell.ogg'].volume(0.5)
|
|
|
+ soundEffects['audio/bubbling.mp3'].volume(0.5)
|
|
|
+ soundEffects['audio/store-entrance-bell.ogg'].volume(0.5)
|
|
|
|
|
|
let levelLoader = new LevelLoader(game)
|
|
|
|
|
@@ -481,14 +489,17 @@ export async function init(inGame) {
|
|
|
candleLit.visible = false
|
|
|
game.scene.add(candleLit)
|
|
|
|
|
|
- stageData.cauldronUniforms = {
|
|
|
- uTime: { value: 0 },
|
|
|
- uPixelRatio: { value: Math.min(window.devicePixelRatio, 2) },
|
|
|
- uBlendTime: { value: 0 },
|
|
|
- uPotionColor: { value: new THREE.Vector3(0, 0.8, 0.2) },
|
|
|
- uNextPotionColor: { value: new THREE.Vector3(0, 0.8, 0.2) },
|
|
|
- uTransparency: { value: 0.8 }
|
|
|
- }
|
|
|
+
|
|
|
+ stageData.cauldronUniforms = THREE.UniformsUtils.merge([
|
|
|
+ THREE.UniformsLib["common"],
|
|
|
+ THREE.UniformsLib["lights"]
|
|
|
+ ])
|
|
|
+ stageData.cauldronUniforms.uTime = { value: 0 },
|
|
|
+ stageData.cauldronUniforms.uPixelRatio = { value: Math.min(window.devicePixelRatio, 2) },
|
|
|
+ stageData.cauldronUniforms.uBlendTime = { value: 0 },
|
|
|
+ stageData.cauldronUniforms.uPotionColor = { value: new THREE.Vector3(0, 0.8, 0.2) },
|
|
|
+ stageData.cauldronUniforms.uNextPotionColor = { value: new THREE.Vector3(0, 0.8, 0.2) },
|
|
|
+ stageData.cauldronUniforms.uTransparency = { value: 0.8 }
|
|
|
|
|
|
stageData.cauldron = await loadGltf(game, 'models/simple_cauldron.gltf.glb')
|
|
|
const cauldronBell = stageData.cauldron.getObjectByName("Sphere015")
|
|
@@ -501,6 +512,7 @@ export async function init(inGame) {
|
|
|
transparent: true,
|
|
|
depthWrite: false,
|
|
|
side: THREE.DoubleSide,
|
|
|
+ lights: true,
|
|
|
})
|
|
|
cauldronTop.material = cauldronTopMaterial
|
|
|
|
|
@@ -810,6 +822,8 @@ export async function init(inGame) {
|
|
|
|
|
|
|
|
|
mainMenuUI(game, stageData)
|
|
|
+ optionsUI(game, stageData)
|
|
|
+ creditsUI(game, stageData)
|
|
|
navigationUI(game, stageData)
|
|
|
brewUI(game, stageData)
|
|
|
shopUI(game, stageData)
|
|
@@ -824,6 +838,14 @@ export async function init(inGame) {
|
|
|
stageData.buyIngredients = () => { buyIngredients(game, stageData)}
|
|
|
|
|
|
|
|
|
+ stageData.adjustMasterVolume = (volume) => {
|
|
|
+ Howler.volume(volume / 100)
|
|
|
+ }
|
|
|
+
|
|
|
+ stageData.adjustMusicVolume = (volume) => {
|
|
|
+ stageData.musicLoop.volume(volume / 100)
|
|
|
+ }
|
|
|
+
|
|
|
///////////
|
|
|
// DEBUG //
|
|
|
///////////
|
|
@@ -1508,11 +1530,14 @@ export function onKeyPress(code) {
|
|
|
}
|
|
|
|
|
|
export function returnToMainMenu(game, stageData) {
|
|
|
+ Howler.stop()
|
|
|
closeBrewUI(game, stageData)
|
|
|
closeShopUI(game, stageData)
|
|
|
hideNavigationUI(game, stageData)
|
|
|
openMainMenuUI(game, stageData)
|
|
|
hideGameStatusUI(game, stageData)
|
|
|
+ hideOptionsUI(game, stageData)
|
|
|
+ hideCreditsUI(game, stageData)
|
|
|
stageData.currentRoom = ROOM_BREW
|
|
|
game.camera.position.copy(stageData.cameraPositions[3].camera)
|
|
|
game.lookAtFocus = stageData.cameraPositions[3].focus.clone()
|