Class FigureAnimation

  • All Implemented Interfaces:
    java.io.Serializable

    public class FigureAnimation
    extends Animation
    Stores animation infos for a Figure.
    See Also:
    Serialized Form
    • Constructor Detail

      • FigureAnimation

        public FigureAnimation()
        Creates an empty FigureAnimation.
      • FigureAnimation

        public FigureAnimation​(Figure f,
                               Point srcPoint,
                               Point targetPoint)
        Creates a figure move animation.
        Parameters:
        f - The figure.
        srcPoint - The old point.
        targetPoint - The target point.
      • FigureAnimation

        public FigureAnimation​(Figure f,
                               Point srcPoint,
                               Point targetPoint,
                               boolean isRamming,
                               int ramPower,
                               Direction ramDir,
                               Thing ramTarget)
        Creates a figure ram animation.
        Parameters:
        f - The figure.
        srcPoint - The old point.
        targetPoint - The target point.
        isRamming - Flag if figure is ramming.
        ramPower - The ram power.
        ramDir - The ram direction.
        ramTarget - The ram target.
      • FigureAnimation

        public FigureAnimation​(Figure f,
                               Point srcPoint,
                               Point targetPoint,
                               boolean isRamming,
                               int ramPower,
                               Direction ramDir,
                               Thing ramTarget,
                               boolean isBlocked)
        Creates a figure ram animation.
        Parameters:
        f - The figure.
        srcPoint - The old point.
        targetPoint - The target point.
        isRamming - Flag if figure is ramming.
        ramPower - The ram power.
        ramDir - The ram direction.
        ramTarget - The ram target.
        isBlocked - Flag, if target point is blocked.
    • Method Detail

      • addMoveAnimation

        public void addMoveAnimation​(Point srcPoint,
                                     Point targetPoint)
        Addds a move animation
        Parameters:
        srcPoint - The old point.
        targetPoint - The target point.
      • addRamAnimation

        public void addRamAnimation​(Point srcPoint,
                                    Point targetPoint,
                                    boolean isRamming,
                                    int ramPower,
                                    Direction ramDir,
                                    Thing ramTarget)
        Adds a figure ram animation.
        Parameters:
        srcPoint - The old point.
        targetPoint - The target point.
        isRamming - Flag if figure is ramming.
        ramPower - The ram power.
        ramDir - The ram direction.
        ramTarget - The ram target.
      • addRamAnimation

        public void addRamAnimation​(Point srcPoint,
                                    Point targetPoint,
                                    boolean isRamming,
                                    int ramPower,
                                    Direction ramDir,
                                    Thing ramTarget,
                                    boolean isBlocked)
        Adds a figure ram animation.
        Parameters:
        srcPoint - The old point.
        targetPoint - The target point.
        isRamming - Flag if figure is ramming.
        ramPower - The ram power.
        ramDir - The ram direction.
        ramTarget - The ram target.
        isBlocked - Flag, if target point is blocked.
      • hasShieldAnimation

        public boolean hasShieldAnimation()
        Checks, if a shielding animation is contained.
        Returns:
        true, if a shielding animation is contained.
      • hasMoveAnimation

        public boolean hasMoveAnimation()
        Checks, if a move animation is contained.
        Returns:
        true, if a move animation is contained.
      • hasRocketAnimation

        public boolean hasRocketAnimation()
        Checks, if a rocket animation is contained.
        Returns:
        true, if a rocket animation is contained.
      • getSrcPoint

        public Point getSrcPoint()
        Gets the source point.
        Returns:
        The srcPoint
      • getTargetPoint

        public Point getTargetPoint()
        Gets the target point.
        Returns:
        the targetPoint
      • setMovement

        public void setMovement​(Point srcPoint,
                                Point targetPoint)
        Sets the move points.
        Parameters:
        srcPoint - The old point.
        targetPoint - The target point.
      • isRamming

        public boolean isRamming()
        Checks, if figure is ramming.
        Returns:
        The isRamming-flag.
      • isRammingEmpty

        public boolean isRammingEmpty()
        Check, if ramming aims to an empty point (wher other figure moves to as well).
        Returns:
        The rammingEmpty-flag
      • setRammingEmpty

        public void setRammingEmpty​(boolean rammingEmpty)
        Sets, if ramming aims to an empty point (wher other figure moves to as well).
        Parameters:
        rammingEmpty - The rammingEmpty-flag to set
      • setRamming

        public void setRamming​(boolean isRamming,
                               int energy,
                               Direction direction,
                               Thing ramTarget)
        Sets some ramming information.
        Parameters:
        isRamming - The isRamming to set.
        energy - The ram energy.
        direction - The ram direction.
        ramTarget - The ram target.
      • isHitByRocket

        public boolean isHitByRocket()
        Checks, if figure was hit by rocket.
        Returns:
        true, if hit By Rocket.
      • getRocketPower

        public int getRocketPower()
        Gets the rocket power.
        Returns:
        the rocketPower
      • getRocketImpactDirection

        public Direction getRocketImpactDirection()
        Gets the rocket impact direction.
        Returns:
        the rocket impact Direction
      • setHitByRocket

        public void setHitByRocket​(int rocketPower,
                                   Direction impactDirection)
        Sets a flag that figure was hit by rocket.
        Parameters:
        rocketPower - The rocketPower.
        impactDirection - The impact Direction.
      • setIsBlocked

        public void setIsBlocked​(boolean b)
        Set a blocked flag for move animation.
        Parameters:
        b - true, if movement was blocked.
      • isBlocked

        public boolean isBlocked()
        Checks, if movement is blocked.
        Returns:
        true if blocked.
      • getRamPower

        public int getRamPower()
        Gets the ram power.
        Returns:
        the ramPower
      • getRamDir

        public Direction getRamDir()
        Gets the ram direction.
        Returns:
        the ramDir
      • addShieldAnimation

        public void addShieldAnimation​(ShieldType type,
                                       int power)
        Adds a shield animation.
        Parameters:
        type - Shield type.
        power - Shield power.
      • isShielded

        public boolean isShielded​(ShieldType type)
        Checks, if shield animation for ShieldType exists.
        Parameters:
        type - The Shield type.
        Returns:
        true, if shield animation exists.
      • getShieldPower

        public int getShieldPower​(ShieldType type)
        Gets the shield power for the given type.
        Parameters:
        type - The Shield type.
        Returns:
        The power.
      • getShieldAnimations

        public java.util.Collection<FigureShieldedAnimation> getShieldAnimations()
        Gets a list of shield animations.
        Returns:
        The list of animations.
      • getCopyForNextAnimation

        protected Animation getCopyForNextAnimation()
        Gets a copy for the next AnimationInfo.
        Overrides:
        getCopyForNextAnimation in class Animation
        Returns:
        This instance with a reduced duration or null, if end of lifecyle is reached.
      • toString

        public java.lang.String toString()
        Returns a string representation.
        Overrides:
        toString in class java.lang.Object
        Returns:
        A string representation.