Class PlayerFigure

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

    public class PlayerFigure
    extends Figure
    Superclass for player figures. The PlayerFigures settings (image, colors, energy and ram power etc.) are specified in the SP_Players.ini-file. The Players moves are handled directly by the game. Bonus counts and coolness calculation is implemented in the PlayerFigures win()-method. Some modifications for energy losses depending on the difficulty level are done by the PlayerFigure as well.
    See Also:
    Serialized Form
    • Field Detail

      • listener

        public boolean listener
        Flag, if figure is already registered as key listener.
      • bestPoints

        protected int bestPoints
        Best levels point result
      • bestLevel

        protected java.lang.String bestLevel
        The best levels name.
      • skin

        protected Skin skin
        The PlayerFigures skin for initial settings. Used for determining base shieldings.
    • Constructor Detail

      • PlayerFigure

        public PlayerFigure​(Game game,
                            FigureInfo fi)
        Creates a new PlayerFigure
        Parameters:
        game - The game.
        fi - The FigureInfo.
    • Method Detail

      • applySkin

        public void applySkin​(Skin skin)
        Applies the given skin to this PlayerFigure, so the skins settings are used for this figure.
        Parameters:
        skin - The skin.
      • onBeforeDie

        protected boolean onBeforeDie​(Thing source,
                                      DieReason reason,
                                      AnimationInfo animation)
        Called before the figure dies (after event handling in FigureKillListeners). Calls Controller to vibrate.
        Overrides:
        onBeforeDie in class Figure
        Parameters:
        source - The death source.
        reason - The death reason.
        animation - The AnimationInfo
        Returns:
        true.
      • win

        public final int win​(int roundCount)
        This effect is performed when the figure won a game. Stores the level, if this was the best level yet.
        Overrides:
        win in class Figure
        Parameters:
        roundCount - The last round
        Returns:
        An additional point bonus.
      • onBeforeRemoveEnergy

        protected int onBeforeRemoveEnergy​(int min,
                                           Thing source,
                                           DieReason reason,
                                           AnimationInfo animation)
        Called before energy is removed from figure. Modifies the energy by the difficulty level.
        Overrides:
        onBeforeRemoveEnergy in class Figure
        Parameters:
        min - The energy loss.
        source - The source of the loss.
        reason - The reason.
        animation - The AnimationInfo.
        Returns:
        A reduced energy by 20% in easy mode, increased by 20% in hard mode.
      • onAddHeat

        protected int onAddHeat​(int heat,
                                boolean internal,
                                Thing source)
        Called when heat is added. Reduces heat gain by skins heat shielding.
        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:
        A modified heat value.
      • reInit

        public void reInit​(Field f)
        Reinitializes the player figure. Resets the moving and sight direction, clears all bonus lists and flags etc.
        Overrides:
        reInit in class Figure
        Parameters:
        f - The field.
      • updatePoints

        protected void updatePoints()
        Inserts sound and message for penalties.
        Overrides:
        updatePoints in class Figure
      • setMaxEnergy

        public final void setMaxEnergy​(int maxEnergy)
        Sets a new energy maximum.
        Overrides:
        setMaxEnergy in class Figure
        Parameters:
        maxEnergy - The new max energy.
      • setInitialEnergy

        public final void setInitialEnergy​(int initialEnergy)
        Sets the initial energy when starting a new level. If the initial energy is higher then the current max energy, this is also increased.
        Overrides:
        setInitialEnergy in class Figure
        Parameters:
        initialEnergy - The new initial energy when starting a new level
      • doSpecialUpdate

        public void doSpecialUpdate​(AnimationInfo animation)
        Special updates. Updates some coolness counters.
        Overrides:
        doSpecialUpdate in class Figure
        Parameters:
        animation - The AnimationInfo.
      • isDummy

        public boolean isDummy()
        Checks, if figure is a dummy.
        Overrides:
        isDummy in class Figure
        Returns:
        false.
      • getExplosionClip

        protected java.lang.String getExplosionClip()
        Gets a clip that is played if this figure stands in an explosion.
        Overrides:
        getExplosionClip in class Figure
        Returns:
        "explosion_ownfigure"
      • getDyingClip

        protected java.lang.String getDyingClip()
        Gets the sound clip to be played if figure dies.
        Overrides:
        getDyingClip in class Figure
        Returns:
        "figure_die"
      • getBestLevel

        public java.lang.String getBestLevel()
        Gets the best level of the current game.
        Returns:
        the bestLevel
      • getBestPoints

        public int getBestPoints()
        Gets the best levels score of the current game.
        Returns:
        the bestPoints
      • getSkin

        public Skin getSkin()
        Returns this figures skin. Use return value for modifying or getting base shield settings or coolnessFactor. To set ram power or energy, use applySkin()-method instead.
        Returns:
        The skin.
      • isParticipatingInGame

        public boolean isParticipatingInGame()
        Returns:
        the isParticipatingInGame
      • setParticipatingInGame

        public void setParticipatingInGame​(boolean isParticipatingInGame)
        Parameters:
        isParticipatingInGame - the isParticipatingInGame to set
      • getViewDirection

        public Direction getViewDirection()
        Gets the current view direction.
        Returns:
        The viewDir
      • setViewDirection

        public void setViewDirection​(Direction viewDir)
        Sets a new view direction.
        Parameters:
        viewDir - The viewDir to set
      • getAdditionalEquipment

        public java.util.List<java.lang.String> getAdditionalEquipment()
        Returns:
        the additional equipments.
      • addAdditionalEquipment

        public void addAdditionalEquipment​(java.lang.String equipment)
        Adds an additional equipment. Additional equipment can be used for game extensions and is not used in core game (yet). Additional equipment is not using up any inventory slots. Examples are Map and HeadUp Display in 3D game.
        Parameters:
        equipment - the equipment to add.
      • removeAdditionalEquipment

        public void removeAdditionalEquipment​(java.lang.String equipment)
        Removes an additional equipment.
        Parameters:
        equipment - the equipment to remove.
      • hasAdditionalEquipment

        public boolean hasAdditionalEquipment​(java.lang.String equipment)
        Checks, if figure has an additional equipment.
        Parameters:
        equipment - the equipment to check.
        Returns:
        true, if figure has the additional equipment.
      • rotateLeft

        public void rotateLeft()
        Rotates the view direction counterclockwise.
      • rotateRight

        public void rotateRight()
        Rotates the view direction clockwise.