/*
   * cambia la dificultad cada cierto tiempo (maximo nivel = 5)
   */
  public int cambioDific() {
    // System.out.println(time.millisElapsed());

    if (time.millisElapsed() >= 30000 && nivelActual == 1) {
      varDific = 250;
      contLV.setValue(2);
      nivelActual = 2;
      velExtra = 1;
    } else if (time.millisElapsed() >= 50000 && nivelActual == 2) {
      varDific = 100;
      contLV.setValue(3);
      nivelActual = 3;
      velExtra = 2;
    } else if (time.millisElapsed() >= 100000 && nivelActual == 3) {
      varDific = 70;
      contLV.setValue(4);
      nivelActual = 4;
      // velExtra=2;
    } else if (time.millisElapsed() >= 150000 && nivelActual == 4) {
      varDific = 50;
      contLV.setValue(5);
      nivelActual = 5;
      if (velExtra < 3) velExtra = 3;
    }
    return (varDific);
  }
Пример #2
0
  public void act() // sean
      {

    if (!played) {
      burningSteppes.playLoop();
      played = !played;
    }
    // makeSmokeFireball();
    counterDelay++;
    if (Greenfoot.isKeyDown("h") && delay > 10) {
      clickSound.play();
      Menu menu = new Menu(getThisWorld());
      Greenfoot.setWorld(menu);
      delay = 0;
    }
    if (getObjects(Ninja.class).size() != 0 && counterDelay >= 10) {
      healthCounter.setValue(ninja.getNINJAHP());
      shurikenCounter.setValue(ninja.getSHURIKENNUMBER());
      powerCounter.setValue(ninja.getPOWERBAR());
      checkDoor();
      counterDelay -= 10;
      /**/
      // TEMPORAY FUNCTIONS FOR HAYDEN TO CHANGE LEVELS TO MAKE THEM /**/

      /**/
      // TEMPORAY FUNCTIONS FOR HAYDEN TO CHANGE LEVELS TO MAKE THEM /**/
    }
    delay++;
    fireballDelay++;
  }
  /*
   * crea los contadores, mensajes, personaje y tiempos del juego
   */
  public void creanivel() {
    time = new SimpleTimer();
    time.mark();
    Barr = new Barra();
    sound2.stop();
    bandBarra = 0;
    varDific = 450;
    nivelActual = 1;
    velExtra = 0;

    orbPj = new Orb();
    addObject(orbPj, 390, 463);

    addObject(new Mensaje("Nivel"), 623, 93);
    addObject(new Mensaje("Vida"), 623, 151);
    addObject(new Mensaje("Tiempo"), 623, 31);
    addObject(new Mensaje("Color seleccionado"), 687, 439);

    contLV = new Counter();
    addObject(contLV, 686, 92);
    contLV.setValue(1);

    contHP = new Counter();
    addObject(contHP, 686, 150);
    contHP.setValue(orbPj.getHP());

    contTime = new Counter();
    addObject(contTime, 686, 30);

    muestraColor = new acColor();
    addObject(muestraColor, 691, 497);

    sound.playLoop();
  }
  @Override
  public boolean applyThis() {
    Counter c = ref.getGame().getObjectById(ref.getTarget()).getCounter(counterName);
    int previousValue = c.getInt();

    switch (mode) {
      case INCR:
        {
          c.tick();
        }
      case DECR:
        {
          c.tick();
        }
      case SET:
        {
          c.tick();
        }
      case PLUS:
        {
          c.modifyValue(value.getInt(ref));
        }
      case MINUS:
        {
          c.modifyValue(-value.getInt(ref));
        }
    }

    if (game.fireEvent(new Event("COUNTER_VALUE_CHANGED", ref))) {
      return true;
    }
    c.setValue(previousValue);

    return false;
  }
  /*
   * espera que se precione un boton, controla el juego; las barras objetos, dificultado y
   * el game over
   */
  public void act() {
    if (opcion == 0) {
      leeboton();
    }

    if (opcion == 1) {
      tiempo();
      agregaBarra();
      agregaObjetos();

      cambioDific();
      muestraColor.cambia(orbPj.getColAct());

      if (orbPj.getGameOver() == 1) {
        opcion = 2;
        sound.stop();
        record = tiempoActual;
        eliminaObjetos();
        setBackground("gameover.png");
        addObject(new Mensaje("ATRAS"), 710, 27);
        bot5 = new boton();
        addObject(bot5, 716, 31);

        addObject(new Mensaje("PUNTUACION"), 400, 458);
        total = new Counter();
        addObject(total, 401, 502);
        total.setValue(record);

        actualizaRecord();
      }

      // System.out.println(orbPj.getGameOver());
    }

    if (opcion == 2) {
      if (Greenfoot.mouseClicked(bot5)) {
        eliminaObjetos();
        opcion = 0;
        sound2.playLoop();
        menu();
      }
    }

    if (opcion == 3) {

      if (Greenfoot.mouseClicked(bot5)) {

        opcion = 2;
        // menu();

      }
    }
  }
Пример #6
0
 private void initCountersUI() {
   DockPanel counterPanel = new DockPanel();
   add(counterPanel);
   minesCounter = new Counter(3);
   minesCounter.setValue(game.getBombCount());
   counterPanel.add(minesCounter, DockPanel.WEST);
   final Counter timeCounter = new Counter(3);
   counterPanel.setHorizontalAlignment(DockPanel.ALIGN_RIGHT);
   counterPanel.add(timeCounter, DockPanel.EAST);
   counterPanel.setWidth(
       Integer.toString(FieldCanvas.SIZE * game.getBoard().getDimension().x) + "px");
   game.getWatch()
       .addListener(
           new IStopWatchListener() {
             @Override
             public void onTimeChange(int currentTime) {
               timeCounter.setValue(currentTime);
             }
           });
 }
Пример #7
0
  private void prepare() // sean
      {
    InfernoDoor door = new InfernoDoor();
    addObject(door, 663 - 50 + 35 + 5, 651 - 50);

    for (int i = 0; i < 14; i++)
      for (int j = 0; j < 2; j++) {
        InfernoFence infernoFence = new InfernoFence();
        addObject(infernoFence, 25 + j * 700, 50 * i + 25);
      }
    for (int i = 1; i < 14; i++)
      for (int j = 0; j < 2; j++) {
        InfernoFence infernoFence = new InfernoFence();
        addObject(infernoFence, 50 * i + 25, 25 + j * (700 - 50));
      }

    for (int i = 0; i < 9; i++) {
      InfernoFence infernoFence = new InfernoFence();
      addObject(infernoFence, 50 * i + 25, 125);
    }
    for (int i = 0; i < 9; i++) {
      InfernoFence infernoFence = new InfernoFence();
      addObject(infernoFence, 50 * i + 175 + 100, 225);
    }

    Firebat firebat2 = new Firebat(8, 3);
    addObject(firebat2, 511, 625);

    Firebat firebat3 = new Firebat(8, 3);
    addObject(firebat3, 588, 534);

    Firebat firebat4 = new Firebat(8, 3);
    addObject(firebat4, 629, 489);

    Firebat firebat5 = new Firebat(8, 3);
    addObject(firebat5, 203, 608);

    Firebat firebat6 = new Firebat(8, 3);
    addObject(firebat6, 484, 388);

    Firebat firebat7 = new Firebat(8, 3);
    addObject(firebat7, 320, 350);

    InfernoFence infernoFence = new InfernoFence();
    addObject(infernoFence, 133, 417);

    InfernoFence infernoFence3 = new InfernoFence();
    addObject(infernoFence3, 164, 571);

    InfernoFence infernoFence5 = new InfernoFence();
    addObject(infernoFence5, 429, 360);

    InfernoFence infernoFence6 = new InfernoFence();
    addObject(infernoFence6, 325, 669);

    InfernoFence infernoFence7 = new InfernoFence();
    addObject(infernoFence7, 452, 571);

    InfernoFence infernoFence8 = new InfernoFence();

    addObject(healthCounter, 866, 120);
    healthCounter.setValue(ninja.getNINJAHP());

    addObject(shurikenCounter, 866, 201);
    shurikenCounter.setValue(ninja.getSHURIKENNUMBER());

    addObject(powerCounter, 866, 161);
    powerCounter.setValue(ninja.getPOWERBAR());

    addObject(levelCounter, 950, 15);
    levelCounter.setValue(31);
    addObject(ninja, 75, 75);
    ninja.setLocation(100, 75);

    HealthGlobe healthglobe = new HealthGlobe();
    addObject(healthglobe, 668, 57);
    healthglobe.setLocation(674, 54);
    HealthGlobe healthglobe2 = new HealthGlobe();
    addObject(healthglobe2, 638, 138);
    healthglobe2.setLocation(672, 110);
    instaPower instapower = new instaPower();
    addObject(instapower, 87, 624);
    instapower.setLocation(76, 623);
    addShuriken addshuriken = new addShuriken();
    addObject(addshuriken, 76, 181);
    addShuriken addshuriken2 = new addShuriken();
    addObject(addshuriken2, 466, 123);
    addshuriken2.setLocation(675, 277);
    instaPower instapower2 = new instaPower();
    addObject(instapower2, 429, 627);
    instapower2.setLocation(431, 625);
    makeAllIcons();
    meleeMinions = getObjects(MeleeMinion.class);
    for (int i = 0; i < meleeMinions.size(); i++) {
      TempText8 text = new TempText8(meleeMinions.get(i));
      addObject(text, meleeMinions.get(i).getX(), meleeMinions.get(i).getY() - 20);
    }
  }
 /*
  * cuenta el tiempo se juego en segundos
  */
 public void tiempo() {
   tiempoActual = time.millisElapsed() / 1000;
   contTime.setValue(tiempoActual);
 }