ajout des hp et des degats sur les cartes GRAND format
This commit is contained in:
@@ -92,6 +92,8 @@ public class Drawable {
|
||||
|
||||
List<String> linesOfText = cutText(20,text);
|
||||
|
||||
Log.i("bitmap"," : h:" + 40*linesOfText.size() + " w: "+text.length()*textSize / linesOfText.size());
|
||||
|
||||
bitmap = Bitmap.createBitmap((int)(text.length()*textSize / linesOfText.size()), (int) 40*linesOfText.size(), Bitmap.Config.ARGB_8888);
|
||||
|
||||
checkPaint();
|
||||
@@ -221,6 +223,7 @@ public class Drawable {
|
||||
Log.e("TextRender","ERROR WORD TOO LONG :" + word);
|
||||
}
|
||||
}
|
||||
if(!nextLine.equals(""))output.add(nextLine);
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ public class DrawableCard extends Drawable{
|
||||
|
||||
private static final int CARD_WITH = 14;
|
||||
private static final int CARD_HEIGHT = 32;
|
||||
private static final float HP_ATK_FONT_SIZE =10F;
|
||||
|
||||
private String color;
|
||||
|
||||
@@ -25,11 +26,15 @@ public class DrawableCard extends Drawable{
|
||||
private Drawable cardOnBardDrawable;
|
||||
private Drawable cardDescription;
|
||||
|
||||
private Drawable cardHpDrawable;
|
||||
private Drawable cardAtkDrawable;
|
||||
|
||||
|
||||
public DrawableCard(Card c, float x, float y, String name, Context context) throws InvalidDataException {
|
||||
super(c.getFrameBitmap(context),x,y,name,CARD_WITH,CARD_HEIGHT);
|
||||
|
||||
cardDescription = new Drawable(c.getDescription(),x+CARD_WITH*0.1F,y+CARD_HEIGHT/2,name,CARD_WITH,CARD_HEIGHT/2,10F);
|
||||
cardDescription = new Drawable(c.getDescription(),x+1F,y+CARD_HEIGHT/2,toString()+"description",CARD_WITH,CARD_HEIGHT/2,10F);
|
||||
updateHpAndAtk(c.getAttack(),c.getHealth());
|
||||
|
||||
color = c.getColor();//CARD_WITH+x
|
||||
Rectangle cardRect = new Rectangle(x,y,(float)(CARD_WITH+x),(float)(CARD_HEIGHT+x));
|
||||
@@ -65,6 +70,18 @@ public class DrawableCard extends Drawable{
|
||||
onBoard=false;
|
||||
}
|
||||
|
||||
/**
|
||||
* cette fonction permet de mettre a jour le nombre de hp restant
|
||||
* si vous ne voulez pas changer une des donnes metter la null ce n'est pas des int mais des Integer donc c'est possible
|
||||
* @param atk l'attaque de la carte
|
||||
* @param hp les point de vie de la carte
|
||||
*/
|
||||
public void updateHpAndAtk(Integer atk,Integer hp)
|
||||
{
|
||||
if(atk != null)cardAtkDrawable = new Drawable(atk+" ",getX()+0.6F,getY()+CARD_HEIGHT-5F,toString()+"atk",CARD_WITH/2,CARD_HEIGHT/8,HP_ATK_FONT_SIZE);
|
||||
if(hp != null)cardHpDrawable = new Drawable(hp+" ",getX()+2.4F+CARD_WITH/2,getY()+CARD_HEIGHT-5F,toString()+"hp",CARD_WITH/2,CARD_HEIGHT/8,HP_ATK_FONT_SIZE);
|
||||
}
|
||||
|
||||
private String removeAlpha(String color) {
|
||||
char[] colorArray = color.toCharArray();
|
||||
if(colorArray[1]=='0' && colorArray[2]=='0')return "#FFFFFFFF";
|
||||
@@ -82,13 +99,18 @@ public class DrawableCard extends Drawable{
|
||||
cardOnBardDrawable.drawOn(c,p);
|
||||
PictureDrawable.drawOn(c,p);
|
||||
|
||||
|
||||
cardHpDrawable.drawOn(c,p);
|
||||
cardAtkDrawable.drawOn(c,p);
|
||||
}else{
|
||||
super.drawOn(c, p);
|
||||
OpacityRectangleDrawable.drawOn(c,p);
|
||||
PictureDrawable.drawOn(c,p);
|
||||
cardDescription.drawOn(c,p);
|
||||
//draw text in the card
|
||||
|
||||
//dessine le texte
|
||||
cardDescription.drawOn(c,p);
|
||||
cardHpDrawable.drawOn(c,p);
|
||||
cardAtkDrawable.drawOn(c,p);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -98,11 +120,15 @@ public class DrawableCard extends Drawable{
|
||||
if (onBoard) {
|
||||
cardOnBardDrawable.setCoordinates(x,y);
|
||||
PictureDrawable.setCoordinates(x +1, y +2);
|
||||
cardAtkDrawable.setCoordinates(getX()+0.6F,getY()+CARD_HEIGHT-5F);
|
||||
cardHpDrawable.setCoordinates(getX()+2.4F+CARD_WITH/2,getY()+CARD_HEIGHT-5F);
|
||||
}else{
|
||||
super.setCoordinates(x, y);
|
||||
OpacityRectangleDrawable.setCoordinates(x, y);
|
||||
PictureDrawable.setCoordinates(x + 1.1F, y + 2.5F);
|
||||
cardDescription.setCoordinates(x,y);
|
||||
cardDescription.setCoordinates(x+CARD_WITH*0.1F,y+CARD_HEIGHT/2);
|
||||
cardAtkDrawable.setCoordinates(x+1F,getY()+CARD_HEIGHT-5F);
|
||||
cardHpDrawable.setCoordinates(x+1F+CARD_WITH/2,getY()+CARD_HEIGHT-5F);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user