ajout des hp et des degats sur les cartes GRAND format
This commit is contained in:
@@ -10,9 +10,6 @@ import com.iutlaval.myapplication.Game.Board;
|
|||||||
import com.iutlaval.myapplication.R;
|
import com.iutlaval.myapplication.R;
|
||||||
|
|
||||||
public abstract class Card {
|
public abstract class Card {
|
||||||
private int health;
|
|
||||||
private int attack;
|
|
||||||
|
|
||||||
private static Bitmap frameBitmap = null;
|
private static Bitmap frameBitmap = null;
|
||||||
|
|
||||||
public void onCardAttack(Board board){}
|
public void onCardAttack(Board board){}
|
||||||
@@ -68,4 +65,10 @@ public abstract class Card {
|
|||||||
|
|
||||||
public abstract String getDescription();
|
public abstract String getDescription();
|
||||||
//TODO
|
//TODO
|
||||||
|
|
||||||
|
|
||||||
|
public abstract int getAttack();
|
||||||
|
|
||||||
|
public abstract int getHealth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,4 +22,14 @@ public class DemoCard extends Card{
|
|||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec volutpat metus eu augue aliquet, nec accumsan tellus aliquam. Nullam eu consectetur quam.";
|
return "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec volutpat metus eu augue aliquet, nec accumsan tellus aliquam. Nullam eu consectetur quam.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAttack() {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHealth() {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ public class Drawable {
|
|||||||
|
|
||||||
List<String> linesOfText = cutText(20,text);
|
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);
|
bitmap = Bitmap.createBitmap((int)(text.length()*textSize / linesOfText.size()), (int) 40*linesOfText.size(), Bitmap.Config.ARGB_8888);
|
||||||
|
|
||||||
checkPaint();
|
checkPaint();
|
||||||
@@ -221,6 +223,7 @@ public class Drawable {
|
|||||||
Log.e("TextRender","ERROR WORD TOO LONG :" + word);
|
Log.e("TextRender","ERROR WORD TOO LONG :" + word);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!nextLine.equals(""))output.add(nextLine);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public class DrawableCard extends Drawable{
|
|||||||
|
|
||||||
private static final int CARD_WITH = 14;
|
private static final int CARD_WITH = 14;
|
||||||
private static final int CARD_HEIGHT = 32;
|
private static final int CARD_HEIGHT = 32;
|
||||||
|
private static final float HP_ATK_FONT_SIZE =10F;
|
||||||
|
|
||||||
private String color;
|
private String color;
|
||||||
|
|
||||||
@@ -25,11 +26,15 @@ public class DrawableCard extends Drawable{
|
|||||||
private Drawable cardOnBardDrawable;
|
private Drawable cardOnBardDrawable;
|
||||||
private Drawable cardDescription;
|
private Drawable cardDescription;
|
||||||
|
|
||||||
|
private Drawable cardHpDrawable;
|
||||||
|
private Drawable cardAtkDrawable;
|
||||||
|
|
||||||
|
|
||||||
public DrawableCard(Card c, float x, float y, String name, Context context) throws InvalidDataException {
|
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);
|
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
|
color = c.getColor();//CARD_WITH+x
|
||||||
Rectangle cardRect = new Rectangle(x,y,(float)(CARD_WITH+x),(float)(CARD_HEIGHT+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;
|
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) {
|
private String removeAlpha(String color) {
|
||||||
char[] colorArray = color.toCharArray();
|
char[] colorArray = color.toCharArray();
|
||||||
if(colorArray[1]=='0' && colorArray[2]=='0')return "#FFFFFFFF";
|
if(colorArray[1]=='0' && colorArray[2]=='0')return "#FFFFFFFF";
|
||||||
@@ -82,13 +99,18 @@ public class DrawableCard extends Drawable{
|
|||||||
cardOnBardDrawable.drawOn(c,p);
|
cardOnBardDrawable.drawOn(c,p);
|
||||||
PictureDrawable.drawOn(c,p);
|
PictureDrawable.drawOn(c,p);
|
||||||
|
|
||||||
|
|
||||||
|
cardHpDrawable.drawOn(c,p);
|
||||||
|
cardAtkDrawable.drawOn(c,p);
|
||||||
}else{
|
}else{
|
||||||
super.drawOn(c, p);
|
super.drawOn(c, p);
|
||||||
OpacityRectangleDrawable.drawOn(c,p);
|
OpacityRectangleDrawable.drawOn(c,p);
|
||||||
PictureDrawable.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) {
|
if (onBoard) {
|
||||||
cardOnBardDrawable.setCoordinates(x,y);
|
cardOnBardDrawable.setCoordinates(x,y);
|
||||||
PictureDrawable.setCoordinates(x +1, y +2);
|
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{
|
}else{
|
||||||
super.setCoordinates(x, y);
|
super.setCoordinates(x, y);
|
||||||
OpacityRectangleDrawable.setCoordinates(x, y);
|
OpacityRectangleDrawable.setCoordinates(x, y);
|
||||||
PictureDrawable.setCoordinates(x + 1.1F, y + 2.5F);
|
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