Class Npc


  • public class Npc
    extends Person
    Person-like cell that is controlled by application
    • Field Detail

      • name

        private java.lang.String name
      • direction

        private int direction
      • width

        private int width
      • height

        private int height
      • offsetX

        private int offsetX
      • offsetY

        private int offsetY
      • widthCoef

        private double widthCoef
      • heightCoef

        private double heightCoef
      • imageNpc

        private java.lang.String imageNpc
      • battle

        private java.lang.String battle
      • timer

        private javax.swing.Timer timer
    • Constructor Detail

      • Npc

        public Npc​(int x,
                   int y,
                   java.lang.String name,
                   Map map,
                   MapManager mapManager)
      • Npc

        public Npc​(int x,
                   int y,
                   Map map,
                   MapManager mapManager)
    • Method Detail

      • move

        public void move​(int endX,
                         int endY)
        Finds closest path from current position to end and moves NPC accordingly
        Parameters:
        endX - ending X value
        endY - ending Y value
      • stopNPCMove

        private void stopNPCMove​(int endX,
                                 int endY)
        Stops NPC's movement and if battle name is not null and there is Player in front of NPC, is starts battle sequence
        Parameters:
        endX - ending X value
        endY - ending Y value
      • moveUp

        private void moveUp()
        Moves NPC up one cell
      • moveDown

        private void moveDown()
        Moves NPC down one cell
      • moveLeft

        private void moveLeft()
        Moves NPC left one cell
      • moveRight

        private void moveRight()
        Moves NPC right one cell
      • loadNpc

        private void loadNpc()
        Loads NPC's attributes from file
      • paint

        public void paint​(java.awt.Graphics2D g)
        Overrides:
        paint in class Person
      • setDirection

        public void setDirection​(int direction)
      • getName

        public java.lang.String getName()
      • getTimer

        public javax.swing.Timer getTimer()