From 8bf3cbd39373f8154497c4902bd6164f86a0652e Mon Sep 17 00:00:00 2001 From: groche97 Date: Thu, 20 Feb 2020 10:46:04 +0100 Subject: [PATCH] aniadido combo --- core/src/utilidades/Personaje.java | 79 +++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 6 deletions(-) diff --git a/core/src/utilidades/Personaje.java b/core/src/utilidades/Personaje.java index 27a671c..5cc5839 100644 --- a/core/src/utilidades/Personaje.java +++ b/core/src/utilidades/Personaje.java @@ -3,6 +3,7 @@ package utilidades; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; @@ -22,12 +23,18 @@ public class Personaje { private int keyL; int x; int y; + float contadorCombo; + float tempCombo; private float vida; Rectangle caja; Rectangle enemigo; boolean position; ShapeRenderer shapeDrawer; + String combo; + int caracter; public Personaje(String caracter, boolean position) { + this.tempCombo=0; + this.combo=""; shapeDrawer=new ShapeRenderer(); //PolygonShape shape = new PolygonShape(1); this.vida=100; @@ -44,12 +51,15 @@ public class Personaje { this.keyL=Input.Keys.A; switch (caracter) { case "ryu": + this.caracter=1; this.ryu(position); break; case "ken": + this.caracter=2; this.ken(position); break; case "cam": + this.caracter=3; this.cam(position); default: break; @@ -58,22 +68,57 @@ public class Personaje { } public void cambiarEstado(int estado) { + this.boost(estado); switch(estado) { case STAND: this.actual=this.standby; break; case ALTO: this.actual=this.alto; + this.combo+=estado; break; case MEDIO: this.actual=this.medio; + this.combo+=estado; break; case BAJO: this.actual=this.bajo; + this.combo+=estado; break; } } + public void boost(int estado) { + switch(caracter) { + case 1: + if(estado==Personaje.MEDIO) { + if(contadorCombo<2) { + contadorCombo++; + } + }else if(estado==Personaje.ALTO) { + if(contadorCombo>=2) { + contadorCombo=0; + this.tempCombo=5; + } + }else { + contadorCombo=0; + } + break; + case 2: + + break; + case 3: + + break; + default: + break; + } + } + + void aplicarBoost() { + this.tempCombo=10; + } + public void recivir(float danio) { if(this.caja.overlaps(enemigo)) { this.vida-=danio; @@ -82,10 +127,18 @@ public class Personaje { public float atacar(float delta) { if(this.actual==this.medio) { - return delta*10; + if(tempCombo>0) { + return delta*20; + }else { + return delta*10; + } } if(this.actual==this.alto) { - return delta*15; + if(tempCombo>0) { + return delta*30; + }else { + return delta*15; + } } return 0; } @@ -114,10 +167,6 @@ public class Personaje { } public void draw(SpriteBatch batch, float delta) { - this.actual.avanzar(5, delta); - this.actual.draw(batch, this.y, this.x); - - //batch.disableBlending(); batch.end(); shapeDrawer.begin(ShapeType.Filled); shapeDrawer.setColor(Color.GREEN); @@ -128,6 +177,24 @@ public class Personaje { } shapeDrawer.end(); batch.begin(); + this.actual.avanzar(5, delta); + this.actual.draw(batch, this.y, this.x); + batch.end(); + if(tempCombo>0) { + Gdx.gl.glEnable(GL20.GL_BLEND); + Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); + shapeDrawer.begin(ShapeType.Filled); + shapeDrawer.setColor(1f,0f,0f,0.3f); + if(this.position) { + shapeDrawer.circle(y+100, x+80, 80); + }else { + shapeDrawer.circle(y+50, x+80, 80); + } + shapeDrawer.end(); + Gdx.gl.glDisable(GL20.GL_BLEND); + tempCombo-=delta; + } + batch.begin(); } public void dispose() {