import java.util.*; /** * @author Nicklas Hjalmarsson * @version 1.0 * * Datatype for an Egg */ public class Egg{ Dragon dragon; ValueBar timeLeft; ValueBar heat; ClientThread ct; boolean hatched; int pos; /** * This is the constructor you should use. */ public Egg(ClientThread c){ ct = c; if(ct.eggs >0){ ct.eggs--; timeLeft = new ValueBar("Time left",100,false); heat = new ValueBar("Heat",50,true); dragon = new Dragon(); dragon.Strength = 0; dragon.Speed = 0; dragon.Perception = 0; dragon.Wisdom = 0; dragon.name += " hatchling"; //Stoppa in ägget där det får plats for(int i = 0;i0) timeLeft.setValue(t-h); else hatch(); } /** * @return how much the Egg cost to uphold each turn */ public int cost(){ return 10 + heat.getValue()/5; } /** * Set out the newly hatched dragon on the map */ public void hatch(){ Area a = ((City)ct.cities.get(ct.homeCityName)).getArea(ct.map); dragon.X_position = a.x; dragon.Y_position = a.y; dragon.X_destination = a.x; dragon.Y_destination = a.y; dragon.Owner = ct.playerNr; ct.requestname++; System.out.println("A new dragon was borned"); hatched = true; } /** * Remove the egg and its valuebars. */ public void remove(){ ct.eggPanel.remove(timeLeft); ct.eggPanel.remove(heat); ct.activeEggs[pos]= null; for(int i = 0;i