I have a problem with spawning new Actors! At the start of the Game there are 6 Zombies in the world, after a while I want to spawn more zombies, but I only want that one Zombie is spawning in the map, but if there are 4 Zombies in the world, other 4 Zombies are spawning, if there are 8, also 8 Zombies are spawning. And if there are 0 Zombies in the world other Zombies will never spawn and I don't understand why
There are a lot of different places in the world because I don't want to spawn them randomly...
I hope you can help me with the problem :)
public void SpawnZombie() //sorgt dafür das neue Zombies erscheinen
{
Zcount++;
Actor Tank = getOneIntersectingObject(tank.class);
RNumber = Greenfoot.getRandomNumber(15);
if (Zcount == 500 && tank.class != null && RNumber == 1){ // Zombies können erscheinen wenn Zcount auf 500 ist und es nicht schon über 4 mal neue Zombies gab.
Zombie zombie = new Zombie();
getWorld().addObject (new Zombie(), 662, 738);
Zcount = 0;
}
if (Zcount == 500 && tank.class != null && RNumber == 2){ // Zombies können erscheinen wenn Zcount auf 500 ist und es nicht schon über 4 mal neue Zombies gab.
Zombie zombie = new Zombie();
getWorld().addObject (new Zombie(), 115, 84);
Zcount = 0;
}
if (Zcount == 500 && tank.class != null && RNumber == 3){ // Zombies können erscheinen wenn Zcount auf 500 ist und es nicht schon über 4 mal neue Zombies gab.
Zombie zombie = new Zombie();
getWorld().addObject (new Zombie(), 1515, 94);
Zcount = 0;
}
if (Zcount == 500 && tank.class != null && RNumber == 4){ // Zombies können erscheinen wenn Zcount auf 500 ist und es nicht schon über 4 mal neue Zombies gab.
Zombie zombie = new Zombie();
getWorld().addObject (new Zombie(), 1511, 719);
Zcount = 0;
}
if (Zcount == 500 && tank.class != null && RNumber == 5){ // Zombies können erscheinen wenn Zcount auf 500 ist und es nicht schon über 4 mal neue Zombies gab.
Zombie zombie = new Zombie();
getWorld().addObject (new Zombie(), 662, 738);
Zcount = 0;
}
if (Zcount == 500 && tank.class != null && RNumber == 6){ // Zombies können erscheinen wenn Zcount auf 500 ist und es nicht schon über 4 mal neue Zombies gab.
Zombie zombie = new Zombie();
getWorld().addObject (new Zombie(), 1216, 387);
Zcount = 0;
}
if (Zcount == 500 && tank.class != null && RNumber == 7){ // Zombies können erscheinen wenn Zcount auf 500 ist und es nicht schon über 4 mal neue Zombies gab.
Zombie zombie = new Zombie();
getWorld().addObject (new Zombie(), 535, 321);
Zcount = 0;
}
if (Zcount == 500 && tank.class != null && RNumber == 8){ // Zombies können erscheinen wenn Zcount auf 500 ist und es nicht schon über 4 mal neue Zombies gab.
Zombie zombie = new Zombie();
getWorld().addObject (new Zombie(), 297, 458);
Zcount = 0;
}
if (Zcount == 500 && tank.class != null && RNumber == 9){ // Zombies können erscheinen wenn Zcount auf 500 ist und es nicht schon über 4 mal neue Zombies gab.
Zombie zombie = new Zombie();
getWorld().addObject (new Zombie(), 927, 736);
Zcount = 0;
}
if (Zcount == 500 && tank.class != null && RNumber == 10){ // Zombies können erscheinen wenn Zcount auf 500 ist und es nicht schon über 4 mal neue Zombies gab.
Zombie zombie = new Zombie();
getWorld().addObject (new Zombie(), 795, 185);
Zcount = 0;
}
if (Zcount == 500 && tank.class != null && RNumber == 11){ // Zombies können erscheinen wenn Zcount auf 500 ist und es nicht schon über 4 mal neue Zombies gab.
Zombie zombie = new Zombie();
getWorld().addObject (new Zombie(), 1164, 119);
Zcount = 0;
}
if (Zcount == 500 && tank.class != null && RNumber == 12){ // Zombies können erscheinen wenn Zcount auf 500 ist und es nicht schon über 4 mal neue Zombies gab.
Zombie zombie = new Zombie();
getWorld().addObject (new Zombie(), 386, 160);
Zcount = 0;
}
if (Zcount == 500 && tank.class != null && RNumber == 13){ // Zombies können erscheinen wenn Zcount auf 500 ist und es nicht schon über 4 mal neue Zombies gab.
Zombie zombie = new Zombie();
getWorld().addObject (new Zombie(), 1041, 73);
Zcount = 0;
}
if (Zcount == 500 && tank.class != null && RNumber == 14){ // Zombies können erscheinen wenn Zcount auf 500 ist und es nicht schon über 4 mal neue Zombies gab.
Zombie zombie = new Zombie();
getWorld().addObject (new Zombie(), 256, 620);
Zcount = 0;
}
if (Zcount == 500 && tank.class != null && RNumber == 15){ // Zombies können erscheinen wenn Zcount auf 500 ist und es nicht schon über 4 mal neue Zombies gab.
Zombie zombie = new Zombie();
getWorld().addObject (new Zombie(), 828, 742);
Zcount = 0;
}
}



