Npc added
This commit is contained in:
parent
f1d32226bd
commit
75326f9437
@ -1,14 +1,19 @@
|
|||||||
package ruscz.game.gameOfProd.Cells;
|
package ruscz.game.gameOfProd.Cells;
|
||||||
|
|
||||||
import ruscz.game.gameOfProd.Map.Map;
|
import ruscz.game.gameOfProd.Map.Map;
|
||||||
|
import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class Npc extends Person {
|
public class Npc extends Person {
|
||||||
private int[] path;
|
private int[] path;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
|
Color color;
|
||||||
|
|
||||||
public Npc(int x, int y, Map map) {
|
public Npc(int x, int y, Map map) {
|
||||||
super(x, y, map);
|
super(x, y, map);
|
||||||
|
this.color = Color.cyan;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void move(int endX, int endY) {
|
public void move(int endX, int endY) {
|
||||||
@ -46,4 +51,10 @@ public class Npc extends Person {
|
|||||||
set(x,y);
|
set(x,y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics2D g) {
|
||||||
|
g.setColor(color);
|
||||||
|
g.fillOval(getX() * WindowOfFreeMove.CELL_SIZE, getY() * WindowOfFreeMove.CELL_SIZE, WindowOfFreeMove.CELL_SIZE, WindowOfFreeMove.CELL_SIZE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,7 @@ public class Map {
|
|||||||
private LinkedList<Block> block;
|
private LinkedList<Block> block;
|
||||||
private LinkedList<InteractionCell> interactionCells;
|
private LinkedList<InteractionCell> interactionCells;
|
||||||
private LinkedList<TriggerCell> triggerCells;
|
private LinkedList<TriggerCell> triggerCells;
|
||||||
|
private LinkedList<Npc> npcs;
|
||||||
private boolean isBlocked;
|
private boolean isBlocked;
|
||||||
private int idExit;
|
private int idExit;
|
||||||
private ImageCell imageCell;
|
private ImageCell imageCell;
|
||||||
@ -33,6 +34,7 @@ public class Map {
|
|||||||
moveToCells = new LinkedList<EventMoveToCell>();
|
moveToCells = new LinkedList<EventMoveToCell>();
|
||||||
interactionCells = new LinkedList<InteractionCell>();
|
interactionCells = new LinkedList<InteractionCell>();
|
||||||
triggerCells = new LinkedList<TriggerCell>();
|
triggerCells = new LinkedList<TriggerCell>();
|
||||||
|
npcs = new LinkedList<>();
|
||||||
block = new LinkedList<Block>();
|
block = new LinkedList<Block>();
|
||||||
isBlocked = false;
|
isBlocked = false;
|
||||||
imageCell = new ImageCell();
|
imageCell = new ImageCell();
|
||||||
@ -63,6 +65,7 @@ public class Map {
|
|||||||
interactionCells = new LinkedList<InteractionCell>();
|
interactionCells = new LinkedList<InteractionCell>();
|
||||||
triggerCells = new LinkedList<TriggerCell>();
|
triggerCells = new LinkedList<TriggerCell>();
|
||||||
mapArray = new TypeOfCell[height][width];
|
mapArray = new TypeOfCell[height][width];
|
||||||
|
npcs = new LinkedList<>();
|
||||||
this.isBlocked = isBlocked;
|
this.isBlocked = isBlocked;
|
||||||
imageCell = new ImageCell();
|
imageCell = new ImageCell();
|
||||||
|
|
||||||
@ -92,6 +95,7 @@ public class Map {
|
|||||||
block = new LinkedList<Block>();
|
block = new LinkedList<Block>();
|
||||||
isBlocked = false;
|
isBlocked = false;
|
||||||
imageCell = new ImageCell();
|
imageCell = new ImageCell();
|
||||||
|
npcs = new LinkedList<>();
|
||||||
this.mapArray = mapArray;
|
this.mapArray = mapArray;
|
||||||
person = new Person(this);
|
person = new Person(this);
|
||||||
}
|
}
|
||||||
@ -114,6 +118,7 @@ public class Map {
|
|||||||
TypeOfCell[][] mapArray = new TypeOfCell[Integer.parseInt(size[0])][Integer.parseInt(size[1])];
|
TypeOfCell[][] mapArray = new TypeOfCell[Integer.parseInt(size[0])][Integer.parseInt(size[1])];
|
||||||
Map map = new Map(mapArray);
|
Map map = new Map(mapArray);
|
||||||
map.setName(name);
|
map.setName(name);
|
||||||
|
map.npcs = new LinkedList<>();
|
||||||
map.getImageCell().readMapFile(name + "-tileset");
|
map.getImageCell().readMapFile(name + "-tileset");
|
||||||
LinkedList<String[]> listOfMoveToCells = new LinkedList<>();
|
LinkedList<String[]> listOfMoveToCells = new LinkedList<>();
|
||||||
int y = 0;
|
int y = 0;
|
||||||
@ -194,6 +199,14 @@ public class Map {
|
|||||||
triggerCells.add(triggerCell);
|
triggerCells.add(triggerCell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setNpcs(Npc npc){
|
||||||
|
npcs.add(npc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkedList<Npc> getNpcs(){
|
||||||
|
return npcs;
|
||||||
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,6 @@
|
|||||||
package ruscz.game.gameOfProd.Windows;
|
package ruscz.game.gameOfProd.Windows;
|
||||||
|
|
||||||
import ruscz.game.gameOfProd.Cells.Cell;
|
import ruscz.game.gameOfProd.Cells.*;
|
||||||
import ruscz.game.gameOfProd.Cells.EventMoveToCell;
|
|
||||||
import ruscz.game.gameOfProd.Cells.InteractionCell;
|
|
||||||
import ruscz.game.gameOfProd.Cells.TriggerCell;
|
|
||||||
import ruscz.game.gameOfProd.Dialog.Dialog;
|
import ruscz.game.gameOfProd.Dialog.Dialog;
|
||||||
import ruscz.game.gameOfProd.Dialog.DialogBar;
|
import ruscz.game.gameOfProd.Dialog.DialogBar;
|
||||||
import ruscz.game.gameOfProd.Map.Map;
|
import ruscz.game.gameOfProd.Map.Map;
|
||||||
@ -186,6 +183,9 @@ public class WindowOfFreeMove extends JFrame {
|
|||||||
m4.linkMaps(m4, this);
|
m4.linkMaps(m4, this);
|
||||||
m5.linkMaps(m5, this);
|
m5.linkMaps(m5, this);
|
||||||
|
|
||||||
|
Npc npc = new Npc(1,1,m5);
|
||||||
|
m5.setNpcs(npc);
|
||||||
|
|
||||||
map = new MapPainter(mapLinkedList, canvas);
|
map = new MapPainter(mapLinkedList, canvas);
|
||||||
|
|
||||||
setMap(m5);
|
setMap(m5);
|
||||||
@ -230,6 +230,9 @@ public class WindowOfFreeMove extends JFrame {
|
|||||||
for (Cell cell : map.getActualMap().getInteractionEventCells()) {
|
for (Cell cell : map.getActualMap().getInteractionEventCells()) {
|
||||||
cell.paint(g2D);
|
cell.paint(g2D);
|
||||||
}
|
}
|
||||||
|
for (Person person: map.getActualMap().getNpcs()){
|
||||||
|
person.paint(g2D);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user