Commit c1bcdfc1 authored by Guillaume Hocquet's avatar Guillaume Hocquet

Minimap Display : Multiplayer

parent 6d370a64
package core.event;
import artificial_intelligence.AIControler;
import core.gamestate.Entity;
import core.gamestate.GameContent;
......
package core.gamestate;
import core.zone.Point;
import map_generation.map.Map;
import network.NetworkConnection;
import network.NetworkObject;
......@@ -9,14 +10,12 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import core.zone.Point;
/**
* Just a class to contain a Map and a GameState
*
* Possible improvement: design a readonly interface for it, to give to the gui to ensure she isn't able to modify it.
*
*
* @author Dupriez Thomas
* @author Guerquin Arnaud
*
......@@ -78,7 +77,7 @@ public class GameContent implements Serializable{
return gameState.getOnlyBeings();
}
public List<Being> getAllBeings() {
return gameState.getAllBeings();
return gameState.getAllBeings();
}
public List<Character> getOnlyCharacters() {
......@@ -95,6 +94,10 @@ public class GameContent implements Serializable{
return players.get(i);
}
public ArrayList<Character> getAllPlayers() {
return players;
}
public void applyTrigger(NetworkConnection<NetworkObject> networkConnection) {
for(Entity e:triggerEntities){
e.checkTrigger(this,networkConnection);
......@@ -104,7 +107,7 @@ public class GameContent implements Serializable{
public void addTriggerToCheck(Entity e) {
triggerEntities.add(e);
}
public void removeTriggerToCheck(Entity e) {
triggerEntities.remove(e);
......
package graphics.guiSkeleton;
import core.gamestate.Character;
import core.gamestate.GameContent;
import core.relayer.Relayer;
import graphics.guiSkeleton.guiPanel.GamePanel;
......@@ -11,6 +12,7 @@ import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.WritableRaster;
import java.util.ArrayList;
/**
* Created by ghocquet on 02/01/16.
......@@ -22,6 +24,7 @@ public class MinimapDisplayer
private Graphics2D g_map;
private Relayer relayer;
private GamePanel gamePanel;
private GameContent gameContent;
private BufferedImage map;
private int mapWidth;
private int mapHeight;
......@@ -29,6 +32,7 @@ public class MinimapDisplayer
private int tileH = TileSprite.TileSpriteHeight();
private Color playerColor = new Color(255,0,0);
private Color stairsColor = new Color(255,255,0);
private Color friendColor = new Color(0,255,0);
/**
* @param gameContent: used to get the map generated
......@@ -39,6 +43,7 @@ public class MinimapDisplayer
Relayer followedRelayer,
GamePanel gamePanel)
{
this.gameContent = gameContent;
this.relayer = followedRelayer;
this.gamePanel = gamePanel;
......@@ -71,8 +76,17 @@ public class MinimapDisplayer
// Update the map
Graphics2D g_newMap = newMap.createGraphics();
g_newMap.setColor(playerColor);
g_newMap.drawRect(relayer.getCharacter().getY()/tileW-1,relayer.getCharacter().getX()/tileH-1,3,3);
ArrayList<Character> playerList = gameContent.getAllPlayers();
for (Character player : playerList) {
if (player.getName() == relayer.getCharacter().getName()) {
g_newMap.setColor(playerColor);
g_newMap.drawRect(player.getY() / tileW - 1, player.getX() / tileH - 1, 3, 3);
}
else {
g_newMap.setColor(friendColor);
g_newMap.drawRect(player.getY() / tileW - 1, player.getX() / tileH - 1, 3, 3);
}
}
// Draw on the Screen
g.drawImage(newMap, gamePanel.getSize().width - (mapWidth-1) / tileW, 0, null);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment