Skip to content

Commit

Permalink
Habitación día 1 por la mañana
Browse files Browse the repository at this point in the history
Falta leer correctamente el archivo de traducción
  • Loading branch information
MattCastUCM committed Jul 19, 2024
1 parent e05faa4 commit 7bcae7f
Show file tree
Hide file tree
Showing 12 changed files with 257 additions and 45 deletions.
Binary file added assets/backgrounds/bedroom/bag.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/backgrounds/bedroom/bedroomBase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/backgrounds/bedroom/bedroomChair.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions localization/day1/bedroomMorningDay1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"bag": {
"root": {
"type": "text",
"character": "player",
"next": "pickBag"
},
"pickBag": {
"type": "event",
"events": [
{ "pickBag": { } }
],
"next": "bag2"
},
"bag2": {
"type": "text",
"character": "player"
}

},

"wardrobe1": {
"root": {
"type": "text",
"character": "player"
}
},

"wardrobe2": {
"root": {
"type": "text",
"character": "player"
}
},

"pc": {
"root": {
"type": "text",
"character": "PC",
"next": "pcChoice"
},
"pcChoice": {
"type": "choice",
"choices":[
{ "next": "turnPC" },
{ "next": "leavePC" }
]
},
"turnPC": {
"type": "event",
"events": [
{ "turnPC": { } }
]
},
"leavePC": {
"type": "text",
"character": "player"
}
},

"bed": {
"root": {
"type": "text",
"character": "player"
}
}

}
28 changes: 28 additions & 0 deletions localization/es/day1/bedroomMorningDay1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"bag": {
"root": {
"text": "Creo que tengo todo preparado..."
},
"bag2": {
"text": "Sí, lo llevo todo, será mejor que coja la mochila y me marche ya."
}
},

"wardrobe1": {
"root": {
"text": "No hay nada útil dentro."
}
},

"wardrobe2": {
"root": {
"text": "En algún momento tendré que ordenar todo esto, pero ahora tengo que irme a clase."
}
},

"bed": {
"root": {
"text": "Ahora que me he conseguido levantar no debería volver a acostarme."
}
}
}
36 changes: 22 additions & 14 deletions src/managers/gameManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export default class GameManager {

// Blackboard
this.map = new Map();
this.map.set("bag", false);

this.bagPicked = "bagPicked";
this.map.set("bagPicked", false);

this.isLate = "isLate";
this.map.set(this.isLate, false);
Expand Down Expand Up @@ -223,20 +225,22 @@ export default class GameManager {
this.computerScene = this.currentScene.scene.get(computerSceneName);
this.computerScene.scene.sleep();


let sceneName = 'BedroomMorningDay1';

// Pasa a la escena inicial con los parametros text, onComplete y onCompleteDelay
let sceneName = 'TextOnlyScene';
this.changeScene(sceneName, {
// El texto de se coge del a archivo de traducciones
text: this.i18next.t("day1.start", { ns: "transitionScenes", returnObjects: true }),
onComplete: () => {
// Al llamar a onComplete, se cambiara a la escena de la alarma
this.changeScene('AlarmScene');
},
onCompleteDelay: 500
});

// let sceneName = 'BedroomDay1';
// this.changeScene(sceneName);
// let sceneName = 'TextOnlyScene';
// this.changeScene(sceneName, {
// // El texto de se coge del a archivo de traducciones
// text: this.i18next.t("day1.start", { ns: "transitionScenes", returnObjects: true }),
// onComplete: () => {
// // Al llamar a onComplete, se cambiara a la escena de la alarma
// this.changeScene('AlarmScene');
// },
// onCompleteDelay: 500
// });

this.changeScene(sceneName);
}

setUserInfo(userInfo) {
Expand All @@ -259,6 +263,8 @@ export default class GameManager {
}

switchToComputer() {
this.UIManager.phoneManager.activate(false);

// se duerme la escena actual
this.currentScene.scene.sleep();
// se cambia a la escena del ordenador
Expand All @@ -267,6 +273,8 @@ export default class GameManager {
}

leaveComputer() {
this.UIManager.phoneManager.activate(true);

this.computerScene.scene.sleep();
this.currentScene.scene.wake();
}
Expand Down
29 changes: 18 additions & 11 deletions src/managers/phoneManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default class PhoneManager {
this.resetCamEvent = "resetCam";
this.wakeUpEvent = "wakeUp";

this.activate(false);
this.showPhone(false);
}


Expand Down Expand Up @@ -301,12 +301,23 @@ export default class PhoneManager {

}


/**
* Activa/desactiva el telefono de manera inmediata
* @param {Boolean} active - true si se va a activar, false en caso contrario
* Muestra/oculta toda la interfaz del telefono (incluyendo el icono y las notificaciones)
* @param {Boolean} active - true si se va a mostrar, false en caso contrario
*/
activate(active) {
if ((this.phone.visible && !active) || (!this.phone.visible && active)) {
this.showPhone(false);
this.icon.visible = active;
this.notifications.visible = this.notificationAmount > 0;
}

/**
* Muestra/oculta el telefono de manera inmediata
* @param {Boolean} active - true si se va a activar, false en caso contrario
*/
showPhone(show) {
if ((this.phone.visible && !show) || (!this.phone.visible && show)) {
this.toggling = false;
this.togglePhone(0);
}
Expand Down Expand Up @@ -382,12 +393,8 @@ export default class PhoneManager {
this.wakeUpMessage.visible = false;
this.icon.visible = true;

if (this.notificationAmount > 0) {
this.notifications.visible = true;
}
else {
this.notifications.visible = false;
}
this.notifications.visible = this.notificationAmount > 0;

// Envia el evento de reiniciar la camara y el de despertarse
this.dispatcher.dispatch(this.resetCamEvent, {});
this.dispatcher.dispatch(this.wakeUpEvent, {});
Expand All @@ -406,7 +413,7 @@ export default class PhoneManager {
// Oculta el icono del movil, las notificaciones, y el propio movil
this.icon.visible = false;
this.notifications.visible = false;
this.activate(false);
this.showPhone(false);

// Cuando termina la animacion de desactivarse, va a la pantalla de la alarma y
// activa el bloqueo del fondo (hay que hacerlo cuando termine la animacion aunque
Expand Down
7 changes: 5 additions & 2 deletions src/scenes/bootScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ export default class BootScene extends Phaser.Scene {
// en cualquier idioma (aunque o existiese)
supportedLngs: ['en', 'es'],
// namespaces que se cargan para cada uno de los idiomas
ns: ['titleMenu', 'userInfoMenu', 'names', 'phoneInfo', 'transitionScenes',
ns: ['titleMenu', 'userInfoMenu', 'names', 'phoneInfo',
'transitionScenes', 'day1/bedroomMorningDay1',
'momDialog', 'dadDialog', 'chat1', 'computer'], // TEST
preload: ['en', 'es'],
// mostrar informacion de ayuda por consola
Expand Down Expand Up @@ -170,6 +171,7 @@ export default class BootScene extends Phaser.Scene {
this.load.json('dadDialog', './dadDialog.json');
this.load.json('chat1', './chat1.json');
this.load.json('computer', './computer.json');
this.load.json('bedroomMorningDay1', './day1/bedroomMorningDay1.json');
}

loadSpinalAnims() {
Expand All @@ -189,6 +191,8 @@ export default class BootScene extends Phaser.Scene {
this.load.image('bedroomCeiling', 'bedroom/bedroomCeiling.png');
this.load.image('bedroomBg', 'bedroom/bedroomBase.png');
this.load.image('bed', 'bedroom/bed.png');
this.load.image('bag', 'bedroom/bag.png');
this.load.image('bedroomChair', 'bedroom/bedroomChair.png');
this.load.image('bedroomDoorClosed', 'bedroom/bedroomDoorClosed.png');
this.load.image('bedroomDoorOpened', 'bedroom/bedroomDoorOpened.png');
this.load.image('bedroomJacket', 'bedroom/bedroomJacket.png');
Expand All @@ -202,7 +206,6 @@ export default class BootScene extends Phaser.Scene {
this.load.image('wardrobeDoor3Closed', 'bedroom/wardrobeDoor3Closed.png');
this.load.image('wardrobeDoor3Opened', 'bedroom/wardrobeDoor3Opened.png');


}

preload() {
Expand Down
7 changes: 6 additions & 1 deletion src/scenes/gameLoop/baseScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export default class BaseScene extends Phaser.Scene {
scale: this.portraitScale
};

this.scale = 1;

this.leftBound = 0;
this.rightBound = this.CANVAS_WIDTH;
this.START_SCROLLING = 30;
Expand Down Expand Up @@ -103,7 +105,10 @@ export default class BaseScene extends Phaser.Scene {
* traducciones es el que se pasa en el parametro namespace, y tiene que pasarse un string con el nombre del
* archivo sin la extension .json
*/
readNodes(id, file, namespace, playerName, context, getObjs) {
readNodes(id, file, namespace, getObjs) {
let playerName = this.gameManager.getUserInfo().name;
let context = this.gameManager.getUserInfo().gender;

// Crea el nodo y guarda sus atributos (se estableceran en el nodo al final)
let node = null;
let nodeId = id;
Expand Down
84 changes: 72 additions & 12 deletions src/scenes/gameLoop/bedroomBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,101 @@ export default class BedroomBase extends BaseScene {

// Pone la imagen de fondo con las dimensiones del canvas
let bg = this.add.image(0, 0, 'bedroomBg').setOrigin(0, 0);
let scale = this.CANVAS_HEIGHT / bg.height;
bg.setScale(scale);
this.scale = this.CANVAS_HEIGHT / bg.height;
bg.setScale(this.scale);

this.rightBound = bg.displayWidth;

// Puerta del armario individual
let door1Closed = this.add.image(2190 * scale, 330 * scale, 'wardrobeDoor1Closed').setOrigin(0, 0).setScale(scale);
let door1Opened = this.add.image(2110 * scale, 330 * scale, 'wardrobeDoor1Opened').setOrigin(0, 0).setScale(scale);
let door1Closed = this.add.image(2190 * this.scale, 330 * this.scale, 'wardrobeDoor1Closed').setOrigin(0, 0).setScale(this.scale);
let door1Opened = this.add.image(2110 * this.scale, 330 * this.scale, 'wardrobeDoor1Opened').setOrigin(0, 0).setScale(this.scale);
super.toggleDoor(door1Closed, door1Opened);

// Puerta izquierda del armario
let door2Closed = this.add.image(2500 * scale, 330 * scale, 'wardrobeDoor2Closed').setOrigin(0, 0).setScale(scale);
let door2Opened = this.add.image(2435 * scale, 307 * scale, 'wardrobeDoor2Opened').setOrigin(0, 0).setScale(scale);
let door2Closed = this.add.image(2500 * this.scale, 330 * this.scale, 'wardrobeDoor2Closed').setOrigin(0, 0).setScale(this.scale);
let door2Opened = this.add.image(2435 * this.scale, 307 * this.scale, 'wardrobeDoor2Opened').setOrigin(0, 0).setScale(this.scale);
super.toggleDoor(door2Closed, door2Opened);

// Puerta derecha del armario
let door3Closed = this.add.image(3155 * scale, 330 * scale, 'wardrobeDoor3Closed').setOrigin(1, 0).setScale(scale);
let door3Opened = this.add.image(3220 * scale, 330 * scale, 'wardrobeDoor3Opened').setOrigin(1, 0).setScale(scale);
let door3Closed = this.add.image(3155 * this.scale, 330 * this.scale, 'wardrobeDoor3Closed').setOrigin(1, 0).setScale(this.scale);
let door3Opened = this.add.image(3220 * this.scale, 330 * this.scale, 'wardrobeDoor3Opened').setOrigin(1, 0).setScale(this.scale);
super.toggleDoor(door3Closed, door3Opened);


// Interior de los armarios. Se reordenan las profundidades de las puertas de los armarios
// para hacer click sobre el elemento correcto. Al hacer click sobre el interior del armario,
// se cambia el nodo en el dialogManager. El nodo que se pone es nulo por defecto, y se tiene
// que establecer en la creacion de la escena
this.wardrobe1Node = null;
this.wardrobe2Node = null;

let wardrobe1 = this.add.rectangle(door1Closed.x, door1Closed.y, door1Closed.displayWidth, door1Closed.displayHeight, 0xfff, 0).setOrigin(0, 0);
door1Closed.setDepth(bg.depth + 3);
door1Opened.setDepth(door1Closed.depth - 1);
wardrobe1.setDepth(door1Opened.depth - 1);
wardrobe1.setInteractive();
wardrobe1.on('pointerdown', () => {
if (door1Opened.visible) {
this.dialogManager.setNode(this.wardrobe1Node)
}
});

let wardrobe2 = this.add.rectangle(door2Closed.x, door2Closed.y, door2Closed.displayWidth + door3Closed.displayWidth - 15, door1Closed.displayHeight, 0xfff, 0).setOrigin(0, 0);
door2Closed.setDepth(bg.depth + 4);
door2Opened.setDepth(door2Closed.depth - 1);
door3Closed.setDepth(bg.depth + 3);
door3Opened.setDepth(door2Closed.depth - 1);
wardrobe2.setDepth(door2Opened.depth - 1);
wardrobe2.setInteractive();
wardrobe2.on('pointerdown', () => {
if (door2Opened.visible || door3Opened.visible) {
this.dialogManager.setNode(this.wardrobe2Node)
}
})


// Ordenador
// Al hacer click sobre el, se cambia el nodo en el dialogManager, y si
// se lanza el evento turnPC, se cambia a la escena del ordenador
this.pcNode = null;

let pc = this.add.rectangle(276, 360, 150, 162, 0xfff, 0).setOrigin(0, 0);
pc.setInteractive();
pc.on('pointerdown', () => {
this.dialogManager.setNode(this.pcNode);
});
this.dispatcher.add("turnPC", this, (obj) => {
console.log(obj);
this.gameManager.switchToComputer();
});

// Silla
this.chair = this.add.image(770 * this.scale, 859 * this.scale, 'bedroomChair').setOrigin(0, 0).setScale(this.scale);

// Puerta de la habitacion
let doorClosed = this.add.image(6, this.CANVAS_HEIGHT, 'bedroomDoorClosed').setOrigin(0, 1).setScale(scale);
let doorOpened = this.add.image(6, this.CANVAS_HEIGHT, 'bedroomDoorOpened').setOrigin(0, 1).setScale(scale);
let doorClosed = this.add.image(6, this.CANVAS_HEIGHT, 'bedroomDoorClosed').setOrigin(0, 1).setScale(this.scale);
let doorOpened = this.add.image(6, this.CANVAS_HEIGHT, 'bedroomDoorOpened').setOrigin(0, 1).setScale(this.scale);
super.toggleDoor(doorClosed, doorOpened, false);

// Al hacer click sobre la puerta abierta, se pasa a la siguiente escena
doorOpened.on('pointerdown', () => {
this.gameManager.changeScene(this.nexScene);
});


// Cama
this.bed = this.add.image(bg.displayWidth, this.CANVAS_HEIGHT, 'bed').setOrigin(1, 1).setScale(scale);
// Al igual que con el interior de los armarios, se recoloca su profundidad y al
// hacer click sobre ella, se cambia el nodo en el dialogManager
this.bed = this.add.image(bg.displayWidth, this.CANVAS_HEIGHT, 'bed').setOrigin(1, 1).setScale(this.scale);
this.bed.setInteractive();

this.bed.setDepth(10);
this.bedNode = null;
this.bed.on('pointerdown', () => {
this.dialogManager.setNode(this.bedNode)
})


this.gameManager.setValue(this.gameManager.bagPicked, false);
this.cameras.main.scrollX = bg.displayWidth - this.CANVAS_WIDTH;

}
Expand Down
Loading

0 comments on commit 7bcae7f

Please sign in to comment.