Package com.starpoints.animation
Class FigureAnimation
- java.lang.Object
-
- com.starpoints.animation.Animation
-
- com.starpoints.animation.FigureAnimation
-
- All Implemented Interfaces:
java.io.Serializable
public class FigureAnimation extends Animation
Stores animation infos for a Figure.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Figure
figure
The figure.protected FigureMoveAnimation
moveAnimation
Move animation.protected FigureRocketAnimation
rocketAnimation
Rocket hit animation.protected java.util.HashMap<ShieldType,FigureShieldedAnimation>
shieldAnimations
Shield animations.-
Fields inherited from class com.starpoints.animation.Animation
duration, startDuration
-
-
Constructor Summary
Constructors Constructor Description FigureAnimation()
Creates an empty FigureAnimation.FigureAnimation(Figure f, Point srcPoint, Point targetPoint)
Creates a figure move animation.FigureAnimation(Figure f, Point srcPoint, Point targetPoint, boolean isRamming, int ramPower, Direction ramDir, Thing ramTarget)
Creates a figure ram animation.FigureAnimation(Figure f, Point srcPoint, Point targetPoint, boolean isRamming, int ramPower, Direction ramDir, Thing ramTarget, boolean isBlocked)
Creates a figure ram animation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMoveAnimation(Point srcPoint, Point targetPoint)
Addds a move animationvoid
addRamAnimation(Point srcPoint, Point targetPoint, boolean isRamming, int ramPower, Direction ramDir, Thing ramTarget)
Adds a figure ram animation.void
addRamAnimation(Point srcPoint, Point targetPoint, boolean isRamming, int ramPower, Direction ramDir, Thing ramTarget, boolean isBlocked)
Adds a figure ram animation.void
addShieldAnimation(ShieldType type, int power)
Adds a shield animation.protected Animation
getCopyForNextAnimation()
Gets a copy for the next AnimationInfo.Direction
getRamDir()
Gets the ram direction.int
getRamPower()
Gets the ram power.Direction
getRocketImpactDirection()
Gets the rocket impact direction.int
getRocketPower()
Gets the rocket power.java.util.Collection<FigureShieldedAnimation>
getShieldAnimations()
Gets a list of shield animations.int
getShieldPower(ShieldType type)
Gets the shield power for the given type.Point
getSrcPoint()
Gets the source point.Point
getTargetPoint()
Gets the target point.boolean
hasMoveAnimation()
Checks, if a move animation is contained.boolean
hasRocketAnimation()
Checks, if a rocket animation is contained.boolean
hasShieldAnimation()
Checks, if a shielding animation is contained.boolean
isBlocked()
Checks, if movement is blocked.boolean
isHitByRocket()
Checks, if figure was hit by rocket.boolean
isRamming()
Checks, if figure is ramming.boolean
isRammingEmpty()
Check, if ramming aims to an empty point (wher other figure moves to as well).boolean
isShielded(ShieldType type)
Checks, if shield animation for ShieldType exists.void
setHitByRocket(int rocketPower, Direction impactDirection)
Sets a flag that figure was hit by rocket.void
setIsBlocked(boolean b)
Set a blocked flag for move animation.void
setMovement(Point srcPoint, Point targetPoint)
Sets the move points.void
setRamming(boolean isRamming, int energy, Direction direction, Thing ramTarget)
Sets some ramming information.void
setRammingEmpty(boolean rammingEmpty)
Sets, if ramming aims to an empty point (wher other figure moves to as well).java.lang.String
toString()
Returns a string representation.-
Methods inherited from class com.starpoints.animation.Animation
clone, getLifecycleIndex
-
-
-
-
Field Detail
-
rocketAnimation
protected FigureRocketAnimation rocketAnimation
Rocket hit animation.
-
moveAnimation
protected FigureMoveAnimation moveAnimation
Move animation.
-
shieldAnimations
protected java.util.HashMap<ShieldType,FigureShieldedAnimation> shieldAnimations
Shield animations.
-
figure
protected Figure figure
The figure.
-
-
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 classAnimation
- 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 classjava.lang.Object
- Returns:
- A string representation.
-
-