Esempio n. 1
0
  /**
   * Initialize the target for the Status to follow
   *
   * @param maxCountDown Maximum countdown duration. currCountDown Current countdown duration target
   *     The target status is attached to stts Status(available string words are : "Flight", "Fire
   *     Power", "Black Hole", "Invincibility".
   */
  public Status(int maxCountDown, int currCountDown, Actor target, String stts) {

    this(maxCountDown, currCountDown, stts);
    this.target = target; // set the target that the status is attached to
    this.selection = false; // Make the status an actual countdown
    update(); // draws the status on myImage
  }
Esempio n. 2
0
  /**
   * Decreases the count down value of status duration, bar width and displays the percentate of
   * status duration left If there is a target, When status duration reaches zero, the status
   * disappears.
   *
   * @param change The Change in status duration value each Act
   */
  public void update(int change) {

    if (currCountDown > 0) {
      currCountDown -= change; // decreases the current countdown by the change value
      percentCountdown =
          (double) currCountDown
              / maxCountDown; // set a double value of percent countdown by dividing current
                              // countdown by maximum countdown
      currBarWidth =
          (int)
              (percentCountdown
                  * barWidth); // set a interger value of current bar width by multiplying percent
                               // countdown and bar width and casting them into a interger value
      percentDisplay =
          (int)
              (percentCountdown
                  * 100); // set a interget value of percentDisplay by multiplying percentCountdown
                          // by 100.
      percentCounter =
          Integer.toString(
              percentDisplay); // cast the interger percentDisplay into a string and store it in
                               // percentCouner
      myImage.clear(); // clears the image
      myImage.drawString(percentCounter + "%", 70, 30); // draws the percentCounter on myImage
      if (currBarWidth > 1) bar.scale(currBarWidth, BAR_HEIGHT); // rescale the bar size
      if (selection == true) if (currCountDown == 1) currCountDown += 1;
      update(); // redraw the image
    }
    if (selection == false)
      if (currCountDown == 0) // if current countdown is 0
      removeStatus(); // remove status
  }
Esempio n. 3
0
  /**
   * Initialize the current countdown duration, and max count down with the status.
   *
   * @param maxCountDown Maximum countdown duration. currCountDown Current countdown duration stts
   *     status(available string words are : "Flight", "Fire Power", "Black Hole", "Invincibility".
   */
  public Status(int maxCountDown, int currCountDown, String stts) {

    this(stts);
    this.maxCountDown = maxCountDown; // Initialize maximum countdown duration
    this.currCountDown = currCountDown; // Initialize current countdown duration
    update(); // draws the status on myImage
  }
Esempio n. 4
0
 /**
  * If a target exist, status would appear above the target until the count down duration is 0. If
  * target is removed the status is removed as well.
  */
 public void act() {
   if (target != null) // if a target is assigned to a status
   {
     if (target.getWorld() != null) {
       setLocation(target.getX(), target.getY() - OFFSET); // offset myImage above the actor
       update(1); // update the image with the actual countdown(not controlled by keyboard)
     } else removeStatus(); // remove status along with actor
   }
 }
Esempio n. 5
0
  /**
   * Set the status attribute
   *
   * @param stts status(available string words are : "Flight", "Fire Power", "Black Hole",
   *     "Invincibility".
   */
  public Status(String stts) {

    this();
    this.status = stts; // initialize the status
    update(); // draws the status on myImage
  }