Add fog of war effect

This commit is contained in:
drdev
2015-03-12 05:20:48 +00:00
parent af6cd2c896
commit 52cb888706
3 changed files with 19 additions and 3 deletions

View File

@@ -8,7 +8,6 @@ import forge.Graphics;
import forge.assets.FImage; import forge.assets.FImage;
import forge.assets.FSkinColor; import forge.assets.FSkinColor;
import forge.assets.FSkinFont; import forge.assets.FSkinFont;
import forge.assets.FSkinImage;
import forge.card.CardDetailUtil; import forge.card.CardDetailUtil;
import forge.card.CardRenderer; import forge.card.CardRenderer;
import forge.card.CardDetailUtil.DetailColors; import forge.card.CardDetailUtil.DetailColors;
@@ -23,6 +22,8 @@ import forge.toolbox.FList.ListItemRenderer;
import forge.util.FCollectionView; import forge.util.FCollectionView;
public class ConquestMapScreen extends FScreen { public class ConquestMapScreen extends FScreen {
private static final Color FOG_OF_WAR_COLOR = FSkinColor.alphaColor(Color.BLACK, 0.6f);
private final FList<Region> lstRegions; private final FList<Region> lstRegions;
private ConquestData model; private ConquestData model;
@@ -115,6 +116,8 @@ public class ConquestMapScreen extends FScreen {
} }
} }
int regionCount = model.getCurrentPlane().getRegions().size();
//draw path with opponents //draw path with opponents
float x0, y0, prevX = x + w / 2, prevY = y + h; float x0, y0, prevX = x + w / 2, prevY = y + h;
float colWidth = w / cols; float colWidth = w / cols;
@@ -131,7 +134,7 @@ public class ConquestMapScreen extends FScreen {
GridPosition pos = path[i]; GridPosition pos = path[i];
x0 = x + colWidth * pos.col + colWidth / 2; x0 = x + colWidth * pos.col + colWidth / 2;
y0 = y + rowHeight * pos.row + rowHeight / 2; y0 = y + rowHeight * pos.row + rowHeight / 2;
if (i > 0 || index < model.getCurrentPlane().getRegions().size() - 1) { //extend path from previous region if any if (i > 0 || index < regionCount - 1) { //extend path from previous region if any
g.drawLine(lineThickness, Color.WHITE, x0, y0, prevX, prevY); g.drawLine(lineThickness, Color.WHITE, x0, y0, prevX, prevY);
} }
prevX = x0; prevX = x0;
@@ -151,6 +154,12 @@ public class ConquestMapScreen extends FScreen {
g.fillCircle(Color.BLACK, x0 + iconSize / 2, y0 + iconSize / 2, iconBackdropRadius); g.fillCircle(Color.BLACK, x0 + iconSize / 2, y0 + iconSize / 2, iconBackdropRadius);
g.drawImage((FImage)opponents.get(i).getMapIcon(), x0, y0, iconSize, iconSize); g.drawImage((FImage)opponents.get(i).getMapIcon(), x0, y0, iconSize, iconSize);
} }
//draw fog of war overlay if region not yet unlocked
int startIndex = (regionCount - index - 1) * opponents.size();
if (startIndex > model.getCurrentPlaneData().getProgress()) {
g.fillRect(FOG_OF_WAR_COLOR, x, y, w, h);
}
} }
} }

View File

@@ -272,6 +272,8 @@ public enum ConquestPlane {
} }
public static class Region { public static class Region {
public static final int OPPONENTS_PER_REGION = 15;
private final String name; private final String name;
private final String artCardName; private final String artCardName;
private final ColorSet colorSet; private final ColorSet colorSet;
@@ -325,7 +327,7 @@ public enum ConquestPlane {
//each region should have 15 opponents include one boss //each region should have 15 opponents include one boss
private void generateOpponents() { private void generateOpponents() {
int opponentsBeforeBoss = 15; //TODO: Reduce by 1 when boss added below int opponentsBeforeBoss = OPPONENTS_PER_REGION; //TODO: Reduce by 1 when boss added below
HashSet<PaperCard> cards = new HashSet<PaperCard>(commanders); HashSet<PaperCard> cards = new HashSet<PaperCard>(commanders);
if (cards.size() < opponentsBeforeBoss) { if (cards.size() < opponentsBeforeBoss) {
//if not enough commanders, add normal creatures as non-commander opponents //if not enough commanders, add normal creatures as non-commander opponents

View File

@@ -18,6 +18,7 @@ public class ConquestPlaneData {
private int wins, losses; private int wins, losses;
private int winStreakBest = 0; private int winStreakBest = 0;
private int winStreakCurrent = 0; private int winStreakCurrent = 0;
private int progress = 0;
public ConquestPlaneData(ConquestPlane plane0) { public ConquestPlaneData(ConquestPlane plane0) {
plane = plane0; plane = plane0;
@@ -77,6 +78,10 @@ public class ConquestPlaneData {
return winStreakCurrent; return winStreakCurrent;
} }
public int getProgress() {
return progress;
}
public int getUnlockedCount() { public int getUnlockedCount() {
int count = 0; int count = 0;
HashSet<PaperCard> collection = FModel.getConquest().getModel().getCollection(); HashSet<PaperCard> collection = FModel.getConquest().getModel().getCollection();