Fix: Ahora no se paraliza el minijuego al generar una nueva combinacion de estratagema
Some checks failed
Build Android APK / build (push) Has been cancelled
Some checks failed
Build Android APK / build (push) Has been cancelled
This commit is contained in:
@@ -10,6 +10,7 @@ import android.widget.FrameLayout;
|
|||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
@@ -194,6 +195,8 @@ private static final String[] NAMES = {
|
|||||||
private LinearLayout sequenceContainer;
|
private LinearLayout sequenceContainer;
|
||||||
private ImageButton btnUp, btnDown, btnLeft, btnRight;
|
private ImageButton btnUp, btnDown, btnLeft, btnRight;
|
||||||
private android.widget.Button btnVolver;
|
private android.widget.Button btnVolver;
|
||||||
|
private ProgressBar progressBar;
|
||||||
|
private ImageView ivFailure;
|
||||||
|
|
||||||
private int[] sequence;
|
private int[] sequence;
|
||||||
private int playerIndex = 0;
|
private int playerIndex = 0;
|
||||||
@@ -201,6 +204,7 @@ private static final String[] NAMES = {
|
|||||||
private boolean esperando = false;
|
private boolean esperando = false;
|
||||||
private boolean juegoActivo = true;
|
private boolean juegoActivo = true;
|
||||||
private int currentStratagemIndex = 0;
|
private int currentStratagemIndex = 0;
|
||||||
|
private boolean bloqueado = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -218,6 +222,8 @@ private static final String[] NAMES = {
|
|||||||
btnLeft = findViewById(R.id.btn_left);
|
btnLeft = findViewById(R.id.btn_left);
|
||||||
btnRight = findViewById(R.id.btn_right);
|
btnRight = findViewById(R.id.btn_right);
|
||||||
btnVolver = findViewById(R.id.btn_volver);
|
btnVolver = findViewById(R.id.btn_volver);
|
||||||
|
progressBar = findViewById(R.id.progress_bar);
|
||||||
|
ivFailure = findViewById(R.id.iv_failure);
|
||||||
|
|
||||||
btnVolver.setOnClickListener(v -> finish());
|
btnVolver.setOnClickListener(v -> finish());
|
||||||
|
|
||||||
@@ -245,6 +251,10 @@ private static final String[] NAMES = {
|
|||||||
currentStratagemIndex = idx;
|
currentStratagemIndex = idx;
|
||||||
playerIndex = 0;
|
playerIndex = 0;
|
||||||
juegoActivo = true;
|
juegoActivo = true;
|
||||||
|
bloqueado = false;
|
||||||
|
|
||||||
|
if (progressBar != null) progressBar.setVisibility(View.GONE);
|
||||||
|
if (ivFailure != null) ivFailure.setVisibility(View.GONE);
|
||||||
|
|
||||||
if (ivStratagemIcon != null) {
|
if (ivStratagemIcon != null) {
|
||||||
try {
|
try {
|
||||||
@@ -258,7 +268,7 @@ private static final String[] NAMES = {
|
|||||||
secuenciaMostrar();
|
secuenciaMostrar();
|
||||||
|
|
||||||
handler.removeCallbacksAndMessages(null);
|
handler.removeCallbacksAndMessages(null);
|
||||||
handler.postDelayed(() -> { esperando = true; }, 1200);
|
esperando = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String ARROW_CHARS = "\u2191\u2193\u2190\u2192";
|
private static final String ARROW_CHARS = "\u2191\u2193\u2190\u2192";
|
||||||
@@ -293,7 +303,8 @@ private static final String[] NAMES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onInput(int dir) {
|
private void onInput(int dir) {
|
||||||
if (!juegoActivo || !esperando) return;
|
if (!juegoActivo || !esperando || bloqueado) return;
|
||||||
|
bloqueado = true;
|
||||||
|
|
||||||
if (dir == sequence[playerIndex]) {
|
if (dir == sequence[playerIndex]) {
|
||||||
playerIndex++;
|
playerIndex++;
|
||||||
@@ -313,13 +324,22 @@ private static final String[] NAMES = {
|
|||||||
completadas++;
|
completadas++;
|
||||||
if (tvCounter != null) tvCounter.setText(String.valueOf(completadas));
|
if (tvCounter != null) tvCounter.setText(String.valueOf(completadas));
|
||||||
esperando = false;
|
esperando = false;
|
||||||
handler.postDelayed(this::nuevaRonda, 1200);
|
if (progressBar != null) {
|
||||||
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
|
handler.postDelayed(() -> {
|
||||||
|
if (progressBar != null) progressBar.setVisibility(View.GONE);
|
||||||
|
}, 300);
|
||||||
|
}
|
||||||
|
handler.postDelayed(this::nuevaRonda, 300);
|
||||||
|
} else {
|
||||||
|
bloqueado = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (soundManager != null) {
|
if (soundManager != null) {
|
||||||
try { soundManager.playFailure(); } catch (Exception e) {}
|
try { soundManager.playFailure(); } catch (Exception e) {}
|
||||||
}
|
}
|
||||||
juegoActivo = false;
|
juegoActivo = false;
|
||||||
|
if (ivFailure != null) ivFailure.setVisibility(View.VISIBLE);
|
||||||
handler.postDelayed(this::nuevaRonda, 1500);
|
handler.postDelayed(this::nuevaRonda, 1500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
20
app/src/main/res/drawable/ic_failure.xml
Normal file
20
app/src/main/res/drawable/ic_failure.xml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="150dp"
|
||||||
|
android:height="150dp"
|
||||||
|
android:viewportWidth="150"
|
||||||
|
android:viewportHeight="150">
|
||||||
|
<!-- Red circle background -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#CC0000"
|
||||||
|
android:pathData="M75,75m-60,0a60,60 0,1 1,120 0a60,60 0,1 1,-120 0"/>
|
||||||
|
<!-- X mark -->
|
||||||
|
<path
|
||||||
|
android:strokeWidth="10"
|
||||||
|
android:strokeColor="#FFFFFF"
|
||||||
|
android:pathData="M45,45L105,105"/>
|
||||||
|
<path
|
||||||
|
android:strokeWidth="10"
|
||||||
|
android:strokeColor="#FFFFFF"
|
||||||
|
android:pathData="M105,45L45,105"/>
|
||||||
|
</vector>
|
||||||
@@ -205,4 +205,22 @@
|
|||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
android:src="@drawable/stratagemas_icon" />
|
android:src="@drawable/stratagemas_icon" />
|
||||||
|
|
||||||
|
<!-- Loading Spinner -->
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress_bar"
|
||||||
|
android:layout_width="80dp"
|
||||||
|
android:layout_height="80dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:indeterminateTint="#FFD700"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<!-- Failure Indicator (X) -->
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_failure"
|
||||||
|
android:layout_width="150dp"
|
||||||
|
android:layout_height="150dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:src="@drawable/ic_failure"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
Reference in New Issue
Block a user