java.lang.Object
fr.r1r0r0.deltaengine.model.elements.cells.Cell
All Implemented Interfaces:
Element<java.lang.Integer>
Direct Known Subclasses:
CrossableCell, RestrictiveCell, UncrossableCell

public abstract class Cell
extends java.lang.Object
implements Element<java.lang.Integer>
A Cell in a grid. Atomic element of a MapLevel, used to render background textures.
  • Field Summary

    Fields
    Modifier and Type Field Description
    private Coordinates<java.lang.Integer> coords  
    private static Dimension dimension  
    private java.lang.String name  
    private Sprite sprite  
  • Constructor Summary

    Constructors
    Constructor Description
    Cell​(int x, int y, Sprite sprite)
    Default constructor.
  • Method Summary

    Modifier and Type Method Description
    Coordinates<java.lang.Integer> getCoordinates()
    Coordinates of the element in the game.
    Dimension getDimension()
    Return dimension of the Element.
    java.lang.String getName()
    Name getter of the element
    Sprite getSprite()
    Returns sprite of the element
    abstract boolean isCrossableBy​(Entity entity)
    Checks if given entity can cross this cell.
    void setCoordinates​(Coordinates<java.lang.Integer> coordinates)
    Allows setting new coordinates for the element.
    void setDimension​(Dimension dimension)
    Allows to set dimension of the element, representing its size.
    void setSprite​(Sprite sprite)
    Set sprite of an element

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • dimension

      private static final Dimension dimension
    • coords

      private Coordinates<java.lang.Integer> coords
    • sprite

      private Sprite sprite
    • name

      private java.lang.String name
  • Constructor Details

    • Cell

      public Cell​(int x, int y, Sprite sprite)
      Default constructor. Set a case sprite and coordinates in the map.
      Parameters:
      x - the abscissa coordinate of the cell in the map. Coordinates values are integers.
      y - the ordinate coordinate of the cell in the map. Coordinates values are integers.
      sprite - the sprite to apply on the case
  • Method Details

    • getDimension

      public final Dimension getDimension()
      Description copied from interface: Element
      Return dimension of the Element. Represents the size of the Element.
      Specified by:
      getDimension in interface Element<java.lang.Integer>
      Returns:
      Dimension of the element
    • setDimension

      public void setDimension​(Dimension dimension)
      Description copied from interface: Element
      Allows to set dimension of the element, representing its size.
      Specified by:
      setDimension in interface Element<java.lang.Integer>
      Parameters:
      dimension - Dimension to set
    • getSprite

      public Sprite getSprite()
      Description copied from interface: Element
      Returns sprite of the element
      Specified by:
      getSprite in interface Element<java.lang.Integer>
      Returns:
      Sprite of the element
    • setSprite

      public void setSprite​(Sprite sprite)
      Description copied from interface: Element
      Set sprite of an element
      Specified by:
      setSprite in interface Element<java.lang.Integer>
      Parameters:
      sprite - sprite to set
    • getCoordinates

      public Coordinates<java.lang.Integer> getCoordinates()
      Description copied from interface: Element
      Coordinates of the element in the game.
      Specified by:
      getCoordinates in interface Element<java.lang.Integer>
      Returns:
      Coordinates of the element
    • setCoordinates

      public void setCoordinates​(Coordinates<java.lang.Integer> coordinates)
      Description copied from interface: Element
      Allows setting new coordinates for the element.
      Specified by:
      setCoordinates in interface Element<java.lang.Integer>
      Parameters:
      coordinates - new coordinates
    • getName

      public java.lang.String getName()
      Description copied from interface: Element
      Name getter of the element
      Specified by:
      getName in interface Element<java.lang.Integer>
      Returns:
      String name of the element
    • isCrossableBy

      public abstract boolean isCrossableBy​(Entity entity)
      Checks if given entity can cross this cell. If entity cannot cross cell, then it will be blocked.
      Parameters:
      entity - entity to check if he can cross
      Returns:
      boolean true if given entity can cross the cell, false otherwise.