Class Field

  • All Implemented Interfaces:
    java.io.Serializable

    public class Field
    extends java.lang.Object
    implements java.io.Serializable
    The field for a game of Starpoints. The field stores a number of points and handles point events when a Thing enters or stays on a point by calling the corresponding methods in this fields levels Effects.
    See Also:
    Serialized Form
    • Constructor Detail

      • Field

        public Field​(Level level,
                     LevelInfo levelinfo)
        Creates a field for the given level. The width, height and depth are taken from the given level.
        Parameters:
        level - The level to create the field for.
        levelinfo - The levelinfo.
    • Method Detail

      • isRandomPoint

        public boolean isRandomPoint​(int x,
                                     int y)
        Checks, if a random point is on position x,y.
        Parameters:
        x - The x coordinate
        y - The y coordinate
        Returns:
        true, if the field info has a random point at the position.
      • getRandomColor

        public int getRandomColor​(boolean includeSwirling)
        Gets a random color depending on the levels settings.
        Parameters:
        includeSwirling - Flag, if swirling colors should be included in random colors
        Returns:
        A random color.
      • getWidth

        public int getWidth()
        Gets this fields width.
        Returns:
        The width
      • getHeight

        public int getHeight()
        Gets this fields height.
        Returns:
        The height
      • getRandomBlueColor

        public int getRandomBlueColor()
        Gets a random blue color depending on the levels settings.
        Returns:
        A random blue color.
      • getExplosionEnergyLoss

        public int getExplosionEnergyLoss()
        Gets the eexplosion energy loss depending on the levels settings.
        Returns:
        The energy loss in an expolosion per round.
      • getLevel

        public Level getLevel()
        Returns the level for this field.
        Returns:
        The level.
      • getPoint

        public Point getPoint​(int x,
                              int y)
        Gets the point at the given coordinates. If the coordinates are off the field bounds, a lightGray Point for the given coordinates with no reference to the game is returned.
        Parameters:
        x - The x coordinate
        y - The y coordinate
        Returns:
        The point at the given coordinates
      • addFieldListener

        public void addFieldListener​(FieldListener listener)
        Adds a field listener.
        Parameters:
        listener - The listener
      • removeFieldListener

        public void removeFieldListener​(FieldListener listener)
        Removes a field listener.
        Parameters:
        listener - The listener
      • rocketStarted

        public void rocketStarted​(ItemRocket r)
        Fires the rocket started event.
        Parameters:
        r - The rocket.
      • bigMinePlaced

        public void bigMinePlaced​(ItemBigMine r)
        Fires the bigmine placed event.
        Parameters:
        r - The mine.
      • updateField

        public void updateField​(AnimationInfo animation)
        Updates the field by calling the update method for every point and the updateEnergy-method for all point occupants afterwards.
        Parameters:
        animation - The AnimationInfo.
      • getExplosionCount

        public int getExplosionCount​(Figure source)
        Counts the explosions currently on the field.
        Parameters:
        source - The source of the explosions. Pass null for all explosions.
        Returns:
        The number of explosions caused by the source, or all if null is passed.
      • getExplosionStrength

        public int getExplosionStrength​(Figure source)
        Aggregates the explosions strength currently on the field.
        Parameters:
        source - The source of the explosions. Pass null for all explosions.
        Returns:
        The sum of explosion strengths caused by the source, or all if null is passed.
      • colorPoints

        public void colorPoints​(Point center,
                                int radius,
                                int newcolor,
                                Thing source,
                                AnimationInfo animation)
        Colors the points on the field in a best possible circle around the center point in the given color.
        Parameters:
        center - The center point.
        radius - The radius of the circle to color.
        newcolor - The new color for the points.
        source - The color source.
        animation - The AnimationInfo.
      • stopSwirling

        public void stopSwirling​(Point center,
                                 int radius)
        Stops swirling on the points on the field in a best possible circle around the center point in the given color.
        Parameters:
        center - The center point.
        radius - The radius of the circle to stop swirling in.