From d374ac16f2da8002d3edb7ce0b3cb9223cfe516d Mon Sep 17 00:00:00 2001 From: Alpuerro <43877321+Alpuerro@users.noreply.github.com> Date: Thu, 16 Jan 2020 07:15:36 +0100 Subject: [PATCH] final websockets --- Juego/.classpath | 6 +- Juego/.project | 2 +- Juego/pom.xml | 2 +- .../java/es/urjc/code/juegosenred/Rest.java | 17 +- .../juegosenred/WebsocketEchoHandler.java | 86 +++---- .../main/resources/static/cutsceneOnline.js | 7 +- Juego/src/main/resources/static/login.js | 26 +- .../resources/static/selecci\303\263nPJH.js" | 229 +++++++++++++----- Juego/target/classes/META-INF/MANIFEST.MF | 12 +- .../items-backend-and-frontend/pom.properties | 8 +- .../items-backend-and-frontend/pom.xml | 2 +- .../juegosenred/WebsocketEchoHandler.class | Bin 5798 -> 5693 bytes Juego/target/classes/static/cutsceneOnline.js | 7 +- Juego/target/classes/static/login.js | 29 +-- Juego/target/classes/static/menu.js | 2 + .../classes/static/selecci\303\263nPJH.js" | 229 +++++++++++++----- 16 files changed, 420 insertions(+), 244 deletions(-) diff --git a/Juego/.classpath b/Juego/.classpath index adf4efe..b410df7 100644 --- a/Juego/.classpath +++ b/Juego/.classpath @@ -38,14 +38,14 @@ - - + + - + diff --git a/Juego/.project b/Juego/.project index 9adf0d4..aba3012 100644 --- a/Juego/.project +++ b/Juego/.project @@ -1,6 +1,6 @@ - JR-Grupo-H + JR-Grupo-H-Master diff --git a/Juego/pom.xml b/Juego/pom.xml index 003e686..7ea16d8 100644 --- a/Juego/pom.xml +++ b/Juego/pom.xml @@ -8,7 +8,7 @@ 0.0.1-SNAPSHOT jar - rest_ejer1_con_ui + rest Backend y frontend para el ejercicio de gesti�n de items diff --git a/Juego/src/main/java/es/urjc/code/juegosenred/Rest.java b/Juego/src/main/java/es/urjc/code/juegosenred/Rest.java index bcf9649..696b82f 100644 --- a/Juego/src/main/java/es/urjc/code/juegosenred/Rest.java +++ b/Juego/src/main/java/es/urjc/code/juegosenred/Rest.java @@ -39,19 +39,4 @@ public WebsocketEchoHandler echoHandler() public static void main(String[] args) { SpringApplication.run(Rest.class, args); } -} - -/* -package es.urjc.code.juegosenred; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class RestEjer1ConUiApplication { - - public static void main(String[] args) { - SpringApplication.run(RestEjer1ConUiApplication.class, args); - } -} -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/Juego/src/main/java/es/urjc/code/juegosenred/WebsocketEchoHandler.java b/Juego/src/main/java/es/urjc/code/juegosenred/WebsocketEchoHandler.java index 956ccc6..80eaad8 100644 --- a/Juego/src/main/java/es/urjc/code/juegosenred/WebsocketEchoHandler.java +++ b/Juego/src/main/java/es/urjc/code/juegosenred/WebsocketEchoHandler.java @@ -18,12 +18,21 @@ public class WebsocketEchoHandler extends TextWebSocketHandler { private ObjectMapper mapper = new ObjectMapper(); BlockingQueue matchmaking = new ArrayBlockingQueue<>(1000); ConcurrentHashMap users = new ConcurrentHashMap(); - int num = 0; + int num; Random rand = new Random(); int [] r1 = new int[9]; int [] r2 = new int[3]; int [] r3 = new int[3]; - + + public void setNum(int h) + { + num=h; + } + + public int getNum() + { + return num; + } @Override protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { @@ -83,66 +92,47 @@ protected void handleTextMessage(WebSocketSession session, TextMessage message) //Eleccion de personajes y de habilidades case "1": { - num++; + this.setNum(this.getNum()+1); //Se elijen los personajes - String p = node.get("personaje").asText(); + String p = node.get("p").asText(); String h1 = node.get("h1").asText(); String h2 = node.get("h2").asText(); String h3 = node.get("h3").asText(); String enemigo = node.get("sess").asText(); - - //Se hacen los randoms para la partida - int ch1 = r1[0]; - int ch2 = r1[1]; - int ch3 = r1[2]; - int ch4 = r1[3]; - int ch5 = r1[4]; - int ch6 = r1[5]; - int ch7 = r1[6]; - int ch8 = r1[7]; - int ch9 = r1[8]; - - int rQ1 = r2[0]; - int rQ2 = r2[1]; - int rQ3 = r2[2]; - - int cT1 = r3[0]; - int cT2 = r3[1]; - int cT3 = r3[2]; + //Respuesta ObjectNode responseNode = mapper.createObjectNode(); responseNode.put("code",1); - responseNode.put("personaje",p); + responseNode.put("p",p); responseNode.put("h1",h1); responseNode.put("h2",h2); responseNode.put("h3",h3); - responseNode.put("characters", ch1); - responseNode.put("characters", ch2); - responseNode.put("characters", ch3); - responseNode.put("characters", ch4); - responseNode.put("characters", ch5); - responseNode.put("characters", ch6); - responseNode.put("characters", ch7); - responseNode.put("characters", ch8); - responseNode.put("characters", ch9); - responseNode.put("characters", rQ1); - responseNode.put("characters", rQ2); - responseNode.put("characters", rQ3); - responseNode.put("characters", cT1); - responseNode.put("characters", cT2); - responseNode.put("characters", cT3); + responseNode.put("ch1", r1[0]); + responseNode.put("ch2", r1[1]); + responseNode.put("ch3", r1[2]); + responseNode.put("ch4", r1[3]); + responseNode.put("ch5", r1[4]); + responseNode.put("ch6", r1[5]); + responseNode.put("ch7", r1[6]); + responseNode.put("ch8", r1[7]); + responseNode.put("ch9", r1[8]); + responseNode.put("rQ1", r2[0]); + responseNode.put("rQ2", r2[1]); + responseNode.put("rQ3", r2[2]); + responseNode.put("cT1", r3[0]); + responseNode.put("cT2", r3[1]); + responseNode.put("cT3", r3[2]); System.out.println("Mensaje enviado: " + responseNode.toString()); users.get(enemigo).sendMessage(new TextMessage(responseNode.toString())); - session.sendMessage(new TextMessage(responseNode.toString())); - - if(num==2) - { - ObjectNode responseNode1 = mapper.createObjectNode(); - responseNode1.put("code",4); - users.get(enemigo).sendMessage(new TextMessage(responseNode1.toString())); - session.sendMessage(new TextMessage(responseNode1.toString())); - } + + if(num>=2) + { + ObjectNode responseNode1 = mapper.createObjectNode(); + responseNode1.put("code",4); + users.get(enemigo).sendMessage(new TextMessage(responseNode1.toString())); + session.sendMessage(new TextMessage(responseNode1.toString())); + } break; } diff --git a/Juego/src/main/resources/static/cutsceneOnline.js b/Juego/src/main/resources/static/cutsceneOnline.js index 22f0b35..1c7b2b1 100644 --- a/Juego/src/main/resources/static/cutsceneOnline.js +++ b/Juego/src/main/resources/static/cutsceneOnline.js @@ -58,7 +58,7 @@ class CutsceneOnline extends Phaser.Scene { Las preguntas coinciden con el índice de answers que lleva su cuenta (actualizado en schedulePlaner()) */ this.questions = ["¿Cuántos fantasmas azules pasaron?", "¿Cuántos fantasmas rojos pasaron?", "¿Cuántos cazafantasmas pasaron?", "¿Cuántos personajes pasaron en total?"]; - this.questionIndex = roundQuestions[round]; + this.questionIndex = round; this.answers = [0, 0, 0, 0]; //Timers para enseñar la pregunta y cambiar de escena. @@ -89,11 +89,10 @@ class CutsceneOnline extends Phaser.Scene { //Enseña la pregunta showQuestion() { - this.add.text(gameWidth*3/20, gameHeight/2, this.questions[this.questionIndex], { font: '64px Caveat Brush', fill: '#ffffff' }); - console.log(this.answers[this.questionIndex]); + this.add.text(gameWidth*3/20, gameHeight/2, roundQuestions[this.questionIndex], { font: '64px Caveat Brush', fill: '#ffffff' }); } - //Cambia la escena y acutaliza el valor de la variable global round con la respuesta + //Cambia la escena y actualiza el valor de la variable global round con la respuesta changeScene() { answer = this.answers[this.questionIndex]; console.log(this.answers[this.questionIndex] + ' = ' + answer); diff --git a/Juego/src/main/resources/static/login.js b/Juego/src/main/resources/static/login.js index 4896f1c..ab9a550 100644 --- a/Juego/src/main/resources/static/login.js +++ b/Juego/src/main/resources/static/login.js @@ -48,25 +48,11 @@ var p; var h1; var h2; var h3; -var ch1; -var ch2; -var ch3; -var ch4; -var ch5; -var ch6; -var ch7; -var ch8; -var ch9; -var rQ1; -var rQ2; -var rQ3; -var cT1; -var cT2; -var cT3; - -var characters; -var correctTombstones; -var roundQuestions; + + +var characters = [9]; +var correctTombstones = [3]; +var roundQuestions = [3]; var ax; var ay; @@ -117,7 +103,7 @@ connection.onmessage = function(msg) case 1: { //Generacion de la partida - p = info.personaje; + p = info.p; h1 = info.h1; h2 = info.h2; h3 = info.h3; diff --git "a/Juego/src/main/resources/static/selecci\303\263nPJH.js" "b/Juego/src/main/resources/static/selecci\303\263nPJH.js" index 2895e67..0e1d5aa 100644 --- "a/Juego/src/main/resources/static/selecci\303\263nPJH.js" +++ "b/Juego/src/main/resources/static/selecci\303\263nPJH.js" @@ -39,41 +39,119 @@ class SeleccionPJH extends Phaser.Scene { Al pulsarse cada uno de los dos botones, dependiendo de la iteración de la configuración de partida se actualiza: El primer parámetro de playerXConfig a 0 o 1 dependiendo de la elección. */ - this.ghostbusterM.on('pointerdown', function (pointer){ - if (this.iter == 0) player1Config[0] = 0; - if (this.iter == 1) player2Config[0] = 0; - this.disableCharSelectMenu(); - this.showAbilitiesSelectMenu(); - }, this); - this.ghostbusterM.on('pointerover', function (pointer) { this.ghostbusterM.setScale(0.9); }, this); - this.ghostbusterM.on('pointerout', function (pointer) { this.ghostbusterM.setScale(0.7); }, this); - - this.ghostbusterW.on('pointerdown', function (pointer){ - if (this.iter == 0) player1Config[0] = 1; - if (this.iter == 1) player2Config[0] = 1; - this.disableCharSelectMenu(); - this.showAbilitiesSelectMenu(); - }, this); - this.ghostbusterW.on('pointerover', function (pointer) { this.ghostbusterW.setScale(0.9); }, this); - this.ghostbusterW.on('pointerout', function (pointer) { this.ghostbusterW.setScale(0.7); }, this); - - this.blueGhost.on('pointerdown', function (pointer){ - if (this.iter == 0) player1Config[0] = 2; - if (this.iter == 1) player2Config[0] = 2; - this.disableCharSelectMenu(); - this.showAbilitiesSelectMenu(); - }, this); - this.blueGhost.on('pointerover', function (pointer) { this.blueGhost.setScale(1.1); }, this); - this.blueGhost.on('pointerout', function (pointer) { this.blueGhost.setScale(0.9); }, this); - - this.redGhost.on('pointerdown', function (pointer){ - if (this.iter == 0) player1Config[0] = 3; - if (this.iter == 1) player2Config[0] = 3; - this.disableCharSelectMenu(); - this.showAbilitiesSelectMenu(); - }, this); - this.redGhost.on('pointerover', function (pointer) { this.redGhost.setScale(1.1); }, this); - this.redGhost.on('pointerout', function (pointer) { this.redGhost.setScale(0.9); }, this); + + + if(conectado) + { + if(playerj=1) + { + this.ghostbusterM.on('pointerdown', function (pointer){ + player1Config[0] = 0; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.ghostbusterM.on('pointerover', function (pointer) { this.ghostbusterM.setScale(0.9); }, this); + this.ghostbusterM.on('pointerout', function (pointer) { this.ghostbusterM.setScale(0.7); }, this); + + this.ghostbusterW.on('pointerdown', function (pointer){ + player1Config[0] = 1; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.ghostbusterW.on('pointerover', function (pointer) { this.ghostbusterW.setScale(0.9); }, this); + this.ghostbusterW.on('pointerout', function (pointer) { this.ghostbusterW.setScale(0.7); }, this); + + this.blueGhost.on('pointerdown', function (pointer){ + player1Config[0] = 2; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.blueGhost.on('pointerover', function (pointer) { this.blueGhost.setScale(1.1); }, this); + this.blueGhost.on('pointerout', function (pointer) { this.blueGhost.setScale(0.9); }, this); + + this.redGhost.on('pointerdown', function (pointer){ + player1Config[0] = 3; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.redGhost.on('pointerover', function (pointer) { this.redGhost.setScale(1.1); }, this); + this.redGhost.on('pointerout', function (pointer) { this.redGhost.setScale(0.9); }, this); + } + else + { + this.ghostbusterM.on('pointerdown', function (pointer){ + player2Config[0] = 0; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.ghostbusterM.on('pointerover', function (pointer) { this.ghostbusterM.setScale(0.9); }, this); + this.ghostbusterM.on('pointerout', function (pointer) { this.ghostbusterM.setScale(0.7); }, this); + + this.ghostbusterW.on('pointerdown', function (pointer){ + player2Config[0] = 1; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.ghostbusterW.on('pointerover', function (pointer) { this.ghostbusterW.setScale(0.9); }, this); + this.ghostbusterW.on('pointerout', function (pointer) { this.ghostbusterW.setScale(0.7); }, this); + + this.blueGhost.on('pointerdown', function (pointer){ + player2Config[0] = 2; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.blueGhost.on('pointerover', function (pointer) { this.blueGhost.setScale(1.1); }, this); + this.blueGhost.on('pointerout', function (pointer) { this.blueGhost.setScale(0.9); }, this); + + this.redGhost.on('pointerdown', function (pointer){ + player2Config[0] = 3; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.redGhost.on('pointerover', function (pointer) { this.redGhost.setScale(1.1); }, this); + this.redGhost.on('pointerout', function (pointer) { this.redGhost.setScale(0.9); }, this); + } + } + else + { + this.ghostbusterM.on('pointerdown', function (pointer){ + if (this.iter == 0) player1Config[0] = 0; + if (this.iter == 1) player2Config[0] = 0; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.ghostbusterM.on('pointerover', function (pointer) { this.ghostbusterM.setScale(0.9); }, this); + this.ghostbusterM.on('pointerout', function (pointer) { this.ghostbusterM.setScale(0.7); }, this); + + this.ghostbusterW.on('pointerdown', function (pointer){ + if (this.iter == 0) player1Config[0] = 1; + + if (this.iter == 1) player2Config[0] = 1; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.ghostbusterW.on('pointerover', function (pointer) { this.ghostbusterW.setScale(0.9); }, this); + this.ghostbusterW.on('pointerout', function (pointer) { this.ghostbusterW.setScale(0.7); }, this); + + this.blueGhost.on('pointerdown', function (pointer){ + + if (this.iter == 0) player1Config[0] = 2; + if (this.iter == 1) player2Config[0] = 2; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.blueGhost.on('pointerover', function (pointer) { this.blueGhost.setScale(1.1); }, this); + this.blueGhost.on('pointerout', function (pointer) { this.blueGhost.setScale(0.9); }, this); + + this.redGhost.on('pointerdown', function (pointer){ + if (this.iter == 0) player1Config[0] = 3; + if (this.iter == 1) player2Config[0] = 3; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.redGhost.on('pointerover', function (pointer) { this.redGhost.setScale(1.1); }, this); + this.redGhost.on('pointerout', function (pointer) { this.redGhost.setScale(0.9); }, this); + } //Son return to ___ this.returnChar = this.add.image(gameWidth*7/50, gameHeight*9/50, 'bt_return').setAlpha(0).setScale(0.7); @@ -193,28 +271,60 @@ class SeleccionPJH extends Phaser.Scene { }, this); //Botón de continuar a la siguiente selección o de empezar juego - this.ready.on('pointerdown', function (pointer){ + this.ready.on('pointerdown', function (pointer) + { //Sólo funciona si se han seleccionado 3 habilidades if (this.abilitiesSelected == 3){ //Impide que este botón se pinte this.abilitiesMenu = false; //Actualizar las abilidades del jugador dependiendo de la iteración del menú - if (this.iter == 0) { - player1Config[1] = this.abilitiesIndex[0]; - player1Config[2] = this.abilitiesIndex[1]; - player1Config[3] = this.abilitiesIndex[2]; - - if (conectado == true){ - msg = { - code: "1", - p: player1Config[0], - h1: player1Config[1], - h2: player1Config[2], - h3: player1Config[3], - sess: session - } - connection.send(JSON.stringify(msg)); - + if (this.iter == 0) + { + if(conectado) + { + if(playerj=1) + { + player1Config[1] = this.abilitiesIndex[0]; + player1Config[2] = this.abilitiesIndex[1]; + player1Config[3] = this.abilitiesIndex[2]; + + + msg = { + code: "1", + p: player1Config[0], + h1: player1Config[1], + h2: player1Config[2], + h3: player1Config[3], + sess: session + } + connection.send(JSON.stringify(msg)); + } + else + { + player2Config[1] = this.abilitiesIndex[0]; + player2Config[2] = this.abilitiesIndex[1]; + player2Config[3] = this.abilitiesIndex[2]; + + if (conectado){ + msg = { + code: "1", + p: player2Config[0], + h1: player2Config[1], + h2: player2Config[2], + h3: player2Config[3], + sess: session + } + connection.send(JSON.stringify(msg)); + } + + } + } + else + { + player1Config[1] = this.abilitiesIndex[0]; + player1Config[2] = this.abilitiesIndex[1]; + player1Config[3] = this.abilitiesIndex[2]; + } } //Si es la segunda iteración, comienza la partida. Si no vuelve al menú de selección de equipo (actualizando iter) @@ -225,8 +335,12 @@ class SeleccionPJH extends Phaser.Scene { this.scene.start('cutscene'); } else { - this.iter++; - this.showCharSelectMenu(); + if(!conectado) + { + this.iter++; + this.showCharSelectMenu(); + } + } //Imprime por pantalla la configuración de cada jugador DEBUG //console.log('P1 ' + player1Config); @@ -236,7 +350,7 @@ class SeleccionPJH extends Phaser.Scene { } - } + }, this); //Interfaz por encima de casi todo @@ -351,8 +465,9 @@ class SeleccionPJH extends Phaser.Scene { else if (this.abilitiesMenu == true && this.abilitiesSelected != 3) this.ready.setAlpha(0.4); else this.ready.setAlpha(0); - if (sincro == 2){ - cambiarescena(); + if (sincro == 2) + { + this.cambiarescena(); } } } diff --git a/Juego/target/classes/META-INF/MANIFEST.MF b/Juego/target/classes/META-INF/MANIFEST.MF index af48a78..1f68447 100644 --- a/Juego/target/classes/META-INF/MANIFEST.MF +++ b/Juego/target/classes/META-INF/MANIFEST.MF @@ -1,11 +1,11 @@ Manifest-Version: 1.0 -Built-By: a.garciagar.2016 -Build-Jdk: 13.0.1 -Implementation-Title: rest_ejer1_con_ui +Implementation-Title: rest Implementation-Version: 0.0.1-SNAPSHOT +Built-By: tomas Implementation-Vendor-Id: es.urjc.code.juegosenred -Implementation-Vendor: Pivotal Software, Inc. -Implementation-URL: http://projects.spring.io/spring-boot/items-backend- - and-frontend/ +Build-Jdk: 1.8.0_191 +Implementation-URL: http://projects.spring.io/spring-boot/items-backen + d-and-frontend/ Created-By: Maven Integration for Eclipse +Implementation-Vendor: Pivotal Software, Inc. diff --git a/Juego/target/classes/META-INF/maven/es.urjc.code.juegosenred/items-backend-and-frontend/pom.properties b/Juego/target/classes/META-INF/maven/es.urjc.code.juegosenred/items-backend-and-frontend/pom.properties index eb78f06..d094d86 100644 --- a/Juego/target/classes/META-INF/maven/es.urjc.code.juegosenred/items-backend-and-frontend/pom.properties +++ b/Juego/target/classes/META-INF/maven/es.urjc.code.juegosenred/items-backend-and-frontend/pom.properties @@ -1,7 +1,7 @@ #Generated by Maven Integration for Eclipse -#Wed Jan 15 23:35:44 CET 2020 -m2e.projectLocation=F\:\\URJC\\Tercero\\Juegos en Red\\Te acuerdas de\\JR-Grupo-H\\Juego -m2e.projectName=JR-Grupo-H +#Thu Jan 16 04:24:31 CET 2020 +version=0.0.1-SNAPSHOT groupId=es.urjc.code.juegosenred +m2e.projectName=JR-Grupo-H-Master +m2e.projectLocation=C\:\\Users\\tomas\\Desktop\\Universidad\\JuegosEnRed\\JR-Grupo-H-master\\Juego artifactId=items-backend-and-frontend -version=0.0.1-SNAPSHOT diff --git a/Juego/target/classes/META-INF/maven/es.urjc.code.juegosenred/items-backend-and-frontend/pom.xml b/Juego/target/classes/META-INF/maven/es.urjc.code.juegosenred/items-backend-and-frontend/pom.xml index 003e686..7ea16d8 100644 --- a/Juego/target/classes/META-INF/maven/es.urjc.code.juegosenred/items-backend-and-frontend/pom.xml +++ b/Juego/target/classes/META-INF/maven/es.urjc.code.juegosenred/items-backend-and-frontend/pom.xml @@ -8,7 +8,7 @@ 0.0.1-SNAPSHOT jar - rest_ejer1_con_ui + rest Backend y frontend para el ejercicio de gesti�n de items diff --git a/Juego/target/classes/es/urjc/code/juegosenred/WebsocketEchoHandler.class b/Juego/target/classes/es/urjc/code/juegosenred/WebsocketEchoHandler.class index 24bc490b76ce340a5c568db129d091f064139c7e..3290e03f7e3dc1255539cd53a87c5a6571f2ee82 100644 GIT binary patch literal 5693 zcmbVP33yc175?vgFZ13^UIYfw4hSNGKp+eufS4eP2oemNiNv^6UM7!Z!YuL43=sFd zQg@}UpkgZl)V3-NB8m&GZK-Y5YPGAaxbNDFJTSW}rAcRTc&XhS&asEva=hUNds&)7>Rln800Cdz>gcc?YOaeU zs_TEcUi+wDktw#!~4P#U+=k+!(Cn0f_<*0ozp ztZ*hBjnVW(B;z=CA{{;>4buwt&9qW&JP^0U_mg#UjxS~GPUzWultM#05mHfaWkh z0>L5!PT@>4POB8Bl3!<#OL4}@uPO#?ax@W5PZ3Z@j9kF&)0ij$sOWFv5FD!GFo97A z5Xk@rpuZmihnpyYPsb4g!}l4>sg7fHb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DQk3EgG7a@I_j76JEOYNp!`w3W^J(ak3RcT2^CZ>ED-B5<<(2u8=9E|V zlThxQknMHZV&HoqZfcMEpag4G@ItATgf7;Y^i&xT+Zt+?g(k)(3L%PKqY3M3*znO-4 z$DBnvhi$QZPrloqii&*q{uHPSyWfz4({}mpH$AjnFJGtS zj)jn|FIqLDFFD(-uTC_Uxi_b!lS#uCN%!b(KV7Gn8K|{hY`G@GR?c>_m04Q_v$oid zAn{OU*lnw7=yDPgoIOJON1u~=D+R%I;$ z$~v?u8?i*$f{?NeVPzL0%05JugNP~bAg+9bgz_1dDqmrlas&~MqQ-Emx&o`z+i{z^7PqTgv06QVJJb(wr}`=G zQV-*9^=qurig1rM9QSJH;C`(F>$E9&K%0RFwaf63wh-$zKQ?GFJfdBXjoKQ(5dai6WWK^qJ4uWwIg`ik%MO(1=!{ojO~tbc-AooUGnu5yJ;J~ zi|N->qQ~(Y`JxgXqQw-9c8tJp@eb`==_o+}@ACC~n|6AS>vHh17>?f&>G+hk|2LAd}XoNi%*F9DPi#({!CP$EEUgCvH}z; zD@7;%LR6%z78~$aBDbRSOokx`Ua^bHOjQHCACyZ_^Vxd?p8O$z?=fA&E+Qvd(} diff --git a/Juego/target/classes/static/cutsceneOnline.js b/Juego/target/classes/static/cutsceneOnline.js index 22f0b35..1c7b2b1 100644 --- a/Juego/target/classes/static/cutsceneOnline.js +++ b/Juego/target/classes/static/cutsceneOnline.js @@ -58,7 +58,7 @@ class CutsceneOnline extends Phaser.Scene { Las preguntas coinciden con el índice de answers que lleva su cuenta (actualizado en schedulePlaner()) */ this.questions = ["¿Cuántos fantasmas azules pasaron?", "¿Cuántos fantasmas rojos pasaron?", "¿Cuántos cazafantasmas pasaron?", "¿Cuántos personajes pasaron en total?"]; - this.questionIndex = roundQuestions[round]; + this.questionIndex = round; this.answers = [0, 0, 0, 0]; //Timers para enseñar la pregunta y cambiar de escena. @@ -89,11 +89,10 @@ class CutsceneOnline extends Phaser.Scene { //Enseña la pregunta showQuestion() { - this.add.text(gameWidth*3/20, gameHeight/2, this.questions[this.questionIndex], { font: '64px Caveat Brush', fill: '#ffffff' }); - console.log(this.answers[this.questionIndex]); + this.add.text(gameWidth*3/20, gameHeight/2, roundQuestions[this.questionIndex], { font: '64px Caveat Brush', fill: '#ffffff' }); } - //Cambia la escena y acutaliza el valor de la variable global round con la respuesta + //Cambia la escena y actualiza el valor de la variable global round con la respuesta changeScene() { answer = this.answers[this.questionIndex]; console.log(this.answers[this.questionIndex] + ' = ' + answer); diff --git a/Juego/target/classes/static/login.js b/Juego/target/classes/static/login.js index bed14b5..ab9a550 100644 --- a/Juego/target/classes/static/login.js +++ b/Juego/target/classes/static/login.js @@ -48,25 +48,11 @@ var p; var h1; var h2; var h3; -var ch1; -var ch2; -var ch3; -var ch4; -var ch5; -var ch6; -var ch7; -var ch8; -var ch9; -var rQ1; -var rQ2; -var rQ3; -var cT1; -var cT2; -var cT3; - -var characters; -var correctTombstones; -var roundQuestions; + + +var characters = [9]; +var correctTombstones = [3]; +var roundQuestions = [3]; var ax; var ay; @@ -117,7 +103,7 @@ connection.onmessage = function(msg) case 1: { //Generacion de la partida - p = info.personaje; + p = info.p; h1 = info.h1; h2 = info.h2; h3 = info.h3; @@ -219,7 +205,6 @@ class Login extends Phaser.Scene this.userCreatedText = this.add.text(gameWidth*(25/100), gameHeight*(30/80),"",{ font: '32px Courier', fill: '#00ff00'}); - this.back.on('pointerdown', function (pointer){ nam.style.display = 'none'; pass.style.display = 'none'; @@ -321,7 +306,6 @@ class Login extends Phaser.Scene this.showOnlineMenu(); loadchat = true; } - if (registered == true) { this.log.setText(""); this.reg.setText(""); @@ -347,6 +331,7 @@ class Login extends Phaser.Scene if(backMenu) { this.fall.setText("El servidor se ha caido"); + this.backMenuFuncTimer = this.time.addEvent({ delay: 4000, callback: this.backMenuFunc, loop: false, callbackScope: this}); } if(match) diff --git a/Juego/target/classes/static/menu.js b/Juego/target/classes/static/menu.js index 8290a0d..8a28836 100644 --- a/Juego/target/classes/static/menu.js +++ b/Juego/target/classes/static/menu.js @@ -14,6 +14,7 @@ class Menu extends Phaser.Scene { super({key:"menu"}); } + preload() { } @@ -85,6 +86,7 @@ class Menu extends Phaser.Scene { this.disableTutorial1(); this.showMainMenu(); }, this); + //Interfaz por encima de casi todo this.bg_estatica = this.add.sprite(gameWidth*11/20,gameHeight/2,'bg_estatica').setAlpha(0.05); this.anims.create({ diff --git "a/Juego/target/classes/static/selecci\303\263nPJH.js" "b/Juego/target/classes/static/selecci\303\263nPJH.js" index 2895e67..0e1d5aa 100644 --- "a/Juego/target/classes/static/selecci\303\263nPJH.js" +++ "b/Juego/target/classes/static/selecci\303\263nPJH.js" @@ -39,41 +39,119 @@ class SeleccionPJH extends Phaser.Scene { Al pulsarse cada uno de los dos botones, dependiendo de la iteración de la configuración de partida se actualiza: El primer parámetro de playerXConfig a 0 o 1 dependiendo de la elección. */ - this.ghostbusterM.on('pointerdown', function (pointer){ - if (this.iter == 0) player1Config[0] = 0; - if (this.iter == 1) player2Config[0] = 0; - this.disableCharSelectMenu(); - this.showAbilitiesSelectMenu(); - }, this); - this.ghostbusterM.on('pointerover', function (pointer) { this.ghostbusterM.setScale(0.9); }, this); - this.ghostbusterM.on('pointerout', function (pointer) { this.ghostbusterM.setScale(0.7); }, this); - - this.ghostbusterW.on('pointerdown', function (pointer){ - if (this.iter == 0) player1Config[0] = 1; - if (this.iter == 1) player2Config[0] = 1; - this.disableCharSelectMenu(); - this.showAbilitiesSelectMenu(); - }, this); - this.ghostbusterW.on('pointerover', function (pointer) { this.ghostbusterW.setScale(0.9); }, this); - this.ghostbusterW.on('pointerout', function (pointer) { this.ghostbusterW.setScale(0.7); }, this); - - this.blueGhost.on('pointerdown', function (pointer){ - if (this.iter == 0) player1Config[0] = 2; - if (this.iter == 1) player2Config[0] = 2; - this.disableCharSelectMenu(); - this.showAbilitiesSelectMenu(); - }, this); - this.blueGhost.on('pointerover', function (pointer) { this.blueGhost.setScale(1.1); }, this); - this.blueGhost.on('pointerout', function (pointer) { this.blueGhost.setScale(0.9); }, this); - - this.redGhost.on('pointerdown', function (pointer){ - if (this.iter == 0) player1Config[0] = 3; - if (this.iter == 1) player2Config[0] = 3; - this.disableCharSelectMenu(); - this.showAbilitiesSelectMenu(); - }, this); - this.redGhost.on('pointerover', function (pointer) { this.redGhost.setScale(1.1); }, this); - this.redGhost.on('pointerout', function (pointer) { this.redGhost.setScale(0.9); }, this); + + + if(conectado) + { + if(playerj=1) + { + this.ghostbusterM.on('pointerdown', function (pointer){ + player1Config[0] = 0; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.ghostbusterM.on('pointerover', function (pointer) { this.ghostbusterM.setScale(0.9); }, this); + this.ghostbusterM.on('pointerout', function (pointer) { this.ghostbusterM.setScale(0.7); }, this); + + this.ghostbusterW.on('pointerdown', function (pointer){ + player1Config[0] = 1; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.ghostbusterW.on('pointerover', function (pointer) { this.ghostbusterW.setScale(0.9); }, this); + this.ghostbusterW.on('pointerout', function (pointer) { this.ghostbusterW.setScale(0.7); }, this); + + this.blueGhost.on('pointerdown', function (pointer){ + player1Config[0] = 2; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.blueGhost.on('pointerover', function (pointer) { this.blueGhost.setScale(1.1); }, this); + this.blueGhost.on('pointerout', function (pointer) { this.blueGhost.setScale(0.9); }, this); + + this.redGhost.on('pointerdown', function (pointer){ + player1Config[0] = 3; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.redGhost.on('pointerover', function (pointer) { this.redGhost.setScale(1.1); }, this); + this.redGhost.on('pointerout', function (pointer) { this.redGhost.setScale(0.9); }, this); + } + else + { + this.ghostbusterM.on('pointerdown', function (pointer){ + player2Config[0] = 0; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.ghostbusterM.on('pointerover', function (pointer) { this.ghostbusterM.setScale(0.9); }, this); + this.ghostbusterM.on('pointerout', function (pointer) { this.ghostbusterM.setScale(0.7); }, this); + + this.ghostbusterW.on('pointerdown', function (pointer){ + player2Config[0] = 1; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.ghostbusterW.on('pointerover', function (pointer) { this.ghostbusterW.setScale(0.9); }, this); + this.ghostbusterW.on('pointerout', function (pointer) { this.ghostbusterW.setScale(0.7); }, this); + + this.blueGhost.on('pointerdown', function (pointer){ + player2Config[0] = 2; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.blueGhost.on('pointerover', function (pointer) { this.blueGhost.setScale(1.1); }, this); + this.blueGhost.on('pointerout', function (pointer) { this.blueGhost.setScale(0.9); }, this); + + this.redGhost.on('pointerdown', function (pointer){ + player2Config[0] = 3; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.redGhost.on('pointerover', function (pointer) { this.redGhost.setScale(1.1); }, this); + this.redGhost.on('pointerout', function (pointer) { this.redGhost.setScale(0.9); }, this); + } + } + else + { + this.ghostbusterM.on('pointerdown', function (pointer){ + if (this.iter == 0) player1Config[0] = 0; + if (this.iter == 1) player2Config[0] = 0; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.ghostbusterM.on('pointerover', function (pointer) { this.ghostbusterM.setScale(0.9); }, this); + this.ghostbusterM.on('pointerout', function (pointer) { this.ghostbusterM.setScale(0.7); }, this); + + this.ghostbusterW.on('pointerdown', function (pointer){ + if (this.iter == 0) player1Config[0] = 1; + + if (this.iter == 1) player2Config[0] = 1; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.ghostbusterW.on('pointerover', function (pointer) { this.ghostbusterW.setScale(0.9); }, this); + this.ghostbusterW.on('pointerout', function (pointer) { this.ghostbusterW.setScale(0.7); }, this); + + this.blueGhost.on('pointerdown', function (pointer){ + + if (this.iter == 0) player1Config[0] = 2; + if (this.iter == 1) player2Config[0] = 2; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.blueGhost.on('pointerover', function (pointer) { this.blueGhost.setScale(1.1); }, this); + this.blueGhost.on('pointerout', function (pointer) { this.blueGhost.setScale(0.9); }, this); + + this.redGhost.on('pointerdown', function (pointer){ + if (this.iter == 0) player1Config[0] = 3; + if (this.iter == 1) player2Config[0] = 3; + this.disableCharSelectMenu(); + this.showAbilitiesSelectMenu(); + }, this); + this.redGhost.on('pointerover', function (pointer) { this.redGhost.setScale(1.1); }, this); + this.redGhost.on('pointerout', function (pointer) { this.redGhost.setScale(0.9); }, this); + } //Son return to ___ this.returnChar = this.add.image(gameWidth*7/50, gameHeight*9/50, 'bt_return').setAlpha(0).setScale(0.7); @@ -193,28 +271,60 @@ class SeleccionPJH extends Phaser.Scene { }, this); //Botón de continuar a la siguiente selección o de empezar juego - this.ready.on('pointerdown', function (pointer){ + this.ready.on('pointerdown', function (pointer) + { //Sólo funciona si se han seleccionado 3 habilidades if (this.abilitiesSelected == 3){ //Impide que este botón se pinte this.abilitiesMenu = false; //Actualizar las abilidades del jugador dependiendo de la iteración del menú - if (this.iter == 0) { - player1Config[1] = this.abilitiesIndex[0]; - player1Config[2] = this.abilitiesIndex[1]; - player1Config[3] = this.abilitiesIndex[2]; - - if (conectado == true){ - msg = { - code: "1", - p: player1Config[0], - h1: player1Config[1], - h2: player1Config[2], - h3: player1Config[3], - sess: session - } - connection.send(JSON.stringify(msg)); - + if (this.iter == 0) + { + if(conectado) + { + if(playerj=1) + { + player1Config[1] = this.abilitiesIndex[0]; + player1Config[2] = this.abilitiesIndex[1]; + player1Config[3] = this.abilitiesIndex[2]; + + + msg = { + code: "1", + p: player1Config[0], + h1: player1Config[1], + h2: player1Config[2], + h3: player1Config[3], + sess: session + } + connection.send(JSON.stringify(msg)); + } + else + { + player2Config[1] = this.abilitiesIndex[0]; + player2Config[2] = this.abilitiesIndex[1]; + player2Config[3] = this.abilitiesIndex[2]; + + if (conectado){ + msg = { + code: "1", + p: player2Config[0], + h1: player2Config[1], + h2: player2Config[2], + h3: player2Config[3], + sess: session + } + connection.send(JSON.stringify(msg)); + } + + } + } + else + { + player1Config[1] = this.abilitiesIndex[0]; + player1Config[2] = this.abilitiesIndex[1]; + player1Config[3] = this.abilitiesIndex[2]; + } } //Si es la segunda iteración, comienza la partida. Si no vuelve al menú de selección de equipo (actualizando iter) @@ -225,8 +335,12 @@ class SeleccionPJH extends Phaser.Scene { this.scene.start('cutscene'); } else { - this.iter++; - this.showCharSelectMenu(); + if(!conectado) + { + this.iter++; + this.showCharSelectMenu(); + } + } //Imprime por pantalla la configuración de cada jugador DEBUG //console.log('P1 ' + player1Config); @@ -236,7 +350,7 @@ class SeleccionPJH extends Phaser.Scene { } - } + }, this); //Interfaz por encima de casi todo @@ -351,8 +465,9 @@ class SeleccionPJH extends Phaser.Scene { else if (this.abilitiesMenu == true && this.abilitiesSelected != 3) this.ready.setAlpha(0.4); else this.ready.setAlpha(0); - if (sincro == 2){ - cambiarescena(); + if (sincro == 2) + { + this.cambiarescena(); } } }