Class LaserTower

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable
    Direct Known Subclasses:
    SuperLaserTower

    public class LaserTower
    extends ComputerFigure
    Enemy that fires lasers but does not move.
    See Also:
    Serialized Form
    • Field Detail

      • FIRE_FREQUENCY

        protected int FIRE_FREQUENCY
        Laser fire frequency.
      • FIRE_DELAY

        protected int FIRE_DELAY
        Laser fire delay between aiming and firing.
      • counter

        protected int counter
        Fire counter for laser beam.
      • isFiring

        protected boolean isFiring
        Flag for laser beam.
    • Constructor Detail

      • LaserTower

        public LaserTower​(Game game,
                          FigureInfo figureInfo)
        Creates a new LaserTower.
        Parameters:
        game - The game.
        figureInfo - The figure info.
    • Method Detail

      • addStateProperties

        protected void addStateProperties​(ThingState state,
                                          AnimationInfo animation)
        Adds properties necessary for LaserTower painting.
        Overrides:
        addStateProperties in class Thing
        Parameters:
        state - The state to add properties to.
        animation - The current AnimationInfo.
      • getPainterClassname

        public java.lang.String getPainterClassname()
        Gets the fully qualified classname of the Painter to use for this item (in 2D game).
        Overrides:
        getPainterClassname in class Figure
        Returns:
        "com.starpoints.painter.arena2D.PainterLaserTower"
      • doSpecialUpdate

        protected void doSpecialUpdate​(AnimationInfo animation)
        This method is called at the end of the regular updateThing()-method. If the number of rounds equal to the fire frequency has passed, since the last laser was fired, the figure aims its laser.
        Overrides:
        doSpecialUpdate in class ComputerFigure
        Parameters:
        animation - The AnimationInfo.
      • getBeamSound

        protected java.lang.String getBeamSound()
        Gets the sound to play when aiming.
        Returns:
        "laseraim"
      • checkEnemy

        protected boolean checkEnemy​(Figure f)
        Checks, if a figure is relevant for the closest enemy determination.
        Overrides:
        checkEnemy in class ComputerFigure
        Parameters:
        f - The figure.
        Returns:
        true, if figure is not another ChaosDuck AND super.checkEnemy().
      • performLaserEffect

        protected void performLaserEffect​(Thing target,
                                          AnimationInfo animation)
        Performs the laser hit effect.
        Parameters:
        target - The target. Never null.
        animation - The AnimationInfo.
      • getFireSound

        protected java.lang.String getFireSound()
        Gets the sound to play when firing laser.
        Returns:
        "laserbeam"
      • getTarget

        public Point getTarget()
        Gets the current target (or null, if not aiming).
        Returns:
        The target.
      • isFiring

        public boolean isFiring()
        Checks, if the laser tower is currently firing.
        Returns:
        true, if Tower is firing its laser.
      • wantsToMove

        protected boolean wantsToMove()
        Checks, if this figure wants to move.
        Overrides:
        wantsToMove in class ComputerFigure
        Returns:
        false.
      • reInit

        protected void reInit​(Field f)
        Reinitializes the figure after each level.
        Overrides:
        reInit in class Figure
        Parameters:
        f - The new field