diff --git a/public/js/Overlay/HUD.js b/public/js/Overlay/HUD.js index c2bbbf9..6e8e289 100644 --- a/public/js/Overlay/HUD.js +++ b/public/js/Overlay/HUD.js @@ -6,16 +6,15 @@ export class HUD extends Overlay { constructor(width, height) { super(width, height); - this.numItems = 0; - this.items = new Set() + this.light = new THREE.PointLight( 0xff0000, 1, 100 ); this.light.position.set( 10, 10, 50 ); - this.light2 = new THREE.DirectionalLight(0xFFFFFF, 3.0); + // this.light = new THREE.DirectionalLight(0xFFFFFF, 1.0); - this.light2.target.position.set(15, 6, -20); - //this.light2.castShadow = true; - this.light2.position.set(-20, 50, 10); + // this.light.target.position.set(0, 0, -20); + // this.light.castShadow = true; + //this.light.position.set(-20, 50, 10); //create crosshair torus---------------------------------------------------- const geometry = new THREE.TorusGeometry(0.5,0.1,9,15,Math.PI*2); @@ -30,7 +29,6 @@ export class HUD extends Overlay { this.scene.add(this.light); - this.scene.add(this.light2); @@ -54,35 +52,12 @@ export class HUD extends Overlay { - add(name,object) + addObject(object) { - object.object.name = name; - - object.object.rotateX(Math.PI/4); - object.object.rotateY(Math.PI/4); - object.object.rotateZ(Math.PI/4); - object.object.position.set(20, 9 -(3*this.numItems), -20); - this.scene.add(object.object); - - this.numItems += 1; - this.items.add(name); + this.scene.add(object); } - remove(name) - { - var selectedObject = this.scene.getObjectByName(name); - console.log("removing from hud"); - console.log(selectedObject); - this.scene.remove( selectedObject); - this.items.delete(name); - - } - - hasItem(name) - { - return this.items.has(name); - } diff --git a/public/js/SceneSubjects/objects/BedroomDrawer.js b/public/js/SceneSubjects/objects/BedroomDrawer.js index e0cd094..fcc18d1 100644 --- a/public/js/SceneSubjects/objects/BedroomDrawer.js +++ b/public/js/SceneSubjects/objects/BedroomDrawer.js @@ -5,7 +5,6 @@ import { keyboardManager } from '../../managers/KeyboardManager.js'; import { loadingManager, mainChar } from '../../managers/SceneManager.js'; import { gameOverlay } from '../../Overlay/GameOverlay.js'; import { subtitleManager } from '../../managers/SubtitleManager.js'; -import { Key } from './Key.js'; export class BedroomDrawer extends THREE.Object3D { @@ -38,22 +37,6 @@ export class BedroomDrawer extends THREE.Object3D { this.open = false; //keeps track if the drawer is openend - //add key to object - //set key transforms-------------------------------------------------------------------------- - this.key = new Key(); - this.key.object.scale.x = 0.5; - this.key.object.scale.y = 0.5; - this.key.object.scale.z = 0.5; - // key.object.position.set(20.15, 1.8, 27.5 ); - this.key.object.name = "key"; - - this.object.add(this.key.object); - - //---------------------------------------------------------------------------------------- - - - - var gltf = loader.load('bedroomDrawer.glb', (gltf) => { //console.log("loaded drawer"); gltf.scene.traverse(c => { @@ -62,19 +45,16 @@ export class BedroomDrawer extends THREE.Object3D { }); // //scale drawer - - var obj_gltf = new THREE.Object3D(); - - obj_gltf.scale.x = 8; - obj_gltf.scale.y = 8; - obj_gltf.scale.z = 8; + this.object.scale.x = 8; + this.object.scale.y = 8; + this.object.scale.z = 8; //move drawer - obj_gltf.position.set(0, 0,0); + this.object.position.set(20.15, 1.6, 27); - obj_gltf.add(gltf.scene); - this.object.add(obj_gltf); + + this.object.add(gltf.scene); }); } @@ -167,9 +147,7 @@ export class BedroomDrawer extends THREE.Object3D { this.startSubtitles = true; //add that he found the key - - - // hud.add("bedroomDrawer",key.object); + this.keyFound = true; //make sure vicinity can no longer be checked: do not show overlay anymore this.doCheckVicinity = false; gameOverlay.hideOverlay(); @@ -185,7 +163,6 @@ export class BedroomDrawer extends THREE.Object3D { if (this.open == true) { if (this.object.position.z > 29.5) { //stop moving this.open = false; - this.keyFound = true; } else { this.object.position.z += 0.1; //move to the left diff --git a/public/js/SceneSubjects/objects/Door.js b/public/js/SceneSubjects/objects/Door.js index c5cbf62..02c1980 100644 --- a/public/js/SceneSubjects/objects/Door.js +++ b/public/js/SceneSubjects/objects/Door.js @@ -135,11 +135,11 @@ export class Door extends THREE.Object3D { update(time) { //just to show the div - +/* if (this.doCheckVicinity) { - this.checkVicinity = this.checkCharacterVicinity(); + //this.checkVicinity = this.checkCharacterVicinity(); } - +*/ if (this.showLockedSubtitles) { this.showSubtitlesLocked(80); @@ -163,10 +163,11 @@ export class Door extends THREE.Object3D { } } + + var checkVicinity = this.checkCharacterVicinity(); if (keyboardManager.wasPressed('E')) { - console.log("e pressed by door"); - if (this.checkVicinity) { - console.log("vicinity by door"); + + if (checkVicinity) { //if character is in vicinity of door, then they can open door if (this.allowInteraction) { this.playDoorSound = true; @@ -180,18 +181,8 @@ export class Door extends THREE.Object3D { this.open = true; //checks how long the animation was playing for this.animationCounter = 0; - - console.log("door allow interaction true. now set to false"); - - /* WhatsApp - - //Suraksha: HIDE KEY IMAGE IN OVERLAY!!! KAMERON!!! (double blue tick) - //Kameron: THATSSSS MA NAME!!! (single tick) - - */ - - this.allowInteraction = false; + //HIDE KEY IMAGE IN OVERLAY!!! KAMERON!!! } else{ @@ -239,7 +230,6 @@ export class Door extends THREE.Object3D { return false; } - return3DObject() { return this.object; } diff --git a/public/js/SceneSubjects/objects/Key.js b/public/js/SceneSubjects/objects/Key.js index ba3c81b..f097e9e 100644 --- a/public/js/SceneSubjects/objects/Key.js +++ b/public/js/SceneSubjects/objects/Key.js @@ -32,8 +32,14 @@ export class Key extends THREE.Object3D { }); + this.object.scale.x = 0.4; + this.object.scale.y = 0.4; + this.object.scale.z = 0.4; + + //set object's position + //this.object.position.set(-12, 9, 64);; + this.object.position.set(20.15, 7.6, 37 );//Perfect - // this.object.position.set(20.15, 7.6, 37 );//Perfect this.object.add(gltf.scene); }); @@ -42,6 +48,19 @@ export class Key extends THREE.Object3D { update(time) { + if (bedroomDrawer.isKeyFound()) { + // console.log("Bedroom Drawer is Opened"); + if (this.open == false) { + // console.log("Key anim not played"); + if (this.object.position.z > 39) { //stop moving + this.open = true; + } + else { + // console.log("Key anim playing"); + this.object.position.z += 0.5; //move to the left + } + } + } if (this.open) { diff --git a/public/js/managers/SceneManager.js b/public/js/managers/SceneManager.js index cc3e58a..e2639ac 100644 --- a/public/js/managers/SceneManager.js +++ b/public/js/managers/SceneManager.js @@ -111,9 +111,6 @@ var letterI = new LetterI(); var key = new Key(); - - - //pre-loader export var loadingManager; @@ -388,20 +385,17 @@ export class SceneManager { //bedroom managers[1].register(bedroomPainting); - + managers[1].register(bedroomDrawer); + managers[1].register(hammer); managers[1].register(pin); managers[1].register(lockCupboard); managers[1].register(cupBoardDoorR); managers[1].register(letterI); - + managers[1].register(key); managers[1].register(flashlight); - bedroomDrawer.object.position.set(20.15, 1.8, 27.5 ); - managers[1].register(bedroomDrawer); - //------------------------------------------------------------------------ - managers[2].register("footstep", "assets/footstep.mpeg"); managers[2].register("door_open", "assets/door_open.mpeg"); managers[2].entities["door_open"].setLoop(false); @@ -505,7 +499,7 @@ export class SceneManager { this.audioActive = true; this.managers[2].audioListener.context.resume(); - this.managers[2].entities["background"].play(); + // this.managers[2].entities["background"].play(); } //make intro screen visible @@ -602,38 +596,9 @@ export class SceneManager { // } } else if (this.game_state == this.GAME_RUN) { - //hud elements - if (this.hud.hasItem('key') ) - { - console.log() - } - - - if (this.hud.hasItem('key') == false && bedroomDrawer.keyFound && testdoor.open == false) - { - console.log("key adde"); - var selectedObject = bedroomDrawer.object.getObjectByName('key'); - console.log(selectedObject); - bedroomDrawer.object.remove( selectedObject); - - - this.hud.add("key",new Key()); - testdoor.setAllowInteraction(true); - - - } - else if (this.hud.hasItem('key') && testdoor.open) - { - console.log("key removed"); - this.hud.remove('key'); - - - } - // - //door open sounds--------------------------------------------------------------------------- - if (this.hud.hasItem('key')) { + if (key.checkKeyTaken()) { testdoor.doCheckVicinity = true; if (keyboardManager.wasPressed('E') && testdoor.playDoorSound) { if (this.managers[2].entities["door_open"].isPlaying == false) { @@ -722,8 +687,9 @@ export class SceneManager { } this.unpause(); }); + } + else if (this.game_state == this.GAME_PAUSE) { - mainMenu.addEventListener('click', () => { //make menu not visible for (let i = 0; i < menu.length; i++) { @@ -732,13 +698,6 @@ export class SceneManager { this.game_state = this.GAME_MENU; }); - - - this.renderPauseMenu(); - } - else if (this.game_state == this.GAME_PAUSE) { - - if (keyboardManager.keyDownQueue[0] == 'P') { @@ -753,6 +712,8 @@ export class SceneManager { } + this.renderPauseMenu(); + } } diff --git a/public/models/3DObjects/bedroomDrawer.glb b/public/models/3DObjects/bedroomDrawer.glb index f491d51..7664e0b 100644 Binary files a/public/models/3DObjects/bedroomDrawer.glb and b/public/models/3DObjects/bedroomDrawer.glb differ diff --git a/public/models/3DObjects/bedroomDrawerfirst.glb b/public/models/3DObjects/bedroomDrawerfirst.glb deleted file mode 100644 index 7664e0b..0000000 Binary files a/public/models/3DObjects/bedroomDrawerfirst.glb and /dev/null differ