Class BigBossDuck

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class BigBossDuck
    extends ComputerFigure
    The Last Enemy of the Chaos Duck realm, consisting of 4 figures of this class, placed in a 2x2-square. Only works well in Inner Sanctum! Inactive, until all LaserTowers are destroyed. When active, duck moves randomly up or down, firing a flame thrower in rotating directions, if enemy is nearer than ENEMY_FIREDISTANCE. If destroyed, the BigBossDuck spawns two ItemNextLevel and a GoldenShield- and a DoubleShields-Item.
    See Also:
    Serialized Form
    • Field Detail

      • TOPLEFT

        public static final int TOPLEFT
        Direction constant for fire animation.
        See Also:
        Constant Field Values
      • TOPRIGHT

        public static final int TOPRIGHT
        Direction constant for fire animation.
        See Also:
        Constant Field Values
      • BOTTOMLEFT

        public static final int BOTTOMLEFT
        Direction constant for fire animation.
        See Also:
        Constant Field Values
      • BOTTOMRIGHT

        public static final int BOTTOMRIGHT
        Direction constant for fire animation.
        See Also:
        Constant Field Values
      • XDIFS

        public static final int[] XDIFS
        X modifiers for fire
      • YDIFS

        public static final int[] YDIFS
        Y modifiers for fire
    • Constructor Detail

      • BigBossDuck

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

      • addStateProperties

        protected void addStateProperties​(ThingState state,
                                          AnimationInfo animation)
        Adds properties necessary for BigBossDuck 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.PainterBigBossDuck"
      • isAvailableInEditor

        public boolean isAvailableInEditor()
        Checks, if this figure is available in level editor.
        Overrides:
        isAvailableInEditor in class Figure
        Returns:
        false.
      • isZombie

        public boolean isZombie()
        Checks, if Duck is already a zombie.
        Returns:
        true, if Duck is already a zombie.
      • isDummy

        public boolean isDummy()
        Checks, if figure is a dummy (for level display).
        Overrides:
        isDummy in class ComputerFigure
        Returns:
        true for all but topleft BigBossDuck.
      • getImageName

        public java.lang.String getImageName​(AnimationInfo animation)
        Gets the image name for this figure.
        Overrides:
        getImageName in class Figure
        Parameters:
        animation - AnimationInfo.
        Returns:
        "bb_"+getDirString()
      • getPosition

        public int getPosition()
        Calculates this BigBossDucks position.
        Returns:
        The position.
      • doCalculateNextPoint

        protected Point doCalculateNextPoint()
        This method is called each round, to get the next point for this figure when playing. If any drone explodes, the BigBoss does not move. Otherwise superclasses method is called. Stores the next point for acccess by drones.
        Overrides:
        doCalculateNextPoint in class ComputerFigure
        Returns:
        This figures next point
      • onAddHeat

        protected int onAddHeat​(int heat,
                                boolean internal,
                                Thing source)
        Returns 0. Big Boss is immune to heat.
        Overrides:
        onAddHeat in class Figure
        Parameters:
        heat - The originally added heat
        internal - Flag, if heat was produced inside the figure.
        source - The heating source.
        Returns:
        0.
      • onExplode

        protected int onExplode​(int power,
                                Thing source,
                                AnimationInfo animation)
        Performed, when a thing stands in an explosion. Ignores self-sourced explosions.
        Overrides:
        onExplode in class Figure
        Parameters:
        power - The explosion power
        source - The explosion source
        animation - The AnimationInfo.
        Returns:
        A modified energy loss.
      • onBeforeRemoveEnergy

        protected int onBeforeRemoveEnergy​(int min,
                                           Thing source,
                                           DieReason reason,
                                           AnimationInfo animation)
        Called before energy is removed from figure. Override in subclasses to modify energy losses. Returns the original energy loss by default.
        Overrides:
        onBeforeRemoveEnergy in class Figure
        Parameters:
        min - The energy loss.
        source - the source.
        reason - The energy removal reason.
        animation - The AnimationInfo
        Returns:
        The modified energy loss.
      • onBeforeDie

        protected boolean onBeforeDie​(Thing source,
                                      DieReason reason,
                                      AnimationInfo animation)
        Called before the figure dies (after event handling in FigureKillListeners). Checks if all other ducks are zombies already, if yes, all others are notifies to die (finally). Otherwise this duck becomes a zombie, and false is returned to keep this duck alive, until all others are dead as well.
        Overrides:
        onBeforeDie in class Figure
        Parameters:
        source - The death source.
        reason - The death reason.
        animation - The AnimationInfo
        Returns:
        true, if figure really dies, false to prevent that. true by default.
      • getEnergySum

        public int getEnergySum()
        Returns the accumulated energy of all ducks.
        Returns:
        The accumulated energy of all ducks.
      • wantsToUseItem

        public boolean wantsToUseItem()
        This method is called each round, if the figure has an item, to check, if the item should be used.
        Overrides:
        wantsToUseItem in class Figure
        Returns:
        true, if this figure wants to use it's item.
      • wantsToMove

        public boolean wantsToMove()
        Checks, if the Duck wants to move .
        Overrides:
        wantsToMove in class ComputerFigure
        Returns:
        true, if this figure wants to move.
      • anyLaserTowerAlive

        public boolean anyLaserTowerAlive()
        Checks, if any of the LaserTowers in the level is still alive.
        Returns:
        true, if any of the LaserTowers in the level is still alive.
      • doSpecialUpdate

        protected void doSpecialUpdate​(AnimationInfo animation)
        Updates after each round. Drops any item that might have been picked up. Checks for the FlameThrower effect and loads a rocket, if all drones are dead.
        Overrides:
        doSpecialUpdate in class ComputerFigure
        Parameters:
        animation - The AnimationInfo.
      • onAfterDeath

        protected void onAfterDeath​(Point p,
                                    AnimationInfo animation)
        Called, directly after a figure dies and its point is unoccupied. Places an ItemSecretLevel, that is activated for 8 rounds.
        Overrides:
        onAfterDeath in class Figure
        Parameters:
        p - The point
        animation - T-he AnimationInfo
      • shoot

        protected void shoot​(int xdif,
                             int ydif)
        Performs the flame thrower effect.
        Parameters:
        xdif - X addition depending on shoot direction.
        ydif - y addition depending on shoot direction.
      • 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 this figure, is visible and ok.
      • reInit

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