Exemplo n.º 1
0
  public boolean hatch(NumGen numGen) {
    if (hasHatched()) return false;
    if (!hasStopped()) return false;
    if (age < incubationTime) return false;

    hatchAge = age;
    double angle = numGen.nextInt() % 360;
    hatchedNarjillo =
        new Narjillo(
            dna,
            getPosition(),
            angle,
            new LifeFormEnergy(energy, Configuration.CREATURE_MAX_LIFESPAN));
    energy = 0;
    return true;
  }
Exemplo n.º 2
0
 private int calculateIncubationTime(NumGen numGen) {
   final int MAX_INCUBATION_INTERVAL =
       Configuration.EGG_MAX_INCUBATION_TIME - Configuration.EGG_MIN_INCUBATION_TIME;
   int extraIncubation = (int) (MAX_INCUBATION_INTERVAL * numGen.nextDouble());
   return Configuration.EGG_MIN_INCUBATION_TIME + extraIncubation;
 }