Example #1
0
  @Override
  public void key(int i, boolean bln) {
    super.key(i, bln);
    if (i == KeyCode.KEY_D) {
      right = bln;
    }
    if (i == KeyCode.KEY_A) {
      left = bln;
    }

    // scare the house the demon is nearby
    if (i == KeyCode.KEY_F) {
      boolean allScared = true;
      for (int j = 0; j < housesPosX.length; j++) {
        if (Math.abs(littleDemonPosX - housesPosX[j] + (houseNotScared.getWidth() / 2)) < 15) {
          SoundPlayer.getSoundPlayer().playScareHouse();
          // SoundPlayer.getSoundPlayer().playDemonSpeaking(); (at the same time?)
          housesScared[j] = true;
        }
        if (!housesScared[j]) {
          allScared = false;
        }
      }
      if (allScared) {
        // complete task when all the houses are scared
        setComplete(true);
        left = false;
        right = false;
      }
    }
  }
Example #2
0
  @Override
  public void render(Graphics2D g2) {
    super.render(g2);
    g2.setColor(Color.BLACK);
    g2.fillRect(0, 0, 400, 300);

    /*
    Debug values
    g2.setColor(Color.BLACK);
    g2.drawString("Scare house task", 40, 60);
    */

    // road
    g2.drawImage(roadImage, 50, 210, null);

    for (int j = 0; j < housesPosX.length; j++) {
      if (housesScared[j]) {
        g2.drawImage(houseIsScared, housesPosX[j] - 20, 160, null);
      } else {
        g2.drawImage(houseNotScared, housesPosX[j] - 20, 160, null);
      }
    }

    // draw the little demon
    g2.drawImage(demonTinyTask, (int) littleDemonPosX - (demonTinyTask.getWidth() / 2), 200, null);

    g2.drawImage(aPrompt, 70, 40, null);
    g2.drawImage(dPrompt, 140, 40, null);
    g2.drawImage(scarePrompt, 230, 40, null);

    // draw complete on finishing the task
    if (isComplete()) {
      g2.drawImage(completePrompt, 0, 0, null);
    }
  }
Example #3
0
  @Override
  public void render(Graphics2D g2) {
    super.render(g2);
    g2.setColor(Color.BLACK);
    g2.fillRect(0, 0, 400, 300);
    g2.drawImage(coffeeMachineImage, 100, 0, null);
    BufferedImage img = null;
    if (coffeeBrew.getProgress() < coffeeBrew.getTargetNumber() / 3) {
      img = images[0];
    } else if (coffeeBrew.getProgress() < (coffeeBrew.getTargetNumber() / 3) * 2) {
      img = images[1];
    } else if (coffeeBrew.getProgress() < coffeeBrew.getTargetNumber()) {
      img = images[2];
    } else {
      img = images[3];
    }
    if (isComplete()) {
      img = images[3]; // show full thing when it's complete
    }
    g2.drawImage(img, 100, 0, null);
    if (stepOn < 3) {
      g2.drawImage(images[6 + stepOn], 100 + (30 * stepOn), 60, null);
    }
    if (stepOn == codes.length && !isComplete()) {
      // show brewing prompt when coffee is being made
      g2.drawImage(images[5], 120, 60, null);
    }

    // draw completed prompt on completion
    if (isComplete()) {
      g2.drawImage(images[4], 0, 0, null);
    }
  }
Example #4
0
 @Override
 public void update(int ms) {
   super.update(ms);
   if (!isComplete()) {
     if (stepOn >= codes.length) {
       coffeeBrew.updateTimer(ms);
     }
   }
 }
Example #5
0
  @Override
  public void key(int keycode, boolean pressed) {
    demonPlayer.key(keycode, pressed);
    // handle input for actice task (only on valid active task)

    if (!isCompletedWithTasks()
        && activeTask != null
        && activeTask == toDoList.get(nextTaskIndex)) {
      activeTask.key(keycode, pressed);
    } else {
      // if it's not the right one on the todo list then see if
      // it's one of the other tasks.
      if ((activeTask instanceof HitImpTask)
          || (activeTask instanceof InterviewTask)
          || (activeTask instanceof PaperworkTask)) {
        activeTask.key(keycode, pressed);
      }
    }
    if (keycode == KeyCode.KEY_T && pressed) {
      // System.out.println("Toggle");
      toggleToDoListVisiblity();
    }
    if (keycode == KeyCode.KEY_Z) {
      if (pressed) {
        demonPlayer.setSpeed(18);
      } else {
        demonPlayer.setSpeed(6);
      }
    }

    // to test days there will be a cheat button
    if (keycode == KeyCode.KEY_K && pressed) {
      paperworkLeft -= 90;
      // System.out.println("Complete all the things");
      for (int i = 0; i < toDoList.size(); i++) {
        toDoList.get(i).setComplete(true);
      }
      nextTaskIndex = toDoList.size();
    }
  }
Example #6
0
 @Override
 public void key(int i, boolean bln) {
   super.key(i, bln);
   if (!bln) {
     return;
   }
   if (stepOn != codes.length && i == codes[stepOn]) {
     stepOn++;
     if (stepOn == codes.length) {
       SoundPlayer.getSoundPlayer().playCoffeeBrewing();
     } else {
       SoundPlayer.getSoundPlayer().playMouseClick();
     }
   }
 }
Example #7
0
 @Override
 public void update(int ms) {
   super.update(ms);
   float demonSpeed = 2.3f;
   if (right) {
     littleDemonPosX += demonSpeed;
     if (littleDemonPosX > 400) {
       littleDemonPosX = 400;
     }
   } else if (left) {
     littleDemonPosX -= demonSpeed;
     if (littleDemonPosX < 0) {
       littleDemonPosX = 0;
     }
   }
 }
Example #8
0
  @Override
  public void render(Object o) {
    Graphics2D g2 = (Graphics2D) o;
    // Clear the background
    g2.setColor(Color.BLACK);
    g2.fillRect(0, 0, 800, 600);
    // 1. clip office work to draw.
    // 800x300 Office world from (0, 0)
    //    draw background(s)
    //    draw all of the office furniture/people
    //    draw the demon
    //    If one is viewing the tasks window, render the tasks.
    Graphics2D officeRender = (Graphics2D) g2.create(0, 0, 800, 300); // reset the graphics

    // Draw the background
    officeRender.drawImage(coolParallaxScrolling, -parallaxOffset, 0, null);
    officeRender.drawImage(coolParallaxScrolling, 800 - parallaxOffset, 0, null);
    officeRender.drawImage(coolParallaxScrolling, -parallaxOffset, 100, null);
    officeRender.drawImage(coolParallaxScrolling, 800 - parallaxOffset, 100, null);

    int offset = ((int) camera.getXLocation()) % officeBackgroundRepeated.getWidth();
    for (int i = 0; i < ((officeBackgroundRepeated.getWidth() / 800) + 1); i++) {
      officeRender.drawImage(
          officeBackgroundRepeated,
          (int) (-offset + (i * officeBackgroundRepeated.getWidth())),
          100,
          null);
    }

    for (int i = 0; i < officeWorld.getEntities().size(); i++) {
      officeWorld.getEntities().get(i).render(officeRender);
    }
    officeRender.dispose();
    // 2. clip task world to draw.
    // 400x300 task world from (200, 300)
    //    If there is an active task, draw it
    //    Otherwise, draw a placeholder(?)
    Graphics2D taskRender = (Graphics2D) g2.create(200, 300, 400, 300);
    /// for (int j=0; j<toDoList.size(); j++) {
    ///     toDoList.get(j).render(g2); // pass the clipped graphics in
    /// }
    if (activeTask != null) {
      // find what task needs to be done next
      activeTask.render(taskRender);
      if (!isCompletedWithTasks()
          && activeTask != toDoList.get(nextTaskIndex)
          && !activeTask.isComplete()
          && !(activeTask instanceof HitImpTask)
          && !(activeTask instanceof InterviewTask)
          && !(activeTask instanceof PaperworkTask)) {
        // prompt that the task is visited too  early
        taskRender.drawImage(canNotDoYetPrompt, 0, 0, null);
      }
    } else {
      // Whatever is there with no task
    }
    taskRender.dispose();

    if (isFinishedWithDailyThings() && !viewingCompletedDay) {
      // SoundPlayer.getSoundPlayer().playVictoryMusic();
      SoundPlayer.getSoundPlayer().setMusicTo(SoundPlayer.NONE);
      SoundPlayer.getSoundPlayer().playVictoryMusic();
      viewingCompletedDay = true;
    }

    // draw the to-do list on top of everything
    if (viewingTasks) {
      // View all of the tasks.
    }
    gui.render(o);
    // Draw borders

    g2.drawImage(border, 0, 300, null);
    g2.drawImage(border2, 196, 306, null);
    g2.drawImage(border2, 598, 306, null);

    // render employee status gui according to what state they're in.
    for (int i = 0; i < workers.length; i++) {
      g2.drawImage(workerHeadsIcon[(workers[i].getState())], 495 + (50 * i), 10, null);
    }

    BufferedImage dayImg = getAssetManager().getImage("day" + (dayOn + 1));
    if (dayImg != null) {
      g2.drawImage(dayImg, 10, 10, null);
    }

    // draw the alert GUI warning about an imp attack
    for (int i = 0; i < impTaskObjects.size(); i++) {
      int yPos = 30 + (i * 25);
      int xPos = (int) (impTaskObjects.get(i).getX() - camera.getXLocation());
      // contain it to the screen so one can see what direction to go.
      if (xPos < 10) {
        xPos = 10;
      } else if (xPos > 730) {
        xPos = 770;
      }
      g2.drawImage(impAlertImage, xPos, yPos, null);
    }

    // Draw an imp that is flying across the screen
    if (showImp) {
      g2.drawImage(
          impImage,
          impXLoc - (impImage.getWidth() / 2),
          (int) ((((float) ((impXLoc - 400) * (impXLoc - 400))) / 1000) + 150)
              - (impImage.getHeight() / 2),
          null);
    }

    if (viewingCompletedDay) {
      // g2.drawImage(completeDay, 200, 150, null);
    }

    // draw the todolist last to go on top
    todoListGuiElement.render(o);

    /*
    Debugging things
    */
    /*
    g2.setColor(Color.WHITE);
    g2.fillRect(0, 0, 150, 50);
    g2.setColor(Color.BLACK);
    g2.drawString("activeTask: " + activeTask, 10, 20);
    g2.drawString("paperworkLeft: " + paperworkLeft, 10, 30);
    */
  }