Class Enemy

  • All Implemented Interfaces:
    Constants, java.lang.Runnable

    public class Enemy
    extends Object
    implements Constants
    This class handles the enemy object
    • Constructor Detail

      • Enemy

        public Enemy​(Scene scene,
                     Cell cell,
                     java.util.concurrent.locks.Lock lock)
        Initialize the enemy
        Parameters:
        scene - The scene the enemy is in
        cell - The cell this enemy is in
        lock - The lock used to prevent the threads from conflicting
    • Method Detail

      • setSound

        public void setSound​(Sound sound)
        Set the enemy attack sound
        Parameters:
        sound - The sound
      • setDirection

        public void setDirection​(Enemy.Direction direction)
        Set the direction of the enemy
        Parameters:
        direction - The direction the enemy is facing
      • moveUp

        public boolean moveUp()
        Move up
        Overrides:
        moveUp in class Object
        Returns:
        If movement is not possible returns false
      • moveDown

        public boolean moveDown()
        Move down
        Overrides:
        moveDown in class Object
        Returns:
        If movement is not possible move down
      • moveLeft

        public boolean moveLeft()
        Move left
        Overrides:
        moveLeft in class Object
        Returns:
        If movement is not possible returns false
      • moveRight

        public boolean moveRight()
        Move right
        Overrides:
        moveRight in class Object
        Returns:
        If movement is not possible returns false
      • getAi

        public EnemyAI getAi()
        Get the AI in use by the enemy
        Returns:
        Returns the current AI in use
      • run

        public void run()
        This method is run constantly by the runnable
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class Object