de.uni_paderborn.robots.gui
Class CutScene

java.lang.Object
  |
  +--de.uni_paderborn.robots.gui.CutScene

public class CutScene
extends java.lang.Object

This class implements the CutScenes for important events. At the moment, there are five different CutScenes:

  1. When both robots want to swap cards.
  2. When one robot wants to swap and the other does not.
  3. When a robot has to be disqualified.
  4. When a robot runs out of energy.


    Inner Class Summary
    private  class CutScene.Animation
              class to control the animation.
    private  class CutScene.Controller
              The inner class Controller represents a JFrame where you can activate or deactivate the CutScenes.
    private  class CutScene.Drawing
              This class contains the image that has to be drawn and it's ms, that is the time it will appear on screen.
    private  class CutScene.Painting
              The Painting is the component, where the sequence will be painted.
     
    Field Summary
    private  CutScene.Animation anim
              The current Animation object
    private  boolean callFromGUI
              indicating whether the CutScene has been evoked from the GUI
    private  CutScene.Controller controller
              The current Controller object
    private  java.lang.String dirDisqualify
              the directory for the images of the disqualified-robot
    private  java.lang.String dirLeftCommon
              the directory for the images of the robot on the left hand side
    private  java.lang.String dirNoSwap
              the directory for the images of the non-swapping-robot
    private  java.lang.String dirOutOfEnergy
              the directory for the images of the out-of-energy-robot
    private  java.lang.String dirRightCommon
              the directory for the images of the robot on the right hand side
    private  java.lang.String dirRobot
              the directory for the images of the robots in general
    private  java.lang.String dirSwap
              the directory for the images of the swapping-robot
    private  java.lang.String dirVictory
              the directory for the images of the victory-robot
    private static int DISQUALIFY
              Parameter for getting the images of the DISQUALIFY scene.
    private static int NO_ENERGY
              Parameter for getting the images of the SWAP scene.
    private static int NO_SWAP_LEFT
              Parameter for getting the images of the SWAP scene.
    private static int NO_SWAP_RIGHT
              Parameter for getting the images of the NO_SWAP scene.
    private  CutScene.Painting painting
              The current Painting object
    private  java.util.Random rand
              An instance of Random for the ranom()-method.
    private  java.lang.String root
              the root directory all images are in
    private static int SEE_STARS_LEFT
              Parameter for getting the images of the SEE_STARS scene.
    private static int SEE_STARS_RIGHT
              Parameter for getting the images of the SEE_STARS scene.
    private static int SWAP_LEFT
              Parameter for getting the images of the SWAP scene.
    private static int SWAP_RIGHT
              Parameter for getting the images of the SWAP scene.
    private static int VICTORY_PILLAR
              Parameter for getting the images of the VICTORY scene.
    private static int VICTORY_ROBOT
              Parameter for getting the images of the VITORY scene.
     
    Constructor Summary
    CutScene()
              Creates a new instance of CutScenes.
     
    Method Summary
     void centerWindow(java.awt.Window window)
              Method to center this window in the middle of the screen.
     void controller()
              Method to activate the control window where you can enable or disable the CutScenes.
    private  CutScene.Drawing[] createSequence(int robotID, int kind)
              Creates a new sequence that will be drawn.
     void disqualifyRobot(int robotID)
              Use this method when a robot will be disqualified.
     boolean isDisqualifyActive()
              Method to ensure that the CutScene when one robot has to be disqualified is set enabled.
     boolean isNoEnergyActive()
              Method to ensure that the CutScene when one robot runs out of energy is set enabled.
     boolean isSwapBothActive()
              Method to ensure that the CutScene when both robots want to swap cards is set enabled.
     boolean isSwapOneActive()
              Method to ensure that the CutScene when only one robot wants to swap cards is set enabled.
     boolean isVictoryActive()
              Method to ensure that the CutScene when one robot has one the game is set enabled.
    private  int random(int bottom, int top)
              Convenience method for creating a random integer.
     void robotHasNoEnergy(int robotID)
              Use this method when a robot has run out of energy.
     void setCallFromGUI(boolean b)
              Method to set the callFromGUI variable that is needed to proove if the CutScene is called from the GUI.
     void swapBoth(int robot1, int robot2)
              Call this method when both robots wanna swap cards.
     void swapOne(int swapID, int noSwapID)
              Call this method when only one robot wann swap and the other don't.
     void victory(int robotID)
              Use this method when a robot has won the game.
     
    Methods inherited from class java.lang.Object
    , clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
     

    Field Detail

    SWAP_LEFT

    private static final int SWAP_LEFT
    Parameter for getting the images of the SWAP scene. Implemented just for convenience.

    SWAP_RIGHT

    private static final int SWAP_RIGHT
    Parameter for getting the images of the SWAP scene. Implemented just for convenience.

    NO_SWAP_LEFT

    private static final int NO_SWAP_LEFT
    Parameter for getting the images of the SWAP scene. Implemented just for convenience.

    NO_SWAP_RIGHT

    private static final int NO_SWAP_RIGHT
    Parameter for getting the images of the NO_SWAP scene. Implemented just for convenience.

    DISQUALIFY

    private static final int DISQUALIFY
    Parameter for getting the images of the DISQUALIFY scene. Implemented just for convenience.

    NO_ENERGY

    private static final int NO_ENERGY
    Parameter for getting the images of the SWAP scene. Implemented just for convenience.

    SEE_STARS_LEFT

    private static final int SEE_STARS_LEFT
    Parameter for getting the images of the SEE_STARS scene. Implemented just for convenience.

    SEE_STARS_RIGHT

    private static final int SEE_STARS_RIGHT
    Parameter for getting the images of the SEE_STARS scene. Implemented just for convenience.

    VICTORY_ROBOT

    private static final int VICTORY_ROBOT
    Parameter for getting the images of the VITORY scene. Implemented just for convenience.

    VICTORY_PILLAR

    private static final int VICTORY_PILLAR
    Parameter for getting the images of the VICTORY scene. Implemented just for convenience.

    anim

    private CutScene.Animation anim
    The current Animation object

    controller

    private CutScene.Controller controller
    The current Controller object

    painting

    private CutScene.Painting painting
    The current Painting object

    callFromGUI

    private boolean callFromGUI
    indicating whether the CutScene has been evoked from the GUI

    root

    private java.lang.String root
    the root directory all images are in

    dirLeftCommon

    private java.lang.String dirLeftCommon
    the directory for the images of the robot on the left hand side

    dirRightCommon

    private java.lang.String dirRightCommon
    the directory for the images of the robot on the right hand side

    dirSwap

    private java.lang.String dirSwap
    the directory for the images of the swapping-robot

    dirNoSwap

    private java.lang.String dirNoSwap
    the directory for the images of the non-swapping-robot

    dirDisqualify

    private java.lang.String dirDisqualify
    the directory for the images of the disqualified-robot

    dirOutOfEnergy

    private java.lang.String dirOutOfEnergy
    the directory for the images of the out-of-energy-robot

    dirRobot

    private java.lang.String dirRobot
    the directory for the images of the robots in general

    dirVictory

    private java.lang.String dirVictory
    the directory for the images of the victory-robot

    rand

    private java.util.Random rand
    An instance of Random for the ranom()-method.
    Constructor Detail

    CutScene

    public CutScene()
    Creates a new instance of CutScenes.
    Method Detail

    createSequence

    private CutScene.Drawing[] createSequence(int robotID,
                                              int kind)
    Creates a new sequence that will be drawn.

    Parameters:
    robotID - The ID of the robot as stored in RobotImages.
    kind - The kind of sequence. Use constants above.
    Returns:
    an array of Drawing-objects.

    swapBoth

    public void swapBoth(int robot1,
                         int robot2)
    Call this method when both robots wanna swap cards. Use ArenaImages.RobotImages.ID as parameters.

    Parameters:
    robot1 - The ID of the robot on the one side in the CutScene.
    robot2 - The ID of the robot on the other side in the CutScene.

    swapOne

    public void swapOne(int swapID,
                        int noSwapID)
    Call this method when only one robot wann swap and the other don't. Use ArenaImages.RobotImages.ID as parameters.

    Parameters:
    swapID - The ID of the robot that wanna swap.
    noSwapID - The ID of the robot that don't wanna swap.

    disqualifyRobot

    public void disqualifyRobot(int robotID)
    Use this method when a robot will be disqualified. Use ArenaImages.RobotImages.ID as parameters.

    Parameters:
    robotID - The ID of the robot that will be disqualified.

    robotHasNoEnergy

    public void robotHasNoEnergy(int robotID)
    Use this method when a robot has run out of energy. Use ArenaImages.RobotImages.ID as parameters.

    Parameters:
    robotID - The ID of the robot that has run out of energy.

    victory

    public void victory(int robotID)
    Use this method when a robot has won the game. Use ArenaImages.RobotImages.ID as parameters.

    Parameters:
    robotID - The ID of the robot that has run out of energy.

    controller

    public void controller()
    Method to activate the control window where you can enable or disable the CutScenes.

    random

    private int random(int bottom,
                       int top)
    Convenience method for creating a random integer.

    Parameters:
    bottom - The bottom-border of the integer (inclusive).
    top - The top-border of the integer (inclusive).
    Returns:
    an integer ranging from the bottom to the top. if bottom is greater than the top, these two values will be swapped.

    isSwapBothActive

    public boolean isSwapBothActive()
    Method to ensure that the CutScene when both robots want to swap cards is set enabled.

    Returns:
    true when the CutScene is set enabled false otherwise.

    isSwapOneActive

    public boolean isSwapOneActive()
    Method to ensure that the CutScene when only one robot wants to swap cards is set enabled.

    Returns:
    true when the CutScene is set enabled false otherwise.

    isNoEnergyActive

    public boolean isNoEnergyActive()
    Method to ensure that the CutScene when one robot runs out of energy is set enabled.

    Returns:
    true when the CutScene is set enabled false otherwise.

    isDisqualifyActive

    public boolean isDisqualifyActive()
    Method to ensure that the CutScene when one robot has to be disqualified is set enabled.

    Returns:
    true when the CutScene is set enabled false otherwise.

    isVictoryActive

    public boolean isVictoryActive()
    Method to ensure that the CutScene when one robot has one the game is set enabled.

    Returns:
    true when the CutScene is set enabled false otherwise.

    setCallFromGUI

    public void setCallFromGUI(boolean b)
    Method to set the callFromGUI variable that is needed to proove if the CutScene is called from the GUI. Without this variable the scene doesn't work.

    Parameters:
    b - the boolean value

    centerWindow

    public void centerWindow(java.awt.Window window)
    Method to center this window in the middle of the screen.