Class ItemRocket

    • Field Detail

      • DEBUG

        protected boolean DEBUG
        Debug flag.
      • OFF

        protected static int OFF
        Sound constant for no sound.
      • explosionDuration

        protected int explosionDuration
        Duration of detonation.
      • active

        protected boolean active
        State of the rocket (ACTIVE/INACTIVE)
      • dropPoint

        protected Point dropPoint
        The point on which the user fired the rocket.
      • detonating

        protected boolean detonating
        Flag, if currently detonating.
      • targetX

        protected int targetX
        Target x position.
      • targetY

        protected int targetY
        Target y position.
      • targetLine

        protected java.util.ArrayList<Point> targetLine
        The line of points to the target.
      • speed

        protected int speed
        Speed of the rocket.
      • owner

        protected Figure owner
        Owner after being picked up
      • loopName

        protected java.lang.String loopName
        The name of the sound clip to loop as rocket warning.
    • Constructor Detail

      • ItemRocket

        public ItemRocket()
        Creates a new ItemRocket.
    • Method Detail

      • 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 Item
        Returns:
        "com.starpoints.painter.arena2D.PainterItemRocket"
      • getItemRating

        public int getItemRating()
        Returns an item value for ComputerFigures rating in the items category.
        Overrides:
        getItemRating in class Item
        Returns:
        energy * 12.
      • addStateProperties

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

        public ItemCategory getCategory()
        Returns the items category.
        Overrides:
        getCategory in class Item
        Returns:
        the category
      • die

        public void die​(Thing source,
                        DieReason reason,
                        AnimationInfo animation)
        Explodes, if INACTIVE, otherwise detonate.
        Overrides:
        die in class Item
        Parameters:
        source - The explosion source.
        reason - The reason.
        animation - The AnimationInfo.
      • getOwner

        protected Figure getOwner()
        Returns this rockets owner.
        Returns:
        The owner.
      • setOwner

        protected void setOwner​(Figure owner)
        Sets the owner.
        Parameters:
        owner - the owner to set
      • detonate

        public void detonate​(Point p,
                             AnimationInfo animation)
        Detonates with a radius depending on the rockets energy.
        Parameters:
        p - The detonation point.
        animation - The AnimationInfo.
      • stopClip

        protected void stopClip()
        Stops the warning music.
      • onEnemyKilled

        public void onEnemyKilled​(Figure enemy,
                                  int round,
                                  DieReason reason,
                                  AnimationInfo animation)
        Called, if the thing killed an enemy.
        Overrides:
        onEnemyKilled in class Item
        Parameters:
        enemy - The killed enemy.
        round - The round count.
        reason - The reason.
        animation - The AnimationInfo.
      • onBePickedUp

        public boolean onBePickedUp​(Figure picker,
                                    AnimationInfo animation)
        If INACTIVE, normal picking up, if ACTIVE, picker dies, if he has no explosion shielding, otherwise the pickers energy is reduced by 2 times this rockets energy, divided by the rocket shielding.
        Overrides:
        onBePickedUp in class Item
        Parameters:
        picker - The picker
        animation - The AnimationInfo.
        Returns:
        true, if pickable, false otherwise.
      • onBeUsed

        public boolean onBeUsed​(Figure user,
                                AnimationInfo animation)
        Starts this rocket (if it is ok). Calculates the line (list of points) to the target, calls the rocketStarted()- method on the field, and inserts the warning sound loop.
        Overrides:
        onBeUsed in class Item
        Parameters:
        user - The user who fires the rocket
        animation - The AnimationInfo.
        Returns:
        true, if rocket is ok.
      • beFired

        protected void beFired()
        Sets the state to ACTIVE, calls the fields rocketStarted-method, and starts the sound fx.
      • getTargetPoint

        public Point getTargetPoint()
        Gets the target point.
        Returns:
        The target point.
      • performFieldEffect

        protected void performFieldEffect​(AnimationInfo animation)
        Moves to the target if active and speedcount is reached.
        Overrides:
        performFieldEffect in class Item
        Parameters:
        animation - The AnimationInfo.
      • doSpecialUpdate

        protected void doSpecialUpdate​(AnimationInfo animation)
        Recalculates the target and target line.
        Overrides:
        doSpecialUpdate in class Item
        Parameters:
        animation - The AnimationInfo.
      • paintUpdate

        public void paintUpdate()
        Increases the speed counter. Can be used for dummy rocket painting.
      • onHitItem

        public boolean onHitItem​(Item rammedItem,
                                 AnimationInfo animation)
        Method called if this item moves and hits another item.
        Overrides:
        onHitItem in class Item
        Parameters:
        rammedItem - The rammed item
        animation - The AnimationInfo.
        Returns:
        true, if this item is placed on the rammed items point.
      • moveToTarget

        protected void moveToTarget​(AnimationInfo animation)
        Moves to the target, in case the speedCounter has increased to the speed value.
        Parameters:
        animation - The AnimationInfo.
      • getNextPoint

        protected Point getNextPoint​(int xp,
                                     int yp)
        Gets the next point.
        Parameters:
        xp - The last x position.
        yp - The last y position.
        Returns:
        The next point.
      • setDropPoint

        public void setDropPoint​(Point p)
        Sets the drop point
        Parameters:
        p - The point.
      • calculateTargetLine

        protected void calculateTargetLine()
        Calculates the points to move over when fired.
      • getStartingPoint

        public Point getStartingPoint()
        Gets the starting point of this rocket.
        Returns:
        The point of the owner.
      • getTargetLine

        public java.util.ArrayList<Point> getTargetLine()
        Gets the line of points this rocket will move.
        Returns:
        The target line.
      • calculateTarget

        public void calculateTarget​(int xpos,
                                    int ypos)
        Calculates the rocket target using the given start coordinates.
        Parameters:
        xpos - X position.
        ypos - Y position.
      • calculateTarget

        public void calculateTarget​(int xpos,
                                    int ypos,
                                    boolean checkInvisibility,
                                    boolean checkECM)
        Determines the nearest target figure and calculates the target line.
        Parameters:
        xpos - The xpos, the rocket is fired from.
        ypos - The ypos, the rocket is fired from.
        checkInvisibility - Flag, if invisible figures are no target.
        checkECM - Flag, if an ECM system prevents the figures from being the target.
      • getNearestTarget

        protected Thing getNearestTarget​(int xpos,
                                         int ypos,
                                         boolean checkInvisibility,
                                         boolean checkECM)
        Gets the nearest figure for target determination
        Parameters:
        xpos - The current x pos
        ypos - The current y pos
        checkInvisibility - Flag, if invisible figures should be ignored
        checkECM - Flag, if figures with ECM system should be ignored.
        Returns:
        The nearest possible target
      • hasTarget

        public boolean hasTarget()
        Checks if this rocket has a target.
        Returns:
        true, if rocket has target.
      • isActive

        public boolean isActive()
        Checks, if the rocket is active.
        Returns:
        state == ACTIVE
      • setActive

        public void setActive​(boolean active)
        Checks, if the rocket is active.
        Parameters:
        active - The new state.
      • getNextCalculatedPoint

        protected Point getNextCalculatedPoint()
        Gets the first point of the target line.
        Returns:
        The first point of the target line.
      • setTarget

        public void setTarget​(int x,
                              int y)
        Sets the target point.
        Parameters:
        x - target x coordinate
        y - target y coordinate
      • getSpeedCount

        public int getSpeedCount()
        Gets the current speed counter value.
        Returns:
        The current speed counter value.
      • getSpeed

        public int getSpeed()
        Gets the speed of this rocket (nr of rounds between each move).
        Returns:
        The speed of this rocket.
      • setSpeed

        public void setSpeed​(int speed)
        Sets the speed of this rocket (nr of rounds between each move).
        Parameters:
        speed - The new speed of this rocket.
      • isDetonating

        public boolean isDetonating()
        Checks, if the rocket is currently deton
        Returns:
        true if detonating.
      • setNasty

        public void setNasty​(boolean nasty)
        Makes this rocket nasty (only targeting PlayerFigures).
        Parameters:
        nasty - Flag, if rocket will be nasty or not.
      • getRocketeer

        public Item getRocketeer()
        Gets an ItemRocketeer, in case this figure is fired by one. Needed for targetline-calculation.
        Returns:
        The rocketeer.
      • setRocketeer

        public void setRocketeer​(Item rocketeer)
        Sets an ItemRocketeer, in case this figure is fired by one. Needed for targetline-calculation. Should be called by items, that generate rockets during game.
        Parameters:
        rocketeer - The rocketeer.
      • getMoveAnimationLength

        public int getMoveAnimationLength()
        Method that can be overwritten by moving item subclasses, in case move animation should not last for default of 3 update cycles.
        Overrides:
        getMoveAnimationLength in class Item
        Returns:
        3 by default.