Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Hud overlay" #74

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 7 additions & 32 deletions public/js/Overlay/HUD.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -30,7 +29,6 @@ export class HUD extends Overlay {


this.scene.add(this.light);
this.scene.add(this.light2);



Expand All @@ -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);
}



Expand Down
37 changes: 7 additions & 30 deletions public/js/SceneSubjects/objects/BedroomDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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 => {
Expand All @@ -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);
});

}
Expand Down Expand Up @@ -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();
Expand All @@ -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
Expand Down
26 changes: 8 additions & 18 deletions public/js/SceneSubjects/objects/Door.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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{
Expand Down Expand Up @@ -239,7 +230,6 @@ export class Door extends THREE.Object3D {
return false;
}


return3DObject() {
return this.object;
}
Expand Down
21 changes: 20 additions & 1 deletion public/js/SceneSubjects/objects/Key.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand All @@ -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) {
Expand Down
57 changes: 9 additions & 48 deletions public/js/managers/SceneManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ var letterI = new LetterI();
var key = new Key();





//pre-loader
export var loadingManager;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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++) {
Expand All @@ -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')
{

Expand All @@ -753,6 +712,8 @@ export class SceneManager {
}


this.renderPauseMenu();

}
}

Expand Down
Binary file modified public/models/3DObjects/bedroomDrawer.glb
Binary file not shown.
Binary file removed public/models/3DObjects/bedroomDrawerfirst.glb
Binary file not shown.