Class ItemSatellite

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

    public class ItemSatellite
    extends Item
    implements FigureMoveListener
    Item, that can be used to move around instead of the user. Picked items are transferred to the user. Hitting a figure does small rocket damage. Immune to holes.
    See Also:
    Serialized Form
    • Field Detail

      • mode

        protected com.starpoints.game.item.ItemSatellite.SatelliteMode mode
        The current satellite mode.
      • dropFlag

        protected boolean dropFlag
        Needed for correct listener removal by self-inflicted drop.
      • lastMove

        protected Direction lastMove
        Direction after figure moved.
    • Constructor Detail

      • ItemSatellite

        public ItemSatellite()
        Creates a new ItemSatellite.
    • 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.PainterItemSatellite"
      • getItemRating

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

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

        public java.lang.String getImageName()
        Returns the image name..
        Returns:
        item_satellite as default. Modified, if figure moved.
      • onBePickedUp

        public boolean onBePickedUp​(Figure picker,
                                    AnimationInfo animation)
        If the satellite is active, it gives rocket damage to picker (as long as it is not the user).
        Overrides:
        onBePickedUp in class Item
        Parameters:
        picker - The picker
        animation - The AnimationInfo.
        Returns:
        true, if picker is old user, otherwise
      • onBeforeDie

        protected void onBeforeDie​(Thing source,
                                   DieReason reason,
                                   AnimationInfo animation)
        Called, before the item dies. Removes move listener.
        Overrides:
        onBeforeDie in class Item
        Parameters:
        source - The death source. Might be null if dying e.g. because of energy losses by gray points.
        reason - The death reason.
        animation - The AnimationInfo.
      • onBeUsed

        public boolean onBeUsed​(Figure user,
                                AnimationInfo animation)
        Adds the satellite as move listener.
        Overrides:
        onBeUsed in class Item
        Parameters:
        user - The user
        animation - The AnimationInfo.
        Returns:
        true, because the satellite is kept as icon.
      • beforeMove

        public boolean beforeMove​(Figure f,
                                  Point p,
                                  Point newP,
                                  AnimationInfo animation)
        Called, if the satellite is active. Lets the satellite move instead of the figure
        Specified by:
        beforeMove in interface FigureMoveListener
        Parameters:
        f - The figure.
        p - The figures current point.
        newP - The point the figures wants to move to.
        animation - The AnimationInfo
        Returns:
        true, if figure can move.
      • onLevelFinished

        protected void onLevelFinished()
        Called after a level was finished. Removes as FigureMoveListener.
        Overrides:
        onLevelFinished in class Item
      • onHitItem

        public boolean onHitItem​(Item rammedItem,
                                 AnimationInfo animation)
        Method called if this item moves and hits another item. Makes the user take the 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.
      • onDrop

        public void onDrop​(Figure oldOwner,
                           AnimationInfo animation)
        Called if the item is lost.
        Overrides:
        onDrop in class Item
        Parameters:
        oldOwner - The old owner of the item.
        animation - AnimationInfo.
      • doSpecialUpdate

        protected void doSpecialUpdate​(AnimationInfo animation)
        Performs the update in each round in overridden classes. Does nothing per default.
        Overrides:
        doSpecialUpdate in class Item
        Parameters:
        animation - The AnimationInfo.
      • isTransferring

        public boolean isTransferring()
        Checks, if satellite just transferred an item to its user.
        Returns:
        true, if satellite just transferred an item to its user.
      • getMoveAnimationLength

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