Class AnimationInfo

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    EmptyAnimationInfo

    public class AnimationInfo
    extends java.lang.Object
    implements java.io.Serializable
    Container for all animations during one round segment. The AnimationInfo is copied each phase to keep all contained animation that have not reached the end of its lifecycle. It is passed to all relevant methods during game that manipulate the game state to add animation information e.g. for rockets, regeneration or shield fx. During GameState creation, the AnimationInfo content is partly aggregated for display relevant state changes.
    See Also:
    Serialized Form
    • Field Detail

      • EMPTY

        public static final AnimationInfo EMPTY
        Empty Animaton singleton.
      • figureAnimations

        protected java.util.Hashtable<Figure,​FigureAnimation> figureAnimations
        Map of FigureAnimations.
      • pointAnimations

        protected java.util.Hashtable<Point,​PointAnimation> pointAnimations
        Map of PointAnimations.
      • itemAnimations

        protected java.util.Hashtable<Item,​ItemAnimation> itemAnimations
        Map of ItemAnimations.
      • additionalAnimations

        protected java.util.Hashtable<java.lang.Object,​Animation> additionalAnimations
        Map of additional Animations.
    • Constructor Detail

      • AnimationInfo

        public AnimationInfo​(int index)
        Creates a new AnimationInfo with the given index.
        Parameters:
        index - The index.
    • Method Detail

      • getFigureAnimation

        public FigureAnimation getFigureAnimation​(Figure f)
        Gets a FigureAnimation for the given figure.
        Parameters:
        f - The Figure.
        Returns:
        The FigureAnimation.
      • containsFigureAnimation

        public boolean containsFigureAnimation​(Figure f)
        Checks, if an animation for the given figure is contained.
        Parameters:
        f - The figure.
        Returns:
        true, if an animation for the given figure is contained.
      • containsFigureMoveAnimation

        public boolean containsFigureMoveAnimation​(Figure f)
        Checks, if a move animation for the given figure is contained.
        Parameters:
        f - The figure.
        Returns:
        true, if an animation for the given figure is contained.
      • addFigureMoveAnimation

        public FigureAnimation addFigureMoveAnimation​(Figure f,
                                                      Point srcPoint,
                                                      Point targetPoint)
        Adds a figure move animation.
        Parameters:
        f - The figure.
        srcPoint - The source point.
        targetPoint - The target point.
        Returns:
        The FigureAniamtion.
      • addFigureRamAnimation

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

        public FigureAnimation addFigureRamAnimation​(Figure f,
                                                     boolean isRamming,
                                                     int ramPower,
                                                     Direction ramDir,
                                                     Thing ramTarget)
        Adds a figure ram animation for a figure standing on a rammers target point.
        Parameters:
        f - The figure.
        isRamming - Flag, if figure is actively ramming.
        ramPower - The ram power.
        ramDir - The ram direction.
        ramTarget - The ram taerget.
        Returns:
        The FigureAnimation.
      • addFigureRamAnimation

        public FigureAnimation addFigureRamAnimation​(Figure f,
                                                     Point srcPoint,
                                                     Point targetPoint,
                                                     boolean isRamming,
                                                     int ramPower,
                                                     Direction ramDir,
                                                     Thing ramTarget,
                                                     boolean isBlocked)
        Adds a figure ram animation.
        Parameters:
        f - The figure.
        srcPoint - The source point.
        targetPoint - The target point.
        isRamming - Flag, if figure is actively ramming.
        ramPower - The ram power.
        ramDir - The ram direction.
        ramTarget - The ram taerget.
        isBlocked - Flag, if target is blocked.
        Returns:
        The FigureAnimation.
      • addFigureShieldAnimation

        public FigureAnimation addFigureShieldAnimation​(Figure f,
                                                        ShieldType type,
                                                        int power)
        Adds a shield animation for the figure.
        Parameters:
        f - The figure.
        type - The shield type.
        power - The shield power.
        Returns:
        the FigureAnimation.
      • getItemAnimation

        public ItemAnimation getItemAnimation​(Item i)
        Gets an Animation for the given item.
        Parameters:
        i - The item.
        Returns:
        An Animation for the item.
      • addItemMoveAnimation

        public ItemAnimation addItemMoveAnimation​(Item i,
                                                  Point srcPoint,
                                                  Point targetPoint,
                                                  int duration)
        Adds an item-move animation
        Parameters:
        i - The item.
        srcPoint - The source point.
        targetPoint - The target point.
        duration - Duration of animation.
        Returns:
        The ItemAnimation.
      • containsItemAnimation

        public boolean containsItemAnimation​(Item i)
        Checks, if an animation is contained for the given item.
        Parameters:
        i - The item.
        Returns:
        true, if an animation is contained for the given item.
      • createOrGetPointAnimation

        public PointAnimation createOrGetPointAnimation​(Point p)
        Gets or creates an Animation for the given Point.
        Parameters:
        p - The Point.
        Returns:
        A PointAnnimation.
      • addPointColorAnimation

        public PointAnimation addPointColorAnimation​(Point p,
                                                     int color,
                                                     int oldColor)
        Adds a Color animation caused by no swirl.
        Parameters:
        p - The point
        color - The color
        oldColor - the old color
        Returns:
        The created or existing PointAnimation
      • addPointColorAnimation

        public PointAnimation addPointColorAnimation​(Point p,
                                                     int color,
                                                     int oldColor,
                                                     boolean causedBySwirl)
        Adds a Color animation
        Parameters:
        p - The point
        color - The color
        oldColor - the old color
        causedBySwirl - Flag, if caused by swirl effect.
        Returns:
        The created or existing PointAnimation
      • addPointChainExplodeAnimation

        public PointAnimation addPointChainExplodeAnimation​(Point p,
                                                            Point target)
        Adds a Chain explosion animation
        Parameters:
        p - The source point
        target - the target point.
        Returns:
        The created or existing PointAnimation
      • containsPointAnimation

        public boolean containsPointAnimation​(Point p)
        Checks, if an animation for the given point exist.
        Parameters:
        p - The point.
        Returns:
        true, if an animation for the given point exist.
      • containsAdditionalAnimation

        public boolean containsAdditionalAnimation​(java.lang.Object o)
        Checks, if an additional animation is contained for the key.
        Parameters:
        o - The key.
        Returns:
        true, if a Animation exists.
      • getAdditionalAnimation

        public Animation getAdditionalAnimation​(java.lang.Object o)
        Gets an additional animation for the given object.
        Parameters:
        o - The key.
        Returns:
        The Animation or null, if none exists for the key.
      • addAdditionalAnimation

        public void addAdditionalAnimation​(java.lang.Object o,
                                           Animation a)
        Adds an additional Animation
        Parameters:
        o - The key
        a - The animation.
      • getAdditionalAnimationKeys

        public java.util.Set<java.lang.Object> getAdditionalAnimationKeys()
        Gets a set of additional animation keys.
        Returns:
        Set of additional animation keys.
      • getIndex

        public int getIndex()
        Gets the Index of this AnimationInfo.
        Returns:
        The index.
      • toString

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

        public java.lang.String getFigureAnimationString()
        Returns a string representation of the figure animations.
        Returns:
        A string representation.
      • getCopyForNextAnimation

        public AnimationInfo getCopyForNextAnimation​(int newIndex)
        Gets a copy for the next AnimationInfo.
        Parameters:
        newIndex - The next animations index.
        Returns:
        This instance with a reduced duration or null, if end of lifecyle is reached.
      • clear

        public void clear()
        Clears all animations.