Package ruscz.game.gameOfProd.Cells
Class Npc
- java.lang.Object
-
- ruscz.game.gameOfProd.Cells.Cell
-
- ruscz.game.gameOfProd.Cells.Person
-
- ruscz.game.gameOfProd.Cells.Npc
-
public class Npc extends Person
Person-like cell that is controlled by application
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringbattleprivate intdirectionprivate intheightprivate doubleheightCoefprivate java.lang.StringimageNpcprivate MapManagermapManagerprivate java.lang.Stringnameprivate intoffsetXprivate intoffsetYprivate javax.swing.Timertimerprivate intwidthprivate doublewidthCoef
-
Constructor Summary
Constructors Constructor Description Npc(int x, int y, java.lang.String name, Map map, MapManager mapManager)Npc(int x, int y, Map map, MapManager mapManager)
-
Method Summary
Modifier and Type Method Description java.lang.StringgetName()javax.swing.TimergetTimer()private voidloadNpc()Loads NPC's attributes from filevoidmove(int endX, int endY)Finds closest path from current position to end and moves NPC accordinglyprivate voidmoveDown()Moves NPC down one cellprivate voidmoveLeft()Moves NPC left one cellprivate voidmoveRight()Moves NPC right one cellprivate voidmoveUp()Moves NPC up one cellvoidpaint(java.awt.Graphics2D g)voidsetDirection(int direction)private voidstopNPCMove(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-
Methods inherited from class ruscz.game.gameOfProd.Cells.Person
animateMove, getDirectionMoveLast, getDirectionSight, getDistance, getIsMoving, getMap, isInEvent, move, setDirectionMove, setDirectionMoveLast, setDirectionSight, setDistance, setImagePerson, setInEvent, setIsMoving
-
-
-
-
Field Detail
-
mapManager
private final MapManager mapManager
-
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 valueendY- 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 valueendY- 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
-
setDirection
public void setDirection(int direction)
-
getName
public java.lang.String getName()
-
getTimer
public javax.swing.Timer getTimer()
-
-