Пример #1
0
 private void addDish() {
   foodTimerDiff = (System.nanoTime() - foodTimer) / 1000000;
   if (foodTimerDiff > foodDelay) { // there will be a 88% chance the next dish will be food
     double chance = Math.random();
     int rail = (int) Math.round(Math.random() * 2);
     if (chance < foodprobability) {
       String food = foodList.get((int) (Math.random() * foodList.size()) % foodList.size());
       Food f = new Food(food, rail, foodValues.get(food));
       f.setPositionInRail(player.getx() + GamePanel.WIDTH + f.getWidth() / 2, rail);
       f.setCamera(camera);
       dishes.add(f);
     } else {
       String power = powerList.get((int) (Math.random() * powerList.size()) % powerList.size());
       Power p = new Power(power, rail);
       p.setPositionInRail(player.getx() + GamePanel.WIDTH + p.getWidth() / 2, rail);
       p.setCamera(camera);
       dishes.add(p);
     }
     foodTimer = System.nanoTime();
     if (difficulty == OptionsState.EASY)
       foodDelay = (long) (Math.random() * fooddelays[0]) + fooddelays[1];
     if (difficulty == OptionsState.NORMAL)
       foodDelay = (long) (Math.random() * fooddelays[2]) + fooddelays[3];
     if (difficulty == OptionsState.HARD)
       foodDelay = (long) (Math.random() * fooddelays[4]) + fooddelays[5];
   }
 }