From ceba6849df381163667a311cd5a14441fc8f892c Mon Sep 17 00:00:00 2001 From: SariusRu Date: Sat, 28 May 2016 14:55:11 +0200 Subject: [PATCH] redrawProvince --- Province.java | 70 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/Province.java b/Province.java index 5230b0a..042f91e 100644 --- a/Province.java +++ b/Province.java @@ -154,8 +154,74 @@ public class Province extends Actor return eCount; } - public void redrawProvince() { - //Platzhalter + public void redrawProvince() + { + GreenfootImage province = new GreenfootImage(100,65); + GreenfootImage provinceName = new GreenfootImage(displayName,16,new Color(0,0,0),new Color(1.0f,1.0f,1.0f,0.5f)); + province.drawImage(provinceName,0,0); + eCalculate(province); + } + + private void eCalculate(GreenfootImage province) + { + int eCountTanks = eCount / 5; + GreenfootImage tryOut = new GreenfootImage("C:\\Users\\samue\\Documents\\GitHub\\zweiundvierzig\\Tank.jpg"); + if(eCountTanks <= 3) + { + if(eCountTanks == 1) + { + province.drawImage(tryOut,0,17); + } + if(eCountTanks == 2) + { + province.drawImage(tryOut,0,17); + province.drawImage(tryOut,17,17); + } + if(eCountTanks == 3) + { + province.drawImage(tryOut,0,17); + province.drawImage(tryOut,17,17); + province.drawImage(tryOut,34,17); + } + } + else + { + GreenfootImage eCountTanksImage = new GreenfootImage(Integer.toString(eCountTanks) + "x",16,Color.CYAN,new Color(1.0f,1.0f,1.0f,0.5f)); + province.drawImage(eCountTanksImage,0,17); + province.drawImage(tryOut,22,18); + } + int eCountHorse = (eCount - (eCountTanks * 5))/3; + if(eCountHorse == 1) + { + province.drawImage(tryOut,0,34); + } + int eCountInf = eCount - (eCountTanks * 5) - (eCountHorse * 3); + if(eCountInf <= 4) + { + if(eCountInf == 1) + { + province.drawImage(tryOut,0,51); + } + if(eCountInf == 2) + { + province.drawImage(tryOut,0,51); + province.drawImage(tryOut,17,51); + } + if(eCountInf == 3) + { + province.drawImage(tryOut,0,51); + province.drawImage(tryOut,17,51); + province.drawImage(tryOut,34,51); + } + if(eCountInf == 4) + { + province.drawImage(tryOut,0,51); + province.drawImage(tryOut,17,51); + province.drawImage(tryOut,34,51); + province.drawImage(tryOut,51,51); + } + } + setImage(province); } }