path la faute et path des hp+dmg invisible

This commit is contained in:
marc barbier
2021-01-09 12:06:54 +01:00
parent 7fb11f51b0
commit 86657ce1c7
5 changed files with 24 additions and 12 deletions
@@ -21,11 +21,11 @@ public abstract class Card {
* @param c * @param c
*/ */
public Card(String UID,Context c) { public Card(String UID,Context c) {
this.attack=getDefaultAttack();
this.health=getDefaultHealth();
if(!(UID == null || c == null)) { if(!(UID == null || c == null)) {
drawableCard = new DrawableCard(this, 0, 0, UID, c); drawableCard = new DrawableCard(this, 0, 0, UID, c);
} }
this.attack=getDefaultAttack();
this.health=getDefaultHealth();
} }
public int getAttack() { public int getAttack() {
@@ -90,6 +90,7 @@ public class GameLogicThread extends Thread{
//pickDeck(); //pickDeck();
//loading textures //loading textures
Log.i("ressources","loading bitmaps");
Bitmap bitmapYourTurn = BitmapFactory.decodeResource(renderer.getResources(),R.drawable.t_pb_your_turn); Bitmap bitmapYourTurn = BitmapFactory.decodeResource(renderer.getResources(),R.drawable.t_pb_your_turn);
Bitmap bitmapEnemyTurn = BitmapFactory.decodeResource(renderer.getResources(),R.drawable.t_pb_enemy_turn); Bitmap bitmapEnemyTurn = BitmapFactory.decodeResource(renderer.getResources(),R.drawable.t_pb_enemy_turn);
Bitmap bitmapBattlePhase = BitmapFactory.decodeResource(renderer.getResources(),R.drawable.t_pb_battlephase); Bitmap bitmapBattlePhase = BitmapFactory.decodeResource(renderer.getResources(),R.drawable.t_pb_battlephase);
@@ -97,6 +98,7 @@ public class GameLogicThread extends Thread{
Bitmap bitmapVictory = BitmapFactory.decodeResource(cont.getResources(), R.drawable.t_pb_victory); Bitmap bitmapVictory = BitmapFactory.decodeResource(cont.getResources(), R.drawable.t_pb_victory);
Bitmap bitmapDefeat = BitmapFactory.decodeResource(cont.getResources(), R.drawable.t_pb_defeat); Bitmap bitmapDefeat = BitmapFactory.decodeResource(cont.getResources(), R.drawable.t_pb_defeat);
Log.i("loading","prefs");
SharedPreferences sharedPref = gameActivity.getSharedPreferences("handicape",Context.MODE_PRIVATE); SharedPreferences sharedPref = gameActivity.getSharedPreferences("handicape",Context.MODE_PRIVATE);
boolean modeHandicape = sharedPref.getBoolean(gameActivity.getString(R.string.handicape), false); boolean modeHandicape = sharedPref.getBoolean(gameActivity.getString(R.string.handicape), false);
@@ -109,6 +111,8 @@ public class GameLogicThread extends Thread{
} }
Log.i("ressources","base ressources loaded");
//adding the background //adding the background
renderer.addToDraw(new DrawableBitmap(bitmapBackground, 0,0, "background", 100, 100 )); renderer.addToDraw(new DrawableBitmap(bitmapBackground, 0,0, "background", 100, 100 ));
//drawHandPreview(); //drawHandPreview();
@@ -119,9 +123,7 @@ public class GameLogicThread extends Thread{
final int port = 17057; final int port = 17057;
//gameativity.finish() n'etait pas utilisable il fermais l'application //gameativity.finish() n'etait pas utilisable il fermais l'application
Intent intent = new Intent(gameActivity,MainActivity.class);
//on reset le top et recrée l'activité principale
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
try { try {
Socket client = new Socket(host, port); Socket client = new Socket(host, port);
coms= new Communication(client); coms= new Communication(client);
@@ -129,7 +131,7 @@ public class GameLogicThread extends Thread{
Log.e("ERROR SERVER DEAD","srv"); Log.e("ERROR SERVER DEAD","srv");
gameActivity.runOnUiThread(new PopupRunable("erreur de comunication avec le serveur",gameActivity)); gameActivity.runOnUiThread(new PopupRunable("erreur de comunication avec le serveur",gameActivity));
renderer.terminate(); renderer.terminate();
gameActivity.startActivity(intent); returnToTheMainActivity();
return; return;
} }
renderer.updateFrame(); renderer.updateFrame();
@@ -235,7 +237,7 @@ public class GameLogicThread extends Thread{
renderer.updateFrame(); renderer.updateFrame();
cancelled = true; cancelled = true;
currentThread().sleep(2000); currentThread().sleep(2000);
gameActivity.startActivity(intent); returnToTheMainActivity();
break; break;
case Command.LOSE: case Command.LOSE:
//on termine la partie //on termine la partie
@@ -245,7 +247,7 @@ public class GameLogicThread extends Thread{
cancelled=true; cancelled=true;
currentThread().sleep(2000); currentThread().sleep(2000);
//gameativity.finish() n'etait pas utilisable il fermais l'application //gameativity.finish() n'etait pas utilisable il fermais l'application
gameActivity.startActivity(intent); returnToTheMainActivity();
break; break;
case Command.PING: case Command.PING:
coms.send(Command.PONG); coms.send(Command.PONG);
@@ -378,6 +380,18 @@ public class GameLogicThread extends Thread{
} }
} }
private void returnToTheMainActivity() {
gameActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(gameActivity,MainActivity.class);
//on reset le top et recrée l'activité principale
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
gameActivity.startActivity(intent);
}
});
}
/** /**
* cette methode permet d'afficher la main * cette methode permet d'afficher la main
*/ */
@@ -62,7 +62,7 @@ public class GameActivity extends Activity {
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
//kill les threads //kill les threads
System.exit(0); //System.exit(0);
} }
@Override @Override
@@ -15,9 +15,7 @@ public class PopupRunable implements Runnable{
@Override @Override
public void run() { public void run() {
Toast popupToast = new Toast(context); Toast popupToast = Toast.makeText(context,recivedMessage,Toast.LENGTH_LONG);
popupToast.setText(recivedMessage);
popupToast.setDuration(Toast.LENGTH_LONG);
popupToast.show(); popupToast.show();
} }
} }
Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 115 KiB