No longer displays information for unexplored tiles

This commit is contained in:
Yair Morgenstern 2018-01-01 22:45:21 +02:00
parent c0927cf49f
commit 74f1b6837b
2 changed files with 164 additions and 159 deletions

View File

@ -99,7 +99,7 @@ public class CityScreen extends CameraStageBaseScreen {
private Image getSpecialistIcon(String imageName, final String building, final boolean isFilled, final FullStats specialistType) {
Image specialist = ImageGetter.getImage(imageName);
specialist.setSize(40,40);
specialist.setSize(50,50);
if(!isFilled) specialist.setColor(Color.GRAY);
specialist.addListener(new ClickListener(){
@Override

View File

@ -44,15 +44,15 @@ public class WorldScreen extends CameraStageBaseScreen {
float buttonScale = game.settings.buttonScale;
Table tileTable = new Table();
Table civTable = new Table();
TextButton techButton = new TextButton("",skin);
public LinqHashMap<String,WorldTileGroup> tileGroups = new LinqHashMap<String, WorldTileGroup>();
TextButton techButton = new TextButton("", skin);
public LinqHashMap<String, WorldTileGroup> tileGroups = new LinqHashMap<String, WorldTileGroup>();
Table optionsTable = new Table();
Table notificationsTable = new Table();
TextButton selectIdleUnitButton;
public WorldScreen() {
new Label("",skin).getStyle().font.getData().setScale(game.settings.labelScale);
new Label("", skin).getStyle().font.getData().setScale(game.settings.labelScale);
addTiles();
stage.addActor(tileTable);
@ -73,7 +73,7 @@ public class WorldScreen extends CameraStageBaseScreen {
stage.addActor(techButton);
ScrollPane notificationsScroll = new ScrollPane(notificationsTable);
notificationsScroll.setSize(stage.getWidth()/3, stage.getHeight()/3);
notificationsScroll.setSize(stage.getWidth() / 3, stage.getHeight() / 3);
stage.addActor(notificationsScroll);
addSelectIdleUnitButton();
update();
@ -84,10 +84,10 @@ public class WorldScreen extends CameraStageBaseScreen {
}
private void addSelectIdleUnitButton() {
selectIdleUnitButton = new TextButton("Select next idle unit",skin);
selectIdleUnitButton.setPosition(stage.getWidth()/2-selectIdleUnitButton.getWidth()/2,5);
selectIdleUnitButton = new TextButton("Select next idle unit", skin);
selectIdleUnitButton.setPosition(stage.getWidth() / 2 - selectIdleUnitButton.getWidth() / 2, 5);
stage.addActor(selectIdleUnitButton);
selectIdleUnitButton.addListener(new ClickListener(){
selectIdleUnitButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
LinqCollection<TileInfo> tilesWithIdleUnits = game.civInfo.tileMap.values().where(new Predicate<TileInfo>() {
@ -98,31 +98,30 @@ public class WorldScreen extends CameraStageBaseScreen {
});
TileInfo tileToSelect;
if(!tilesWithIdleUnits.contains(selectedTile))
tileToSelect=tilesWithIdleUnits.get(0);
if (!tilesWithIdleUnits.contains(selectedTile))
tileToSelect = tilesWithIdleUnits.get(0);
else {
int index = tilesWithIdleUnits.indexOf(selectedTile)+1;
if(tilesWithIdleUnits.size()==index) index=0;
int index = tilesWithIdleUnits.indexOf(selectedTile) + 1;
if (tilesWithIdleUnits.size() == index) index = 0;
tileToSelect = tilesWithIdleUnits.get(index);
}
}
setCenterPosition(tileToSelect.position);
selectedTile =tileToSelect;
selectedTile = tileToSelect;
update();
}
});
}
void updateIdleUnitButton(){
void updateIdleUnitButton() {
if (game.civInfo.tileMap.values().any(new Predicate<TileInfo>() {
@Override
public boolean evaluate(TileInfo arg0) {
return arg0.hasIdleUnit();
}
})){
})) {
selectIdleUnitButton.setColor(Color.WHITE);
selectIdleUnitButton.setTouchable(Touchable.enabled);
}
else {
} else {
selectIdleUnitButton.setColor(Color.GRAY);
selectIdleUnitButton.setTouchable(Touchable.disabled);
}
@ -130,9 +129,8 @@ public class WorldScreen extends CameraStageBaseScreen {
private void updateNotificationsList() {
notificationsTable.clearChildren();
for(String notification : game.civInfo.notifications)
{
Label label = new Label(notification,skin);
for (String notification : game.civInfo.notifications) {
Label label = new Label(notification, skin);
label.setColor(Color.WHITE);
notificationsTable.add(label).pad(10).fill();
notificationsTable.row();
@ -140,24 +138,24 @@ public class WorldScreen extends CameraStageBaseScreen {
notificationsTable.pack();
}
public void update(){
public void update() {
updateTechButton();
updateTileTable();
updateTiles();
updateCivTable();
updateNotificationsList();
updateIdleUnitButton();
if(game.civInfo.tech.freeTechs!=0) {
if (game.civInfo.tech.freeTechs != 0) {
game.setScreen(new TechPickerScreen(true));
}
}
void addOptionsTable(){
void addOptionsTable() {
optionsTable.setVisible(false);
TextButton OpenCivilopediaButton = new TextButton("Civilopedia",skin);
OpenCivilopediaButton.addListener(new ClickListener(){
TextButton OpenCivilopediaButton = new TextButton("Civilopedia", skin);
OpenCivilopediaButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.setScreen(new CivilopediaScreen());
@ -167,8 +165,8 @@ public class WorldScreen extends CameraStageBaseScreen {
optionsTable.add(OpenCivilopediaButton).pad(10);
optionsTable.row();
TextButton StartNewGameButton = new TextButton("Start new game",skin);
StartNewGameButton.addListener(new ClickListener(){
TextButton StartNewGameButton = new TextButton("Start new game", skin);
StartNewGameButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.startNewGame();
@ -177,8 +175,8 @@ public class WorldScreen extends CameraStageBaseScreen {
optionsTable.add(StartNewGameButton).pad(10);
optionsTable.row();
TextButton OpenScienceVictoryScreen = new TextButton("Science victory status",skin);
OpenScienceVictoryScreen.addListener(new ClickListener(){
TextButton OpenScienceVictoryScreen = new TextButton("Science victory status", skin);
OpenScienceVictoryScreen.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.setScreen(new ScienceVictoryScreen());
@ -187,8 +185,8 @@ public class WorldScreen extends CameraStageBaseScreen {
optionsTable.add(OpenScienceVictoryScreen).pad(10);
optionsTable.row();
TextButton OpenPolicyPickerScreen = new TextButton("Social Policies",skin);
OpenPolicyPickerScreen.addListener(new ClickListener(){
TextButton OpenPolicyPickerScreen = new TextButton("Social Policies", skin);
OpenPolicyPickerScreen.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.setScreen(new PolicyPickerScreen());
@ -198,8 +196,8 @@ public class WorldScreen extends CameraStageBaseScreen {
optionsTable.row();
TextButton closeButton = new TextButton("Close",skin);
closeButton.addListener(new ClickListener(){
TextButton closeButton = new TextButton("Close", skin);
closeButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
optionsTable.setVisible(false);
@ -207,15 +205,15 @@ public class WorldScreen extends CameraStageBaseScreen {
});
optionsTable.add(closeButton).pad(10);
optionsTable.pack(); // Needed to show the background.
optionsTable.setPosition(stage.getWidth()/2- optionsTable.getWidth()/2,
stage.getHeight()/2- optionsTable.getHeight()/2);
optionsTable.setPosition(stage.getWidth() / 2 - optionsTable.getWidth() / 2,
stage.getHeight() / 2 - optionsTable.getHeight() / 2);
stage.addActor(optionsTable);
}
private void updateTechButton() {
techButton.setVisible(game.civInfo.cities.size()!=0);
techButton.setVisible(game.civInfo.cities.size() != 0);
techButton.clearListeners();
techButton.addListener(new ClickListener(){
techButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.setScreen(new TechPickerScreen());
@ -227,7 +225,7 @@ public class WorldScreen extends CameraStageBaseScreen {
+ game.civInfo.turnsToTech(game.civInfo.tech.currentTechnology()) + " turns");
techButton.setSize(techButton.getPrefWidth(), techButton.getPrefHeight());
techButton.setPosition(10, civTable.getY() - techButton.getHeight()-5);
techButton.setPosition(10, civTable.getY() - techButton.getHeight() - 5);
}
private void updateCivTable() {
@ -235,8 +233,8 @@ public class WorldScreen extends CameraStageBaseScreen {
civTable.row().pad(15);
CivStats currentStats = game.civInfo.civStats;
TextButton CivilopediaButton = new TextButton("Menu",skin);
CivilopediaButton.addListener(new ClickListener(){
TextButton CivilopediaButton = new TextButton("Menu", skin);
CivilopediaButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
optionsTable.setVisible(!optionsTable.isVisible());
@ -247,25 +245,27 @@ public class WorldScreen extends CameraStageBaseScreen {
civTable.add(CivilopediaButton)
.size(CivilopediaButton.getWidth() * buttonScale, CivilopediaButton.getHeight() * buttonScale);
civTable.add(new Label("Turns: " + game.civInfo.turns+"/400", skin));
civTable.add(new Label("Turns: " + game.civInfo.turns + "/400", skin));
CivStats nextTurnStats = game.civInfo.getStatsForNextTurn();
civTable.add(new Label("Gold: " + Math.round(currentStats.gold)
+ "(" +(nextTurnStats.gold >0?"+":"") + Math.round(nextTurnStats.gold) +")", skin));
+ "(" + (nextTurnStats.gold > 0 ? "+" : "") + Math.round(nextTurnStats.gold) + ")", skin));
Label scienceLabel = new Label("Science: +" + Math.round(nextTurnStats.science)
+"\r\n"+game.civInfo.tech.getAmountResearchedText(), skin);
+ "\r\n" + game.civInfo.tech.getAmountResearchedText(), skin);
scienceLabel.setAlignment(Align.center);
civTable.add(scienceLabel);
String happinessText = "Happiness: " + Math.round(game.civInfo.getHappinessForNextTurn());
if(game.civInfo.isGoldenAge()) happinessText+="\r\n GOLDEN AGE ("+game.civInfo.turnsLeftForCurrentGoldenAge+")";
else happinessText+= "\r\n ("+(int)game.civInfo.civStats.happiness+"/"+game.civInfo.happinessRequiredForNextGoldenAge()+")";
if (game.civInfo.isGoldenAge())
happinessText += "\r\n GOLDEN AGE (" + game.civInfo.turnsLeftForCurrentGoldenAge + ")";
else
happinessText += "\r\n (" + (int) game.civInfo.civStats.happiness + "/" + game.civInfo.happinessRequiredForNextGoldenAge() + ")";
Label happinessLabel = new Label(happinessText, skin);
happinessLabel.setAlignment(Align.center);
civTable.add(happinessLabel);
String cultureString = "Culture: " + "+" + Math.round(nextTurnStats.culture) +"\r\n"
+"("+ ((int) game.civInfo.civStats.culture)+"/"+game.civInfo.getCultureNeededForNextPolicy()+")";
String cultureString = "Culture: " + "+" + Math.round(nextTurnStats.culture) + "\r\n"
+ "(" + ((int) game.civInfo.civStats.culture) + "/" + game.civInfo.getCultureNeededForNextPolicy() + ")";
Label cultureLabel = new Label(cultureString, skin);
cultureLabel.setAlignment(Align.center);
civTable.add(cultureLabel);
@ -283,13 +283,13 @@ public class WorldScreen extends CameraStageBaseScreen {
@Override
public void clicked(InputEvent event, float x, float y) {
if (game.civInfo.tech.currentTechnology() == null
&& game.civInfo.cities.size()!=0) {
&& game.civInfo.cities.size() != 0) {
game.setScreen(new TechPickerScreen());
return;
}
game.civInfo.nextTurn();
unitTile=null;
GameSaver.SaveGame(game,"Autosave");
unitTile = null;
GameSaver.SaveGame(game, "Autosave");
update();
}
});
@ -298,7 +298,7 @@ public class WorldScreen extends CameraStageBaseScreen {
stage.addActor(nextTurnButton);
}
private void addTiles() {
final Group allTiles = new Group();
@ -313,22 +313,21 @@ public class WorldScreen extends CameraStageBaseScreen {
group.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
selectedTile = tileInfo;
if(unitTile != null && group.tileInfo.unit == null ) {
LinqHashMap<TileInfo, Float> distanceToTiles = game.civInfo.tileMap.getDistanceToTilesWithinTurn(unitTile.position,unitTile.unit.currentMovement);
if(distanceToTiles.containsKey(selectedTile)) {
unitTile.moveUnitToTile(group.tileInfo,distanceToTiles.get(selectedTile));
}
else {
unitTile.unit.action="moveTo "+ ((int) selectedTile.position.x)+","+ ((int) selectedTile.position.y);
unitTile.unit.doAction(unitTile);
selectedTile = tileInfo;
if (unitTile != null && group.tileInfo.unit == null) {
LinqHashMap<TileInfo, Float> distanceToTiles = game.civInfo.tileMap.getDistanceToTilesWithinTurn(unitTile.position, unitTile.unit.currentMovement);
if (distanceToTiles.containsKey(selectedTile)) {
unitTile.moveUnitToTile(group.tileInfo, distanceToTiles.get(selectedTile));
} else {
unitTile.unit.action = "moveTo " + ((int) selectedTile.position.x) + "," + ((int) selectedTile.position.y);
unitTile.unit.doAction(unitTile);
}
unitTile = null;
selectedTile = group.tileInfo;
}
unitTile = null;
selectedTile = group.tileInfo;
}
update();
update();
}
});
@ -371,7 +370,7 @@ public class WorldScreen extends CameraStageBaseScreen {
lastScale = scrollPane.getScaleX();
}
float scale = (float) Math.sqrt(distance / initialDistance) * lastScale;
if(scale<1) return;
if (scale < 1) return;
scrollPane.setScale(scale);
game.settings.tilesZoom = scale;
}
@ -381,48 +380,51 @@ public class WorldScreen extends CameraStageBaseScreen {
}
private void updateTileTable() {
if(selectedTile == null) return;
if (selectedTile == null) return;
tileTable.clearChildren();
FullStats stats = selectedTile.getTileStats();
tileTable.pad(20);
tileTable.columnDefaults(0).padRight(10);
Label cityStatsHeader = new Label("Tile Stats",skin);
Label cityStatsHeader = new Label("Tile Stats", skin);
cityStatsHeader.setFontScale(2);
tileTable.add(cityStatsHeader).colspan(2).pad(10);
tileTable.row();
tileTable.add(new Label(selectedTile.toString(),skin)).colspan(2);
tileTable.row();
HashMap<String,Float> TileStatsValues = new HashMap<String, Float>();
TileStatsValues.put("Production",stats.production);
TileStatsValues.put("Food",stats.food);
TileStatsValues.put("Gold",stats.gold);
TileStatsValues.put("Science",stats.science);
TileStatsValues.put("Culture",stats.culture);
for(String key : TileStatsValues.keySet()){
if(TileStatsValues.get(key) == 0) continue; // this tile gives nothing of this stat, so why even display it?
tileTable.add(com.unciv.game.utils.ImageGetter.getStatIcon(key)).align(Align.right);
tileTable.add(new Label(Math.round(TileStatsValues.get(key))+"",skin)).align(Align.left);
if (selectedTile.explored) {
tileTable.add(new Label(selectedTile.toString(), skin)).colspan(2);
tileTable.row();
HashMap<String, Float> TileStatsValues = new HashMap<String, Float>();
TileStatsValues.put("Production", stats.production);
TileStatsValues.put("Food", stats.food);
TileStatsValues.put("Gold", stats.gold);
TileStatsValues.put("Science", stats.science);
TileStatsValues.put("Culture", stats.culture);
for (String key : TileStatsValues.keySet()) {
if (TileStatsValues.get(key) == 0)
continue; // this tile gives nothing of this stat, so why even display it?
tileTable.add(com.unciv.game.utils.ImageGetter.getStatIcon(key)).align(Align.right);
tileTable.add(new Label(Math.round(TileStatsValues.get(key)) + "", skin)).align(Align.left);
tileTable.row();
}
}
if(selectedTile.unit !=null){
if (selectedTile.unit != null) {
TextButton moveUnitButton = new TextButton("Move to", skin);
if(unitTile == selectedTile) moveUnitButton = new TextButton("Stop movement",skin);
if (unitTile == selectedTile) moveUnitButton = new TextButton("Stop movement", skin);
moveUnitButton.getLabel().setFontScale(buttonScale);
if(selectedTile.unit.currentMovement == 0){
if (selectedTile.unit.currentMovement == 0) {
moveUnitButton.setColor(Color.GRAY);
moveUnitButton.setTouchable(Touchable.disabled);
}
moveUnitButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if(unitTile!=null) {
if (unitTile != null) {
unitTile = null;
update();
return;
@ -430,8 +432,8 @@ public class WorldScreen extends CameraStageBaseScreen {
unitTile = selectedTile;
// Set all tiles transparent except those in unit range
for(TileGroup TG : tileGroups.linqValues()) TG.setColor(0,0,0,0.3f);
for(TileInfo tile : game.civInfo.tileMap.getDistanceToTilesWithinTurn(unitTile.position,unitTile.unit.currentMovement).keySet()){
for (TileGroup TG : tileGroups.linqValues()) TG.setColor(0, 0, 0, 0.3f);
for (TileInfo tile : game.civInfo.tileMap.getDistanceToTilesWithinTurn(unitTile.position, unitTile.unit.currentMovement).keySet()) {
tileGroups.get(tile.position.toString()).setColor(Color.WHITE);
}
@ -441,7 +443,7 @@ public class WorldScreen extends CameraStageBaseScreen {
tileTable.add(moveUnitButton).colspan(2)
.size(moveUnitButton.getWidth() * buttonScale, moveUnitButton.getHeight() * buttonScale);
if(selectedTile.unit.name.equals("Settler")) {
if (selectedTile.unit.name.equals("Settler")) {
addUnitAction(tileTable, "Found City",
!game.civInfo.tileMap.getTilesInDistance(selectedTile.position, 2).any(new Predicate<TileInfo>() {
@Override
@ -461,23 +463,25 @@ public class WorldScreen extends CameraStageBaseScreen {
});
}
if(selectedTile.unit.name.equals("Worker")) {
if (selectedTile.unit.name.equals("Worker")) {
String improvementButtonText = selectedTile.improvementInProgress == null ?
"Construct\r\nimprovement" : selectedTile.improvementInProgress +"\r\nin progress";
addUnitAction(tileTable,improvementButtonText, !selectedTile.isCityCenter() ||
GameBasics.TileImprovements.linqValues().any(new Predicate<TileImprovement>() {
@Override
public boolean evaluate(TileImprovement arg0) {
return selectedTile.canBuildImprovement(arg0);
}
})
,new ClickListener() {
"Construct\r\nimprovement" : selectedTile.improvementInProgress + "\r\nin progress";
addUnitAction(tileTable, improvementButtonText, !selectedTile.isCityCenter() ||
GameBasics.TileImprovements.linqValues().any(new Predicate<TileImprovement>() {
@Override
public boolean evaluate(TileImprovement arg0) {
return selectedTile.canBuildImprovement(arg0);
}
})
, new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {game.setScreen(new ImprovementPickerScreen(selectedTile));}
} );
addUnitAction(tileTable, "automation".equals(selectedTile.unit.action)? "Stop automation" : "Automate", true,
new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
game.setScreen(new ImprovementPickerScreen(selectedTile));
}
});
addUnitAction(tileTable, "automation".equals(selectedTile.unit.action) ? "Stop automation" : "Automate", true,
new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if ("automation".equals(selectedTile.unit.action))
@ -491,87 +495,87 @@ public class WorldScreen extends CameraStageBaseScreen {
});
}
if(selectedTile.unit.name.equals("Great Scientist")){
addUnitAction(tileTable, "Discover Technology",true,
new ClickListener(){
if (selectedTile.unit.name.equals("Great Scientist")) {
addUnitAction(tileTable, "Discover Technology", true,
new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.civInfo.tech.freeTechs+=1;
selectedTile.unit=null;// destroy!
game.civInfo.tech.freeTechs += 1;
selectedTile.unit = null;// destroy!
game.setScreen(new TechPickerScreen(true));
}
});
addUnitAction(tileTable, "Construct Academy",true,
new ClickListener(){
addUnitAction(tileTable, "Construct Academy", true,
new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
selectedTile.improvement="Academy";
selectedTile.unit=null;// destroy!
selectedTile.improvement = "Academy";
selectedTile.unit = null;// destroy!
update();
}
});
}
if(selectedTile.unit.name.equals("Great Artist")){
addUnitAction(tileTable, "Start Golden Age",true,
new ClickListener(){
if (selectedTile.unit.name.equals("Great Artist")) {
addUnitAction(tileTable, "Start Golden Age", true,
new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.civInfo.enterGoldenAge();
selectedTile.unit=null;// destroy!
selectedTile.unit = null;// destroy!
update();
}
});
addUnitAction(tileTable, "Construct Landmark",true,
new ClickListener(){
addUnitAction(tileTable, "Construct Landmark", true,
new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
selectedTile.improvement="Landmark";
selectedTile.unit=null;// destroy!
selectedTile.improvement = "Landmark";
selectedTile.unit = null;// destroy!
update();
}
});
}
if(selectedTile.unit.name.equals("Great Engineer")){
addUnitAction(tileTable, "Hurry Wonder",selectedTile.isCityCenter() &&
if (selectedTile.unit.name.equals("Great Engineer")) {
addUnitAction(tileTable, "Hurry Wonder", selectedTile.isCityCenter() &&
selectedTile.getCity().cityConstructions.getCurrentConstruction() instanceof Building &&
((Building)selectedTile.getCity().cityConstructions.getCurrentConstruction()).isWonder,
new ClickListener(){
((Building) selectedTile.getCity().cityConstructions.getCurrentConstruction()).isWonder,
new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
selectedTile.getCity().cityConstructions.addConstruction(300 + (30 * selectedTile.getCity().population)); //http://civilization.wikia.com/wiki/Great_engineer_(Civ5)
selectedTile.unit=null; // destroy!
selectedTile.unit = null; // destroy!
update();
}
});
addUnitAction(tileTable, "Construct Manufactory",true,
new ClickListener(){
addUnitAction(tileTable, "Construct Manufactory", true,
new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
selectedTile.improvement="Manufactory";
selectedTile.unit=null;// destroy!
selectedTile.improvement = "Manufactory";
selectedTile.unit = null;// destroy!
update();
}
});
}
if(selectedTile.unit.name.equals("Great Merchant")){
addUnitAction(tileTable, "Conduct Trade Mission",true,
new ClickListener(){
if (selectedTile.unit.name.equals("Great Merchant")) {
addUnitAction(tileTable, "Conduct Trade Mission", true,
new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.civInfo.civStats.gold+=350; // + 50 * era_number - todo!
selectedTile.unit=null; // destroy!
game.civInfo.civStats.gold += 350; // + 50 * era_number - todo!
selectedTile.unit = null; // destroy!
update();
}
});
addUnitAction(tileTable, "Construct Customs House",true,
new ClickListener(){
addUnitAction(tileTable, "Construct Customs House", true,
new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
selectedTile.improvement="Customs House";
selectedTile.unit=null;// destroy!
selectedTile.improvement = "Customs House";
selectedTile.unit = null;// destroy!
update();
}
});
@ -580,7 +584,7 @@ public class WorldScreen extends CameraStageBaseScreen {
tileTable.pack();
tileTable.setPosition(stage.getWidth()-10- tileTable.getWidth(), 10);
tileTable.setPosition(stage.getWidth() - 10 - tileTable.getWidth(), 10);
}
private void addUnitAction(Table tileTable, String actionText, boolean canAct, ClickListener action) {
@ -601,7 +605,8 @@ public class WorldScreen extends CameraStageBaseScreen {
private void updateTiles() {
for (WorldTileGroup WG : tileGroups.linqValues()) WG.update(this);
if(unitTile!=null) return; // While we're in "unit move" mode, no tiles but the tiles the unit can move to will be "visible"
if (unitTile != null)
return; // While we're in "unit move" mode, no tiles but the tiles the unit can move to will be "visible"
// YES A TRIPLE FOR, GOT PROBLEMS WITH THAT?
// Seriously though, there is probably a more efficient way of doing this, probably?
@ -610,41 +615,41 @@ public class WorldScreen extends CameraStageBaseScreen {
HashSet<String> ViewableVectorStrings = new HashSet<String>();
// tiles adjacent to city tiles
for(TileInfo tileInfo : game.civInfo.tileMap.values())
if(game.civInfo.civName.equals(tileInfo.owner))
for(Vector2 adjacentLocation : HexMath.GetAdjacentVectors(tileInfo.position))
for (TileInfo tileInfo : game.civInfo.tileMap.values())
if (game.civInfo.civName.equals(tileInfo.owner))
for (Vector2 adjacentLocation : HexMath.GetAdjacentVectors(tileInfo.position))
ViewableVectorStrings.add(adjacentLocation.toString());
// Tiles within 2 tiles of units
for(TileInfo tile : game.civInfo.tileMap.values()
for (TileInfo tile : game.civInfo.tileMap.values()
.where(new Predicate<TileInfo>() {
@Override
public boolean evaluate(TileInfo arg0) {
return arg0.unit !=null;
}
}))
for(Vector2 vector : HexMath.GetVectorsInDistance(tile.position,2))
@Override
public boolean evaluate(TileInfo arg0) {
return arg0.unit != null;
}
}))
for (Vector2 vector : HexMath.GetVectorsInDistance(tile.position, 2))
ViewableVectorStrings.add(vector.toString());
for(String string : ViewableVectorStrings)
if(tileGroups.containsKey(string))
for (String string : ViewableVectorStrings)
if (tileGroups.containsKey(string))
tileGroups.get(string).setIsViewable(true);
}
void setCenterPosition(final Vector2 vector){
void setCenterPosition(final Vector2 vector) {
TileGroup TG = tileGroups.linqValues().first(new Predicate<WorldTileGroup>() {
@Override
public boolean evaluate(WorldTileGroup arg0) {
return arg0.tileInfo.position.equals(vector) ;
return arg0.tileInfo.position.equals(vector);
}
});
scrollPane.layout(); // Fit the scroll pane to the contents - otherwise, setScroll won't work!
// We want to center on the middle of TG (TG.getX()+TG.getWidth()/2)
// and so the scroll position (== where the screen starts) needs to be half a screen away
scrollPane.setScrollX(TG.getX()+TG.getWidth()/2-stage.getWidth()/2);
scrollPane.setScrollX(TG.getX() + TG.getWidth() / 2 - stage.getWidth() / 2);
// Here it's the same, only the Y axis is inverted - when at 0 we're at the top, not bottom - so we invert it back.
scrollPane.setScrollY(scrollPane.getMaxY() - (TG.getY() + TG.getWidth()/2 - stage.getHeight()/2));
scrollPane.setScrollY(scrollPane.getMaxY() - (TG.getY() + TG.getWidth() / 2 - stage.getHeight() / 2));
scrollPane.updateVisualScroll();
}