diff --git a/package-lock.json b/package-lock.json index 660b2e3..23340e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "pilas-bloques-exercises", - "version": "1.4.15", + "version": "1.4.17", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 528ebc4..745919b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pilas-bloques-exercises", - "version": "1.4.15", + "version": "1.4.17", "description": "Exercises for Pilas Bloques", "homepage": "http://pilasbloques.program.ar", "author": { diff --git a/src/actores/segundoCiclo/Capy/CapySolo.ts b/src/actores/segundoCiclo/Capy/CapySolo.ts index 76aa8a6..f553509 100644 --- a/src/actores/segundoCiclo/Capy/CapySolo.ts +++ b/src/actores/segundoCiclo/Capy/CapySolo.ts @@ -1,5 +1,4 @@ /// -/// e class CapySolo extends ActorAnimado { static _grilla = 'actor.capySolo.png' diff --git a/src/actores/segundoCiclo/Chuy/Chuy.ts b/src/actores/segundoCiclo/Chuy/Chuy.ts index 98c23d3..f50b88d 100644 --- a/src/actores/segundoCiclo/Chuy/Chuy.ts +++ b/src/actores/segundoCiclo/Chuy/Chuy.ts @@ -28,5 +28,6 @@ class Chuy extends ActorAnimado { this.definirAnimacion("rebotarPelota", [87, 88, 89, 90, 91, 92, 93, 92, 91, 90, 94, 95, 90, 91, 92, 93, 91, 94, 91, 93, 90, 94, 96, 87, 87, 87, 87], 12); this.definirAnimacion("patear", [87, 88, 89, 90, 91, 92, 93, 92, 91, 90, 94, 95, 90, 91, 92, 93, 91, 94, 91, 93, 90, 94, 96, 87, 87, 87, 87], 12) this.definirAnimacion("rebotarPulpito", [77, 78, 79, 80, 81, 82, 83, 82, 81, 80, 84, 85, 80, 81, 82, 83, 81, 84, 81, 83, 80, 84, 86, 77, 77, 77, 77], 12); - } + this.definirAnimacion("surfear", [68, 69, 70, 71, 72, 73, 74, 75, 76], 12); + } } diff --git a/src/actores/segundoCiclo/Chuy/Pelotas.ts b/src/actores/segundoCiclo/Chuy/Pelotas.ts index 9541232..db947ea 100644 --- a/src/actores/segundoCiclo/Chuy/Pelotas.ts +++ b/src/actores/segundoCiclo/Chuy/Pelotas.ts @@ -5,6 +5,7 @@ class Pulpito extends ActorAnimado { constructor() { super(0, 0, { cantColumnas: 2 }); + this.definirAnimacion("correr", [0], 12) this.definirAnimacion("desaparecer", [1], 12); } } diff --git a/src/actores/segundoCiclo/Manic/Manic.ts b/src/actores/segundoCiclo/Manic/Manic.ts index 552c0ca..ce6c204 100644 --- a/src/actores/segundoCiclo/Manic/Manic.ts +++ b/src/actores/segundoCiclo/Manic/Manic.ts @@ -21,5 +21,6 @@ class Manic extends ActorAnimado { this.definirAnimacion("recoger", [28, 29, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 31, 28], 12); this.definirAnimacion("usarCatalejo", [54, 55, 56, 57, 58, 59, 60, 61, 61, 62, 62, 62, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 77, 78, 79, 80, 81, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82], 20); this.definirAnimacion("dibujar", [0, 1, 2, 3, 4, 5, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27], 20); + this.definirAnimacion("surfear", [0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 6, 7, 6, 5, 6, 7, 7], 20); } } diff --git a/src/actores/segundoCiclo/Manic/Telescopio.ts b/src/actores/segundoCiclo/Manic/Telescopio.ts index 13d5e0e..79ed3ab 100644 --- a/src/actores/segundoCiclo/Manic/Telescopio.ts +++ b/src/actores/segundoCiclo/Manic/Telescopio.ts @@ -6,6 +6,7 @@ class Telescopio extends ActorAnimado { super(0, 0, {cantColumnas: 2}); this.definirAnimacion("roto", [1], 1); this.definirAnimacion("arreglado", [0], 1); + this.definirAnimacion("recoger", [0], 1) if(arreglado) this.cargarAnimacion("arreglado") diff --git a/src/actores/segundoCiclo/Yvoty/Yvoty.ts b/src/actores/segundoCiclo/Yvoty/Yvoty.ts index 6ac15bc..81808a6 100644 --- a/src/actores/segundoCiclo/Yvoty/Yvoty.ts +++ b/src/actores/segundoCiclo/Yvoty/Yvoty.ts @@ -33,5 +33,6 @@ class Yvoty extends ActorAnimado { this.definirAnimacion("usarCelu", [38, 38, 38, 39, 39, 40, 40, 40, 41, 42, 43, 41, 43, 42, 42, 42, 44, 45, 46, 47, 46, 42, 42, 42, 45, 46, 46, 46, 45, 44, 48, 48, 48, 49, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 51, 51, 38, 38, 38, 38, 38, 38, 38], 20); this.definirAnimacion("sacarFoto", [38, 38, 38, 39, 39, 40, 40, 40, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 40, 40, 40, 40], 20); this.definirAnimacion("escribir", [16, 16, 17, 17, 18, 18, 18, 19, 19, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18], 20); + this.definirAnimacion("surfear", [52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71], 20) } } diff --git a/src/comportamientos/Escapar.ts b/src/comportamientos/Escapar.ts index a022eec..0c61e30 100644 --- a/src/comportamientos/Escapar.ts +++ b/src/comportamientos/Escapar.ts @@ -9,7 +9,7 @@ class Escapar extends MovimientoAnimado { } preAnimacion(){ - this.argumentos.direccion = new Direct(1, 5); + this.argumentos.direccion = this.argumentos.direccion || new Direct(1,5) this.argumentos.distancia = 600; this.argumentos.velocidad = 8; this.argumentos.cantPasos = 40; @@ -42,4 +42,4 @@ class Escapar extends MovimientoAnimado { return (noTieneQueEscaparConNingunActor || colisionaConElActorParaEscapar); } -} +} \ No newline at end of file diff --git a/src/comportamientos/Irse.ts b/src/comportamientos/Irse.ts deleted file mode 100644 index 6b22179..0000000 --- a/src/comportamientos/Irse.ts +++ /dev/null @@ -1,44 +0,0 @@ -/// - -// Si se pasa por argumento "irseCon" entonces el receptor debe ser actor compuesto -class Irse extends MovimientoAnimado { - - iniciar(receptor){ - this.argumentos.idTransicion = "irse"; - super.iniciar(receptor); - } - - preAnimacion(){ - this.argumentos.direccion = new Direct(1); - this.argumentos.distancia = 600; - this.argumentos.velocidad = 8; - this.argumentos.cantPasos = 40; - - if (this.argumentos.irseCon) { - - if (typeof this.argumentos.irseCon == 'string') { - this.argumentos.irseCon = eval("pilas.escena_actual()." + this.argumentos.irseCon); - } - this.receptor.agregarSubactor(this.argumentos.irseCon); - } - super.preAnimacion(); - } - - configurarVerificaciones() { - super.configurarVerificaciones(); - this.verificacionesPre.push(new Verificacion(() => { - return this.estaEnTransporte(); - }, "Para irse hace falta un transporte")); - } - - estaEnTransporte(){ - if (typeof this.argumentos.irseCon == 'string') { - this.argumentos.irseCon = eval("pilas.escena_actual()." + this.argumentos.irseCon); - } - - let noTieneQueirseConNingunActor = (!this.argumentos.irseCon); - let colisionaConElActorParaIrse = this.receptor.colisiona_con(this.argumentos.irseCon); - - return (noTieneQueirseConNingunActor || colisionaConElActorParaIrse); - } -} diff --git a/src/comportamientos/Sostener.ts b/src/comportamientos/Sostener.ts index 5030454..a9370dc 100644 --- a/src/comportamientos/Sostener.ts +++ b/src/comportamientos/Sostener.ts @@ -20,7 +20,7 @@ class Sostener extends Interactuar { var objetoAgarrado: any = interactuado.clonar() objetoAgarrado.escala = interactuado.escala objetoAgarrado.y = this.receptor.y - objetoAgarrado.x = this.receptor.subactores[0].derecha - (this.receptor.subactores[0].ancho / 4) + objetoAgarrado.x = this.posicionHorizontalDeProximoSubactor() this.receptor.agregarSubactor(objetoAgarrado) objetoAgarrado.cargarAnimacion("correr") // porque tiene que cargar la misma imagen que va a usar al moverse @@ -29,6 +29,10 @@ class Sostener extends Interactuar { } + posicionHorizontalDeProximoSubactor(): number { + return this.receptor.subactores[0].derecha - (this.receptor.subactores[0].ancho / 4) + } + configurarVerificaciones() { super.configurarVerificaciones() this.verificacionesPre.push(new Verificacion(() => this.puedoSostener(), "No puedo sostener dos cosas a la vez...")) diff --git a/src/escenas/libroPrimaria/EscapeEnYacare.ts b/src/escenas/libroPrimaria/EscapeEnYacare.ts new file mode 100644 index 0000000..0919f68 --- /dev/null +++ b/src/escenas/libroPrimaria/EscapeEnYacare.ts @@ -0,0 +1,236 @@ +/// + +class ActorConEntregable extends ActorCompuesto{ + acomodarseEnCapy(capy: CapyConSeguidores): void{ + const entregable = this.subactores.pop() + //capy.agregarSubactor(entregable) + capy.posicionarEnMano(entregable) + } +} + +class TelescopioEntregable extends Telescopio{ + acomodarseEnCapy(capy: CapyConSeguidores): void{ + capy.posicionarEnMano(this) + } +} + +class ManicConPelota extends ActorConEntregable{ + constructor() { + + const manic = new Manic() + manic.escala *= 0.06; + + super(0,0, { subactores: [manic]}); + + const pelota = new Pulpito() + pelota.escala *= 0.02; + pelota.x = manic.derecha + 10 + this.agregarSubactor(pelota) + + + } +} + +class ChuyConCargador extends ActorConEntregable{ + constructor() { + const chuy = new Chuy() + chuy.escala *= 0.05; + + super(0,0, { subactores: [chuy]}); + + const cargador = new Cargador() + cargador.escala *= 0.02; + cargador.x = chuy.derecha + 10 + + this.agregarSubactor(cargador) + } +} + +class YvotySinEntregable extends ActorCompuesto { + + constructor() { + const yvoty = new Yvoty() + yvoty.escala *= 0.05; + super(0,0, { subactores: [yvoty]}); + } + + acomodarseEnCapy(capy: CapyConSeguidores): void{ + + } +} + +class CapyConSeguidores extends ActorCompuesto{ + + entregableEnMano: ActorAnimado + + constructor(){ + const capy = new Capy() + capy.escala *= 0.06 + + super(0,0, { subactores: [capy], puedoSostenerMasDeUno: true}); + } + + entregarSiPuede(){ + if (this.entregableEnMano){ + this.entregableEnMano.eliminar() + this.subactores = this.subactores.filter(actor => actor !== this.entregableEnMano) + this.entregableEnMano = null + } + } + + acomodarEntregable(){ + const actorConEntregable = this.subactores[this.subactores.length - 1] + actorConEntregable.acomodarseEnCapy(this) + } + + posicionarEnMano(entregable: ActorAnimado){ + this.entregableEnMano = entregable + } + + entregar(): void{ + this.entregableEnMano.eliminar() + } + + espejarSeguidor(seguidor, posicion){ + const x = posicion * 50 - 30 + + if (!this.espejado){ + seguidor.x = this.subactores[0].izquierda - x + } + + else { + seguidor.x = this.subactores[0].derecha + x + } + } + + espejarEntregableEnMano(){ + if (!this.espejado){ + this.entregableEnMano.x = this.subactores[0].derecha + } + else{ + this.entregableEnMano.x = this.subactores[0].izquierda + } + } + + tieneAlgoEnLaMano(): boolean{ + return false + } + + actualizar(): void{ + super.actualizar() + this.subactores.forEach((seguidor, indice) => { + if(seguidor !== this.entregableEnMano && indice !== 0){ + this.espejarSeguidor(seguidor,indice) + } + }) + if(this.entregableEnMano){ + this.espejarEntregableEnMano() + } + } +} + +class AgregarASeguidores extends Sostener { + + alInteractuar(): void{ + super.alInteractuar() + this.receptor.entregarSiPuede() + this.receptor.acomodarEntregable() + } + + posicionHorizontalDeProximoSubactor(): number { + return this.receptor.subactores[0].izquierda + 50 * this.receptor.subactores.length + } +} + +class IrseEnYacare extends Escapar { + iniciar(receptor){ + super.iniciar(receptor) + this.argumentos.nombreAnimacion = "surfear" + this.argumentos.direccion = new Direct(1) + this.argumentos.escaparCon = "yacare" + this.argumentos.idTransicion = "irse" + } + + preAnimacion(){ + super.preAnimacion() + this.receptor.eliminarUltimoSubactor() + } +} + +class EscapeEnYacare extends EscenaActividad { + + automata: CapySolo; + telescopio: Telescopio + manic: Manic + chuy: Chuy + yvoty: Yvoty + yacare: Yacare + + iniciar() { + this.fondo = new Fondo('fondo.capy.png', 0, 0); + + this.cuadricula = new Cuadricula(0,0,4,5, + EscenaCapy.opsCuadricula(), + EscenaCapy.opsCasilla()); + + this.telescopio = new TelescopioEntregable(); + this.cuadricula.agregarActor(this.telescopio, 1, 4) + + this.manic = new ManicConPelota() + this.cuadricula.agregarActor(this.manic, 0, 0); + + this.chuy = new ChuyConCargador() + this.cuadricula.agregarActor(this.chuy,2,2); + + this.yvoty = new YvotySinEntregable(); + this.cuadricula.agregarActor(this.yvoty, 1, 2); + + this.automata = new CapyConSeguidores() + this.cuadricula.agregarActor(this.automata, 3, 0); + + this.yacare = new Yacare(); + this.cuadricula.agregarActor(this.yacare, 3, 1); + this.yacare.y -= 10; + this.yacare.escala *= 1.2 + this.yacare.aprender(Flotar, { Desvio: 2 }); + + this.construirFSM(); + } + + + + private construirFSM(){ + const builder= new BuilderStatePattern(this, 'inicial'); + builder.agregarEstado('telescopioEnMano'); + builder.agregarEstado('pelotaEnMano'); + builder.agregarEstado('cargadorEnMano'); + builder.agregarEstado('todosEntregados'); + builder.agregarEstadoAceptacion('montandoYacare'); + + builder.agregarTransicion('inicial','telescopioEnMano','agarrarTelescopio'); + builder.agregarTransicion('telescopioEnMano','pelotaEnMano','entregarTelescopio'); + builder.agregarTransicion('pelotaEnMano','cargadorEnMano','entregarPelota'); + builder.agregarTransicion('cargadorEnMano','todosEntregados','entregarCargador'); + builder.agregarTransicion('todosEntregados','montandoYacare','irse'); + + const estadosEnOrden = ['inicial','telescopioEnMano','pelotaEnMano','cargadorEnMano','montandoYacare'] + + for (let i = 0; i < estadosEnOrden.length; i++) { + if(estadosEnOrden[i]!='telescopioEnMano'){ + builder.agregarError(estadosEnOrden[i],'entregarTelescopio', 'MaƱic necesita su telescopio.'); + } + if(estadosEnOrden[i]!='pelotaEnMano'){ + builder.agregarError(estadosEnOrden[i],'entregarPelota','Chuy necesita su pelota.'); + } + if(estadosEnOrden[i]!='cargadorEnMano'){ + builder.agregarError(estadosEnOrden[i],'entregarCargador','Yvoty necesita su cargador.'); + } + if(estadosEnOrden[i]!='todosEntregados'){ + builder.agregarError(estadosEnOrden[i],'montarYacare','Para montar el yacare todos deben haber recuperado sus cosas.'); + } + } + + this.estado=builder.estadoInicial(); + } + +} \ No newline at end of file diff --git a/src/escenas/libroPrimaria/EscenaCapy.ts b/src/escenas/libroPrimaria/EscenaCapy.ts index 34c063e..174d694 100644 --- a/src/escenas/libroPrimaria/EscenaCapy.ts +++ b/src/escenas/libroPrimaria/EscenaCapy.ts @@ -86,10 +86,10 @@ class EscenaCapy extends EscenaDesdeMapa { cuadriculaY() { return -20; } - opsCuadricula() { + static opsCuadricula() { return { ancho: 400, alto: 380 }; } - opsCasilla() { + static opsCasilla() { return { grilla: 'casillas.capy.png', cantFilas: 1,