mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-09 23:39:40 +07:00
Improvements on tiles can advance
Cannot create adjacent cities Standardized function and parameter names
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -125,3 +125,4 @@ Thumbs.db
|
||||
/ios-moe/xcode/native/
|
||||
gradle.properties
|
||||
SaveFiles/
|
||||
android/android-release.apk
|
||||
|
@ -21,7 +21,7 @@ android {
|
||||
applicationId "com.unciv.game"
|
||||
minSdkVersion 9
|
||||
targetSdkVersion 25
|
||||
versionCode 4
|
||||
versionCode 5
|
||||
versionName "0.9"
|
||||
}
|
||||
buildTypes {
|
||||
|
@ -29,7 +29,7 @@ public class CityBuildings
|
||||
public HashMap<String, Integer> InProgressBuildings = new HashMap<String, Integer>();
|
||||
public String CurrentBuilding = Worker; // default starting building!
|
||||
|
||||
public CityInfo GetCity(){return UnCivGame.Current.civInfo.tileMap.get(cityLocation).GetCity(); }
|
||||
public CityInfo GetCity(){return UnCivGame.Current.civInfo.tileMap.get(cityLocation).getCity(); }
|
||||
public boolean IsBuilt(String buildingName) { return BuiltBuildings.contains(buildingName); }
|
||||
public boolean IsBuilding(String buildingName) { return CurrentBuilding.equals(buildingName); }
|
||||
|
||||
@ -50,7 +50,7 @@ public class CityBuildings
|
||||
if (InProgressBuildings.get(CurrentBuilding) >= GetGameBuilding(CurrentBuilding).Cost)
|
||||
{
|
||||
if (CurrentBuilding.equals(Worker) || CurrentBuilding.equals(Settler))
|
||||
UnCivGame.Current.civInfo.tileMap.get(cityLocation).Unit = new Unit(CurrentBuilding,2);
|
||||
UnCivGame.Current.civInfo.tileMap.get(cityLocation).unit = new Unit(CurrentBuilding,2);
|
||||
|
||||
else
|
||||
{
|
||||
@ -58,7 +58,7 @@ public class CityBuildings
|
||||
Building gameBuilding = GetGameBuilding(CurrentBuilding);
|
||||
if (gameBuilding.ProvidesFreeBuilding != null && !BuiltBuildings.contains(gameBuilding.ProvidesFreeBuilding))
|
||||
BuiltBuildings.add(gameBuilding.ProvidesFreeBuilding);
|
||||
if (gameBuilding.FreeTechs != 0) UnCivGame.Current.civInfo.Tech.FreeTechs += gameBuilding.FreeTechs;
|
||||
if (gameBuilding.FreeTechs != 0) UnCivGame.Current.civInfo.tech.FreeTechs += gameBuilding.FreeTechs;
|
||||
}
|
||||
|
||||
InProgressBuildings.remove(CurrentBuilding);
|
||||
@ -80,22 +80,22 @@ public class CityBuildings
|
||||
{
|
||||
CivilizationInfo civInfo = UnCivGame.Current.civInfo;
|
||||
if(IsBuilt(building.Name)) return false;
|
||||
// if (building.Name.equals("Worker") || building.Name.equals("Settler")) return false;
|
||||
// if (building.name.equals("Worker") || building.name.equals("Settler")) return false;
|
||||
if(building.ResourceRequired) {
|
||||
boolean containsResourceWithImprovement = GetCity().getTilesInRange()
|
||||
.any(new Predicate<TileInfo>() {
|
||||
@Override
|
||||
public boolean evaluate(TileInfo tile) {
|
||||
return tile.Resource != null
|
||||
&& building.Name.equals(tile.GetTileResource().Building)
|
||||
&& tile.GetTileResource().Improvement.equals(tile.Improvement);
|
||||
return tile.resource != null
|
||||
&& building.Name.equals(tile.getTileResource().Building)
|
||||
&& tile.getTileResource().Improvement.equals(tile.improvement);
|
||||
}
|
||||
});
|
||||
if(!containsResourceWithImprovement) return false;
|
||||
}
|
||||
|
||||
if (building.RequiredTech != null && !civInfo.Tech.IsResearched(building.RequiredTech)) return false;
|
||||
if (building.IsWonder && civInfo.Cities
|
||||
if (building.RequiredTech != null && !civInfo.tech.IsResearched(building.RequiredTech)) return false;
|
||||
if (building.IsWonder && civInfo.cities
|
||||
.any(new Predicate<CityInfo>() {
|
||||
@Override
|
||||
public boolean evaluate(CityInfo arg0) {
|
||||
@ -105,7 +105,7 @@ public class CityBuildings
|
||||
}) ) return false;
|
||||
if (building.RequiredBuilding != null && !IsBuilt(building.RequiredBuilding)) return false;
|
||||
if (building.RequiredBuildingInAllCities != null ||
|
||||
civInfo.Cities.any(new Predicate<CityInfo>() {
|
||||
civInfo.cities.any(new Predicate<CityInfo>() {
|
||||
@Override
|
||||
public boolean evaluate(CityInfo arg0) {
|
||||
return arg0.cityBuildings.IsBuilt(building.RequiredBuildingInAllCities);
|
||||
|
@ -12,7 +12,7 @@ import java.util.ArrayList;
|
||||
|
||||
public class CityInfo {
|
||||
public final Vector2 cityLocation;
|
||||
public String Name;
|
||||
public String name;
|
||||
|
||||
public CityBuildings cityBuildings;
|
||||
public CityPopulation cityPopulation;
|
||||
@ -25,7 +25,7 @@ public class CityInfo {
|
||||
return getTileMap().getTilesInDistance(cityLocation,3).where(new Predicate<TileInfo>() {
|
||||
@Override
|
||||
public boolean evaluate(TileInfo arg0) {
|
||||
return UnCivGame.Current.civInfo.civName.equals(arg0.Owner);
|
||||
return UnCivGame.Current.civInfo.civName.equals(arg0.owner);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -47,27 +47,27 @@ public class CityInfo {
|
||||
}
|
||||
|
||||
CityInfo(CivilizationInfo civInfo, Vector2 cityLocation) {
|
||||
Name = CityNames[civInfo.Cities.size()];
|
||||
name = CityNames[civInfo.cities.size()];
|
||||
this.cityLocation = cityLocation;
|
||||
cityBuildings = new CityBuildings(this);
|
||||
cityPopulation = new CityPopulation();
|
||||
|
||||
for(TileInfo tileInfo : civInfo.tileMap.getTilesInDistance(cityLocation,1)) {
|
||||
tileInfo.Owner = civInfo.civName;
|
||||
tileInfo.owner = civInfo.civName;
|
||||
}
|
||||
civInfo.tileMap.get(cityLocation).WorkingCity = this.Name;
|
||||
civInfo.tileMap.get(cityLocation).workingCity = this.name;
|
||||
|
||||
|
||||
autoAssignWorker();
|
||||
civInfo.Cities.add(this);
|
||||
civInfo.cities.add(this);
|
||||
}
|
||||
|
||||
ArrayList<String> getLuxuryResources() {
|
||||
ArrayList<String> LuxuryResources = new ArrayList<String>();
|
||||
for (TileInfo tileInfo : getTilesInRange()) {
|
||||
TileResource resource = tileInfo.GetTileResource();
|
||||
if (resource != null && resource.ResourceType == ResourceType.Luxury && resource.Improvement.equals(tileInfo.Improvement))
|
||||
LuxuryResources.add(tileInfo.Resource);
|
||||
TileResource resource = tileInfo.getTileResource();
|
||||
if (resource != null && resource.ResourceType == ResourceType.Luxury && resource.Improvement.equals(tileInfo.improvement))
|
||||
LuxuryResources.add(tileInfo.resource);
|
||||
}
|
||||
return LuxuryResources;
|
||||
}
|
||||
@ -77,7 +77,7 @@ public class CityInfo {
|
||||
return getTilesInRange().count(new Predicate<TileInfo>() {
|
||||
@Override
|
||||
public boolean evaluate(TileInfo arg0) {
|
||||
return Name.equals(arg0.WorkingCity);
|
||||
return name.equals(arg0.workingCity);
|
||||
}
|
||||
})-1; // 1 is the city center
|
||||
}
|
||||
@ -99,8 +99,8 @@ public class CityInfo {
|
||||
|
||||
// Working ppl
|
||||
for (TileInfo cell : getTilesInRange())
|
||||
if (Name.equals(cell.WorkingCity) || cell.IsCityCenter())
|
||||
stats.add(cell.GetTileStats());
|
||||
if (name.equals(cell.workingCity) || cell.isCityCenter())
|
||||
stats.add(cell.getTileStats());
|
||||
|
||||
//idle ppl
|
||||
stats.Production += getFreePopulation();
|
||||
@ -123,10 +123,6 @@ public class CityInfo {
|
||||
|
||||
cityBuildings.NextTurn(stats.Production);
|
||||
|
||||
for (TileInfo tileInfo : getTilesInRange()) {
|
||||
tileInfo.NextTurn();
|
||||
}
|
||||
|
||||
cultureStored+=stats.Culture;
|
||||
if(cultureStored>=getCultureToNextTile()){
|
||||
addNewTile();
|
||||
@ -143,7 +139,7 @@ public class CityInfo {
|
||||
tiles = tiles.where(new Predicate<TileInfo>() {
|
||||
@Override
|
||||
public boolean evaluate(TileInfo arg0) {
|
||||
return arg0.Owner == null;
|
||||
return arg0.owner == null;
|
||||
}
|
||||
});
|
||||
if(tiles.size()==0) continue;
|
||||
@ -157,7 +153,7 @@ public class CityInfo {
|
||||
TileChosen = tile;
|
||||
}
|
||||
}
|
||||
TileChosen.Owner = UnCivGame.Current.civInfo.civName;
|
||||
TileChosen.owner = UnCivGame.Current.civInfo.civName;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -166,8 +162,8 @@ public class CityInfo {
|
||||
double maxValue = 0;
|
||||
TileInfo toWork = null;
|
||||
for (TileInfo tileInfo : getTilesInRange()) {
|
||||
if (tileInfo.WorkingCity!=null) continue;
|
||||
FullStats stats = tileInfo.GetTileStats();
|
||||
if (tileInfo.workingCity !=null) continue;
|
||||
FullStats stats = tileInfo.getTileStats();
|
||||
|
||||
double value = stats.Food + stats.Production * 0.5;
|
||||
if (value > maxValue) {
|
||||
@ -175,11 +171,11 @@ public class CityInfo {
|
||||
toWork = tileInfo;
|
||||
}
|
||||
}
|
||||
toWork.WorkingCity = Name;
|
||||
toWork.workingCity = name;
|
||||
}
|
||||
|
||||
private double rankTile(TileInfo tile){
|
||||
FullStats stats = tile.GetTileStats();
|
||||
FullStats stats = tile.getTileStats();
|
||||
double rank=0;
|
||||
if(stats.Food<2) rank+=stats.Food;
|
||||
else rank += 2 + (stats.Food-2)/2; // 1 point for each food up to 2, from there on half a point
|
||||
@ -187,7 +183,7 @@ public class CityInfo {
|
||||
rank+=stats.Production;
|
||||
rank+=stats.Science;
|
||||
rank+=stats.Culture;
|
||||
if(tile.Improvement==null) rank+=0.5; // Improvement potential!
|
||||
if(tile.improvement ==null) rank+=0.5; // improvement potential!
|
||||
return rank;
|
||||
}
|
||||
}
|
@ -18,50 +18,50 @@ public class CivilizationInfo {
|
||||
public int baseHappiness = 15;
|
||||
public String civName = "Babylon";
|
||||
|
||||
public CivilizationTech Tech = new CivilizationTech();
|
||||
public CivilizationTech tech = new CivilizationTech();
|
||||
public int turns = 1;
|
||||
|
||||
public LinqCollection<CityInfo> Cities = new LinqCollection<CityInfo>();
|
||||
public LinqCollection<CityInfo> cities = new LinqCollection<CityInfo>();
|
||||
|
||||
public TileMap tileMap = new TileMap(20);
|
||||
|
||||
public int CurrentCity=0; //index!
|
||||
public int currentCity =0; //index!
|
||||
|
||||
public CivilizationInfo(){
|
||||
}
|
||||
|
||||
|
||||
public CityInfo GetCurrentCity() { return Cities.get(CurrentCity); }
|
||||
public CityInfo getCurrentCity() { return cities.get(currentCity); }
|
||||
|
||||
public int TurnsToTech(String TechName) {
|
||||
return (int) Math.ceil((float)(GameBasics.Technologies.get(TechName).Cost - Tech.ResearchOfTech(TechName))
|
||||
/ GetStatsForNextTurn().Science);
|
||||
public int turnsToTech(String TechName) {
|
||||
return (int) Math.ceil((float)(GameBasics.Technologies.get(TechName).Cost - tech.ResearchOfTech(TechName))
|
||||
/ getStatsForNextTurn().Science);
|
||||
}
|
||||
|
||||
public void addCity(Vector2 location){
|
||||
CityInfo city = new CityInfo(this,location);
|
||||
if(Cities.size()==1) city.cityBuildings.BuiltBuildings.add("Palace");
|
||||
if(cities.size()==1) city.cityBuildings.BuiltBuildings.add("Palace");
|
||||
}
|
||||
|
||||
public void NextTurn()//out boolean displayTech)
|
||||
public void nextTurn()//out boolean displayTech)
|
||||
{
|
||||
CivStats nextTurnStats = GetStatsForNextTurn();
|
||||
CivStats nextTurnStats = getStatsForNextTurn();
|
||||
civStats.add(nextTurnStats);
|
||||
if(Cities.size() > 0) Tech.NextTurn(nextTurnStats.Science);
|
||||
if(cities.size() > 0) tech.NextTurn(nextTurnStats.Science);
|
||||
|
||||
for (CityInfo city : Cities.as(CityInfo.class)) city.nextTurn();
|
||||
for (CityInfo city : cities) city.nextTurn();
|
||||
|
||||
for(TileInfo tile : tileMap.values()) if(tile.Unit!=null) tile.Unit.CurrentMovement = tile.Unit.MaxMovement;
|
||||
for(TileInfo tile : tileMap.values()) tile.nextTurn();
|
||||
|
||||
turns += 1;
|
||||
}
|
||||
|
||||
public CivStats GetStatsForNextTurn() {
|
||||
public CivStats getStatsForNextTurn() {
|
||||
CivStats statsForTurn = new CivStats() {{
|
||||
Happiness = baseHappiness;
|
||||
}};
|
||||
HashSet<String> LuxuryResources = new HashSet<String>();
|
||||
for (CityInfo city : Cities) {
|
||||
for (CityInfo city : cities) {
|
||||
statsForTurn.add(city.getCityStats());
|
||||
LuxuryResources.addAll(city.getLuxuryResources());
|
||||
}
|
||||
|
@ -9,59 +9,65 @@ import com.unciv.models.gamebasics.TileImprovement;
|
||||
import com.unciv.models.gamebasics.TileResource;
|
||||
import com.unciv.models.stats.FullStats;
|
||||
|
||||
enum RoadStatus{
|
||||
None,
|
||||
Road,
|
||||
Railroad
|
||||
}
|
||||
|
||||
public class TileInfo
|
||||
{
|
||||
public Unit Unit;
|
||||
public Vector2 Position;
|
||||
public String BaseTerrain;
|
||||
public String TerrainFeature;
|
||||
public String Resource;
|
||||
// public boolean IsWorked = false;
|
||||
public String Improvement;
|
||||
public String ImprovementInProgress;
|
||||
public String Owner; // owning civ name
|
||||
public String WorkingCity; // Working City Name
|
||||
public int TurnsToImprovement;
|
||||
public Unit unit;
|
||||
public Vector2 position;
|
||||
public String baseTerrain;
|
||||
public String terrainFeature;
|
||||
public String resource;
|
||||
public String improvement;
|
||||
public String improvementInProgress;
|
||||
public String owner; // owning civ name
|
||||
public String workingCity; // Working City name
|
||||
public RoadStatus roadStatus = RoadStatus.None;
|
||||
public int turnsToImprovement;
|
||||
|
||||
public Terrain GetBaseTerrain(){return GameBasics.Terrains.get(BaseTerrain);}
|
||||
public CityInfo GetCity(){
|
||||
if(WorkingCity == null) return null;
|
||||
return CivilizationInfo.current().Cities.first(new Predicate<CityInfo>() {
|
||||
public Terrain getBaseTerrain(){return GameBasics.Terrains.get(baseTerrain);}
|
||||
public CityInfo getCity(){
|
||||
if(workingCity == null) return null;
|
||||
return CivilizationInfo.current().cities.first(new Predicate<CityInfo>() {
|
||||
@Override
|
||||
public boolean evaluate(CityInfo arg0) {
|
||||
return arg0.Name.equals(WorkingCity);
|
||||
return arg0.name.equals(workingCity);
|
||||
}
|
||||
});}
|
||||
|
||||
public Terrain GetTerrainFeature(){return TerrainFeature==null ? null : GameBasics.Terrains.get(TerrainFeature);}
|
||||
public Terrain getTerrainFeature(){return terrainFeature ==null ? null : GameBasics.Terrains.get(terrainFeature);}
|
||||
|
||||
public Terrain GetLastTerrain() {
|
||||
return TerrainFeature == null ? GetBaseTerrain() : GetTerrainFeature();
|
||||
public Terrain getLastTerrain() {
|
||||
return terrainFeature == null ? getBaseTerrain() : getTerrainFeature();
|
||||
}
|
||||
|
||||
public TileResource GetTileResource(){return Resource==null ? null : GameBasics.TileResources.get(Resource);}
|
||||
public TileResource getTileResource(){return resource ==null ? null : GameBasics.TileResources.get(resource);}
|
||||
|
||||
public boolean IsCityCenter(){return GetCity()!=null && Position.equals(GetCity().cityLocation);}
|
||||
public boolean isCityCenter(){return getCity()!=null && position.equals(getCity().cityLocation);}
|
||||
|
||||
public TileImprovement GetTileImprovement(){return Improvement==null ? null : GameBasics.TileImprovements.get(Improvement);}
|
||||
public TileImprovement getTileImprovement(){return improvement ==null ? null : GameBasics.TileImprovements.get(improvement);}
|
||||
|
||||
|
||||
private boolean IsResearched(String techName) { return UnCivGame.Current.civInfo.Tech.IsResearched(techName); }
|
||||
private boolean isResearched(String techName) { return UnCivGame.Current.civInfo.tech.IsResearched(techName); }
|
||||
|
||||
public FullStats GetTileStats()
|
||||
public FullStats getTileStats()
|
||||
{
|
||||
FullStats stats = new FullStats(GetBaseTerrain());
|
||||
FullStats stats = new FullStats(getBaseTerrain());
|
||||
|
||||
if(TerrainFeature!=null){
|
||||
Terrain terrainFeature = GetTerrainFeature();
|
||||
if(terrainFeature !=null){
|
||||
Terrain terrainFeature = getTerrainFeature();
|
||||
if(terrainFeature.OverrideStats) stats = new FullStats(terrainFeature);
|
||||
else stats.add(terrainFeature);
|
||||
}
|
||||
|
||||
TileResource resource = GetTileResource();
|
||||
TileResource resource = getTileResource();
|
||||
|
||||
CityInfo City = GetCity();
|
||||
if (HasViewableResource())
|
||||
CityInfo City = getCity();
|
||||
if (hasViewableResource())
|
||||
{
|
||||
stats.add(resource);
|
||||
if(resource.Building!=null && City!=null && City.cityBuildings.IsBuilt(resource.Building))
|
||||
@ -70,17 +76,17 @@ public class TileInfo
|
||||
}
|
||||
}
|
||||
|
||||
TileImprovement improvement = GetTileImprovement();
|
||||
TileImprovement improvement = getTileImprovement();
|
||||
if (improvement != null)
|
||||
{
|
||||
if (resource != null && resource.Improvement.equals(improvement.Name))
|
||||
stats.add(resource.ImprovementStats);
|
||||
else stats.add(improvement);
|
||||
|
||||
if (IsResearched(improvement.ImprovingTech)) stats.add(improvement.ImprovingTechStats);
|
||||
if (isResearched(improvement.ImprovingTech)) stats.add(improvement.ImprovingTechStats);
|
||||
}
|
||||
|
||||
if (City != null && City.cityLocation.equals(Position)) {
|
||||
if (City != null && City.cityLocation.equals(position)) {
|
||||
if (stats.Food < 2) stats.Food = 2;
|
||||
if (stats.Production < 1) stats.Production = 1;
|
||||
}
|
||||
@ -88,51 +94,53 @@ public class TileInfo
|
||||
return stats;
|
||||
}
|
||||
|
||||
public boolean CanBuildImprovement(TileImprovement improvement)
|
||||
public boolean canBuildImprovement(TileImprovement improvement)
|
||||
{
|
||||
Terrain topTerrain = TerrainFeature==null ? GetBaseTerrain() : GetTerrainFeature();
|
||||
if (improvement.TechRequired != null && !IsResearched(improvement.TechRequired)) return false;
|
||||
Terrain topTerrain = terrainFeature ==null ? getBaseTerrain() : getTerrainFeature();
|
||||
if (improvement.TechRequired != null && !isResearched(improvement.TechRequired)) return false;
|
||||
if (improvement.TerrainsCanBeBuiltOn.contains(topTerrain.Name)) return true;
|
||||
if (topTerrain.Unbuildable) return false;
|
||||
return Resource != null && GetTileResource().Improvement.equals(improvement.Name);
|
||||
return resource != null && getTileResource().Improvement.equals(improvement.Name);
|
||||
}
|
||||
|
||||
public void StartWorkingOnImprovement(TileImprovement improvement)
|
||||
public void startWorkingOnImprovement(TileImprovement improvement)
|
||||
{
|
||||
ImprovementInProgress = improvement.Name;
|
||||
TurnsToImprovement = improvement.TurnsToBuild;
|
||||
improvementInProgress = improvement.Name;
|
||||
turnsToImprovement = improvement.TurnsToBuild;
|
||||
}
|
||||
|
||||
public void StopWorkingOnImprovement()
|
||||
public void stopWorkingOnImprovement()
|
||||
{
|
||||
ImprovementInProgress = null;
|
||||
improvementInProgress = null;
|
||||
}
|
||||
|
||||
public void NextTurn()
|
||||
public void nextTurn()
|
||||
{
|
||||
if (ImprovementInProgress == null || Unit==null || !Unit.Name.equals("Worker")) return;
|
||||
TurnsToImprovement -= 1;
|
||||
if(TurnsToImprovement == 0)
|
||||
if(unit !=null) unit.CurrentMovement = unit.MaxMovement;
|
||||
|
||||
if (improvementInProgress == null || unit ==null || !unit.Name.equals("Worker")) return;
|
||||
turnsToImprovement -= 1;
|
||||
if(turnsToImprovement == 0)
|
||||
{
|
||||
if (ImprovementInProgress.startsWith("Remove")) TerrainFeature = null;
|
||||
else Improvement = ImprovementInProgress;
|
||||
if (improvementInProgress.startsWith("Remove")) terrainFeature = null;
|
||||
else improvement = improvementInProgress;
|
||||
|
||||
ImprovementInProgress = null;
|
||||
improvementInProgress = null;
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder SB = new StringBuilder(this.BaseTerrain);
|
||||
if (TerrainFeature != null) SB.append(",\r\n" + TerrainFeature);
|
||||
if (HasViewableResource()) SB.append(",\r\n" + Resource);
|
||||
if (Improvement != null) SB.append(",\r\n" + Improvement);
|
||||
if (ImprovementInProgress != null) SB.append(",\r\n" + ImprovementInProgress+" in "+this.TurnsToImprovement+" turns");
|
||||
if(Unit!=null) SB.append(",\r\n" + Unit.Name+ "("+Unit.CurrentMovement+"/"+Unit.MaxMovement+")");
|
||||
StringBuilder SB = new StringBuilder(this.baseTerrain);
|
||||
if (terrainFeature != null) SB.append(",\r\n" + terrainFeature);
|
||||
if (hasViewableResource()) SB.append(",\r\n" + resource);
|
||||
if (improvement != null) SB.append(",\r\n" + improvement);
|
||||
if (improvementInProgress != null) SB.append(",\r\n" + improvementInProgress +" in "+this.turnsToImprovement +" turns");
|
||||
if(unit !=null) SB.append(",\r\n" + unit.Name+ "("+ unit.CurrentMovement+"/"+ unit.MaxMovement+")");
|
||||
return SB.toString();
|
||||
}
|
||||
|
||||
public boolean HasViewableResource() {
|
||||
return Resource != null && (GetTileResource().RevealedBy==null || IsResearched(GetTileResource().RevealedBy));
|
||||
public boolean hasViewableResource() {
|
||||
return resource != null && (getTileResource().RevealedBy==null || isResearched(getTileResource().RevealedBy));
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package com.unciv.civinfo;
|
||||
|
||||
import com.badlogic.gdx.math.Vector;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Predicate;
|
||||
import com.unciv.game.HexMath;
|
||||
@ -24,36 +23,36 @@ public class TileMap{
|
||||
|
||||
private void addRandomTile(Vector2 position) {
|
||||
final TileInfo tileInfo = new TileInfo();
|
||||
tileInfo.Position = position;
|
||||
tileInfo.position = position;
|
||||
LinqCollection<Terrain> Terrains = GameBasics.Terrains.linqValues();
|
||||
|
||||
final Terrain baseTerrain = Terrains.where(new Predicate<Terrain>() {
|
||||
@Override
|
||||
public boolean evaluate(Terrain arg0) {
|
||||
return arg0.Type.equals("BaseTerrain") && !arg0.Name.equals("Lakes");
|
||||
return arg0.Type.equals("baseTerrain") && !arg0.Name.equals("Lakes");
|
||||
}
|
||||
}).getRandom();
|
||||
tileInfo.BaseTerrain = baseTerrain.Name;
|
||||
tileInfo.baseTerrain = baseTerrain.Name;
|
||||
|
||||
if (baseTerrain.CanHaveOverlay) {
|
||||
if (Math.random() > 0.7f) {
|
||||
Terrain SecondaryTerrain = Terrains.where(new Predicate<Terrain>() {
|
||||
@Override
|
||||
public boolean evaluate(Terrain arg0) {
|
||||
return arg0.Type.equals("TerrainFeature") && arg0.OccursOn.contains(baseTerrain.Name);
|
||||
return arg0.Type.equals("terrainFeature") && arg0.OccursOn.contains(baseTerrain.Name);
|
||||
}
|
||||
}).getRandom();
|
||||
if (SecondaryTerrain != null) tileInfo.TerrainFeature = SecondaryTerrain.Name;
|
||||
if (SecondaryTerrain != null) tileInfo.terrainFeature = SecondaryTerrain.Name;
|
||||
}
|
||||
}
|
||||
|
||||
LinqCollection<TileResource> TileResources = GameBasics.TileResources.linqValues();
|
||||
|
||||
// Resources are placed according to TerrainFeature, if exists, otherwise according to BaseLayer.
|
||||
// Resources are placed according to terrainFeature, if exists, otherwise according to BaseLayer.
|
||||
TileResources = TileResources.where(new Predicate<TileResource>() {
|
||||
@Override
|
||||
public boolean evaluate(TileResource arg0) {
|
||||
return arg0.TerrainsCanBeFoundOn.contains(tileInfo.GetLastTerrain().Name);
|
||||
return arg0.TerrainsCanBeFoundOn.contains(tileInfo.getLastTerrain().Name);
|
||||
}
|
||||
});
|
||||
|
||||
@ -65,7 +64,7 @@ public class TileMap{
|
||||
} else if (Math.random() < 1 / 10f) {
|
||||
resource = GetRandomResource(TileResources, ResourceType.Luxury);
|
||||
}
|
||||
if (resource != null) tileInfo.Resource = resource.Name;
|
||||
if (resource != null) tileInfo.resource = resource.Name;
|
||||
|
||||
tiles.put(position.toString(),tileInfo);
|
||||
}
|
||||
|
@ -65,14 +65,14 @@ public class CityScreen extends CameraStageBaseScreen {
|
||||
private void updateCityPickerTable() {
|
||||
CityPickerTable.clear();
|
||||
CityPickerTable.row().pad(20);
|
||||
if(game.civInfo.Cities.size()>1) {
|
||||
if(game.civInfo.cities.size()>1) {
|
||||
TextButton prevCityButton = new TextButton("<", skin);
|
||||
prevCityButton.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
com.unciv.civinfo.CivilizationInfo ci = game.civInfo;
|
||||
if (ci.CurrentCity == 0) ci.CurrentCity = ci.Cities.size()-1;
|
||||
else ci.CurrentCity--;
|
||||
if (ci.currentCity == 0) ci.currentCity = ci.cities.size()-1;
|
||||
else ci.currentCity--;
|
||||
game.setScreen(new CityScreen(game));
|
||||
dispose();
|
||||
}
|
||||
@ -80,18 +80,18 @@ public class CityScreen extends CameraStageBaseScreen {
|
||||
CityPickerTable.add(prevCityButton);
|
||||
}
|
||||
|
||||
Label currentCityLabel = new Label(game.civInfo.GetCurrentCity().Name, skin);
|
||||
Label currentCityLabel = new Label(game.civInfo.getCurrentCity().name, skin);
|
||||
currentCityLabel.setFontScale(2);
|
||||
CityPickerTable.add(currentCityLabel);
|
||||
|
||||
if(game.civInfo.Cities.size()>1) {
|
||||
if(game.civInfo.cities.size()>1) {
|
||||
TextButton nextCityButton = new TextButton(">", skin);
|
||||
nextCityButton.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
com.unciv.civinfo.CivilizationInfo ci = game.civInfo;
|
||||
if (ci.CurrentCity == ci.Cities.size()-1) ci.CurrentCity = 0;
|
||||
else ci.CurrentCity++;
|
||||
if (ci.currentCity == ci.cities.size()-1) ci.currentCity = 0;
|
||||
else ci.currentCity++;
|
||||
game.setScreen(new CityScreen(game));
|
||||
dispose();
|
||||
}
|
||||
@ -109,7 +109,7 @@ public class CityScreen extends CameraStageBaseScreen {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
game.setWorldScreen();
|
||||
game.worldScreen.setCenterPosition(game.civInfo.GetCurrentCity().cityLocation);
|
||||
game.worldScreen.setCenterPosition(game.civInfo.getCurrentCity().cityLocation);
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
@ -119,7 +119,7 @@ public class CityScreen extends CameraStageBaseScreen {
|
||||
}
|
||||
|
||||
private void addTiles() {
|
||||
final CityInfo cityInfo = game.civInfo.GetCurrentCity();
|
||||
final CityInfo cityInfo = game.civInfo.getCurrentCity();
|
||||
|
||||
Group allTiles = new Group();
|
||||
|
||||
@ -134,19 +134,19 @@ public class CityScreen extends CameraStageBaseScreen {
|
||||
});
|
||||
|
||||
if(!cityInfo.getTilesInRange().contains(tileInfo)) group.setColor(0,0,0,0.3f);
|
||||
else if(!tileInfo.IsCityCenter()) {
|
||||
else if(!tileInfo.isCityCenter()) {
|
||||
group.addPopulationIcon();
|
||||
group.populationImage.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
if(tileInfo.WorkingCity==null && cityInfo.getFreePopulation() > 0) tileInfo.WorkingCity = cityInfo.Name;
|
||||
else if(cityInfo.Name.equals(tileInfo.WorkingCity)) tileInfo.WorkingCity = null;
|
||||
if(tileInfo.workingCity ==null && cityInfo.getFreePopulation() > 0) tileInfo.workingCity = cityInfo.name;
|
||||
else if(cityInfo.name.equals(tileInfo.workingCity)) tileInfo.workingCity = null;
|
||||
updateCityTable();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Vector2 positionalVector = HexMath.Hex2WorldCoords(tileInfo.Position.cpy().sub(cityInfo.cityLocation));
|
||||
Vector2 positionalVector = HexMath.Hex2WorldCoords(tileInfo.position.cpy().sub(cityInfo.cityLocation));
|
||||
int groupSize = 50;
|
||||
group.setPosition(stage.getWidth()/2 + positionalVector.x*0.8f * groupSize,
|
||||
stage.getHeight()/2 + positionalVector.y*0.8f * groupSize);
|
||||
@ -185,7 +185,7 @@ public class CityScreen extends CameraStageBaseScreen {
|
||||
}
|
||||
|
||||
private void updateCityTable() {
|
||||
CityInfo cityInfo = game.civInfo.GetCurrentCity();
|
||||
CityInfo cityInfo = game.civInfo.getCurrentCity();
|
||||
FullStats stats = cityInfo.getCityStats();
|
||||
CityStatsTable.pad(20);
|
||||
CityStatsTable.columnDefaults(0).padRight(10);
|
||||
@ -211,7 +211,7 @@ public class CityScreen extends CameraStageBaseScreen {
|
||||
CityStatsTable.row();
|
||||
}
|
||||
|
||||
String CurrentBuilding = game.civInfo.GetCurrentCity().cityBuildings.CurrentBuilding;
|
||||
String CurrentBuilding = game.civInfo.getCurrentCity().cityBuildings.CurrentBuilding;
|
||||
|
||||
String BuildingText = "Pick building";
|
||||
if(CurrentBuilding != null) BuildingText = CurrentBuilding+"\r\n"
|
||||
@ -236,8 +236,8 @@ public class CityScreen extends CameraStageBaseScreen {
|
||||
if(selectedTile == null) return;
|
||||
TileTable.clearChildren();
|
||||
|
||||
CityInfo City =game.civInfo.GetCurrentCity();
|
||||
FullStats stats = selectedTile.GetTileStats();
|
||||
CityInfo City =game.civInfo.getCurrentCity();
|
||||
FullStats stats = selectedTile.getTileStats();
|
||||
TileTable.pad(20);
|
||||
TileTable.columnDefaults(0).padRight(10);
|
||||
|
||||
|
@ -5,7 +5,6 @@ import com.badlogic.gdx.scenes.scene2d.Group;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Container;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.unciv.civinfo.TileInfo;
|
||||
|
||||
public class TileGroup extends Group {
|
||||
@ -22,7 +21,7 @@ public class TileGroup extends Group {
|
||||
TileGroup(TileInfo tileInfo){
|
||||
this.tileInfo = tileInfo;
|
||||
|
||||
String terrainFileName = "TerrainIcons/" + tileInfo.GetLastTerrain().Name.replace(' ','_') + "_(Civ5).png";
|
||||
String terrainFileName = "TerrainIcons/" + tileInfo.getLastTerrain().Name.replace(' ','_') + "_(Civ5).png";
|
||||
terrainImage = ImageGetter.getImageByFilename(terrainFileName);
|
||||
terrainImage.setSize(50,50);
|
||||
addActor(terrainImage);
|
||||
@ -43,8 +42,8 @@ public class TileGroup extends Group {
|
||||
|
||||
void update() {
|
||||
|
||||
if (tileInfo.HasViewableResource() && resourceImage == null) { // Need to add the resource image!
|
||||
String fileName = "ResourceIcons/" + tileInfo.Resource + "_(Civ5).png";
|
||||
if (tileInfo.hasViewableResource() && resourceImage == null) { // Need to add the resource image!
|
||||
String fileName = "ResourceIcons/" + tileInfo.resource + "_(Civ5).png";
|
||||
Image image = ImageGetter.getImageByFilename(fileName);
|
||||
image.setSize(20,20);
|
||||
image.moveBy(terrainImage.getWidth()-image.getWidth(), 0); // bottom right
|
||||
@ -52,25 +51,25 @@ public class TileGroup extends Group {
|
||||
addActor(image);
|
||||
}
|
||||
|
||||
if (tileInfo.Unit != null && unitImage == null) {
|
||||
unitImage = ImageGetter.getImageByFilename("StatIcons/" + tileInfo.Unit.Name + "_(Civ5).png");
|
||||
if (tileInfo.unit != null && unitImage == null) {
|
||||
unitImage = ImageGetter.getImageByFilename("StatIcons/" + tileInfo.unit.Name + "_(Civ5).png");
|
||||
addActor(unitImage);
|
||||
unitImage.setSize(20, 20); // not moved - is at bottom left
|
||||
}
|
||||
|
||||
if (tileInfo.Unit == null && unitImage != null) {
|
||||
if (tileInfo.unit == null && unitImage != null) {
|
||||
unitImage.remove();
|
||||
unitImage = null;
|
||||
}
|
||||
|
||||
if(unitImage!=null){
|
||||
if(tileInfo.Unit.CurrentMovement==0) unitImage.setColor(Color.GRAY);
|
||||
if(tileInfo.unit.CurrentMovement==0) unitImage.setColor(Color.GRAY);
|
||||
else unitImage.setColor(Color.WHITE);
|
||||
}
|
||||
|
||||
|
||||
if (tileInfo.Improvement != null && improvementImage == null) {
|
||||
improvementImage = ImageGetter.getImageByFilename("ImprovementIcons/" + tileInfo.Improvement.replace(' ','_') + "_(Civ5).png");
|
||||
if (tileInfo.improvement != null && improvementImage == null) {
|
||||
improvementImage = ImageGetter.getImageByFilename("ImprovementIcons/" + tileInfo.improvement.replace(' ','_') + "_(Civ5).png");
|
||||
addActor(improvementImage);
|
||||
improvementImage.setSize(20, 20);
|
||||
improvementImage.moveBy(terrainImage.getWidth()-improvementImage.getWidth(),
|
||||
@ -78,7 +77,7 @@ public class TileGroup extends Group {
|
||||
}
|
||||
|
||||
if(populationImage!=null){
|
||||
if(tileInfo.WorkingCity!=null) populationImage.setColor(Color.WHITE);
|
||||
if(tileInfo.workingCity !=null) populationImage.setColor(Color.WHITE);
|
||||
else populationImage.setColor(Color.GRAY);
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class UnCivGame extends Game {
|
||||
|
||||
public void startNewGame(){
|
||||
civInfo = new CivilizationInfo();
|
||||
civInfo.tileMap.get(Vector2.Zero).Unit = new Unit("Settler",2);
|
||||
civInfo.tileMap.get(Vector2.Zero).unit = new Unit("Settler",2);
|
||||
|
||||
worldScreen = new WorldScreen(this);
|
||||
setWorldScreen();
|
||||
|
@ -17,7 +17,6 @@ import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Predicate;
|
||||
import com.unciv.civinfo.CityInfo;
|
||||
import com.unciv.civinfo.TileInfo;
|
||||
import com.unciv.game.pickerscreens.GameSaver;
|
||||
import com.unciv.game.pickerscreens.ImprovementPickerScreen;
|
||||
@ -123,7 +122,7 @@ public class WorldScreen extends CameraStageBaseScreen {
|
||||
}
|
||||
|
||||
private void updateTechButton() {
|
||||
TechButton.setVisible(game.civInfo.Cities.size()!=0);
|
||||
TechButton.setVisible(game.civInfo.cities.size()!=0);
|
||||
TechButton.clearListeners();
|
||||
TechButton.addListener(new ClickListener(){
|
||||
@Override
|
||||
@ -133,9 +132,9 @@ public class WorldScreen extends CameraStageBaseScreen {
|
||||
}
|
||||
});
|
||||
|
||||
if (game.civInfo.Tech.CurrentTechnology() == null) TechButton.setText("Choose a tech!");
|
||||
else TechButton.setText(game.civInfo.Tech.CurrentTechnology() + "\r\n"
|
||||
+ game.civInfo.TurnsToTech(game.civInfo.Tech.CurrentTechnology()) + " turns");
|
||||
if (game.civInfo.tech.CurrentTechnology() == null) TechButton.setText("Choose a tech!");
|
||||
else TechButton.setText(game.civInfo.tech.CurrentTechnology() + "\r\n"
|
||||
+ game.civInfo.turnsToTech(game.civInfo.tech.CurrentTechnology()) + " turns");
|
||||
|
||||
TechButton.setSize(TechButton.getPrefWidth(), TechButton.getPrefHeight());
|
||||
TechButton.setPosition(10, CivTable.getY() - TechButton.getHeight()-5);
|
||||
@ -161,7 +160,7 @@ public class WorldScreen extends CameraStageBaseScreen {
|
||||
|
||||
CivTable.add(new Label("Turns: " + game.civInfo.turns+"/400", skin));
|
||||
|
||||
CivStats nextTurnStats = game.civInfo.GetStatsForNextTurn();
|
||||
CivStats nextTurnStats = game.civInfo.getStatsForNextTurn();
|
||||
|
||||
CivTable.add(new Label("Gold: " + currentStats.Gold + "(" +(nextTurnStats.Gold>0?"+":"") + nextTurnStats.Gold+")", skin));
|
||||
|
||||
@ -181,13 +180,13 @@ public class WorldScreen extends CameraStageBaseScreen {
|
||||
nextTurnButton.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
if (game.civInfo.Tech.CurrentTechnology() == null
|
||||
&& game.civInfo.Cities.size()!=0) {
|
||||
if (game.civInfo.tech.CurrentTechnology() == null
|
||||
&& game.civInfo.cities.size()!=0) {
|
||||
game.setScreen(new TechPickerScreen(game));
|
||||
dispose();
|
||||
return;
|
||||
}
|
||||
game.civInfo.NextTurn();
|
||||
game.civInfo.nextTurn();
|
||||
GameSaver.SaveGame(game,"Autosave");
|
||||
update();
|
||||
}
|
||||
@ -213,12 +212,12 @@ public class WorldScreen extends CameraStageBaseScreen {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
selectedTile = tileInfo;
|
||||
if(unitTile != null && group.tileInfo.Unit == null ) {
|
||||
int distance = HexMath.GetDistance(unitTile.Position, group.tileInfo.Position);
|
||||
if (distance <= unitTile.Unit.CurrentMovement) {
|
||||
unitTile.Unit.CurrentMovement -= distance;
|
||||
group.tileInfo.Unit = unitTile.Unit;
|
||||
unitTile.Unit = null;
|
||||
if(unitTile != null && group.tileInfo.unit == null ) {
|
||||
int distance = HexMath.GetDistance(unitTile.position, group.tileInfo.position);
|
||||
if (distance <= unitTile.unit.CurrentMovement) {
|
||||
unitTile.unit.CurrentMovement -= distance;
|
||||
group.tileInfo.unit = unitTile.unit;
|
||||
unitTile.unit = null;
|
||||
unitTile = null;
|
||||
selectedTile = group.tileInfo;
|
||||
}
|
||||
@ -229,12 +228,12 @@ public class WorldScreen extends CameraStageBaseScreen {
|
||||
});
|
||||
|
||||
|
||||
Vector2 positionalVector = HexMath.Hex2WorldCoords(tileInfo.Position);
|
||||
Vector2 positionalVector = HexMath.Hex2WorldCoords(tileInfo.position);
|
||||
int groupSize = 50;
|
||||
group.setPosition(stage.getWidth() / 2 + positionalVector.x * 0.8f * groupSize,
|
||||
stage.getHeight() / 2 + positionalVector.y * 0.8f * groupSize);
|
||||
group.setSize(groupSize, groupSize);
|
||||
tileGroups.put(tileInfo.Position.toString(), group);
|
||||
tileGroups.put(tileInfo.position.toString(), group);
|
||||
allTiles.addActor(group);
|
||||
topX = Math.max(topX, group.getX() + groupSize);
|
||||
topY = Math.max(topY, group.getY() + groupSize);
|
||||
@ -279,7 +278,7 @@ public class WorldScreen extends CameraStageBaseScreen {
|
||||
private void updateTileTable() {
|
||||
if(selectedTile == null) return;
|
||||
TileTable.clearChildren();
|
||||
FullStats stats = selectedTile.GetTileStats();
|
||||
FullStats stats = selectedTile.getTileStats();
|
||||
TileTable.pad(20);
|
||||
TileTable.columnDefaults(0).padRight(10);
|
||||
|
||||
@ -305,11 +304,11 @@ public class WorldScreen extends CameraStageBaseScreen {
|
||||
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);
|
||||
moveUnitButton.getLabel().setFontScale(buttonScale);
|
||||
if(selectedTile.Unit.CurrentMovement == 0){
|
||||
if(selectedTile.unit.CurrentMovement == 0){
|
||||
moveUnitButton.setColor(Color.GRAY);
|
||||
moveUnitButton.setTouchable(Touchable.disabled);
|
||||
}
|
||||
@ -325,7 +324,7 @@ public class WorldScreen extends CameraStageBaseScreen {
|
||||
|
||||
// Set all tiles transparent except those in unit range
|
||||
for(TileGroup TG : tileGroups.linqValues()) TG.setColor(0,0,0,0.3f);
|
||||
for(Vector2 vector : HexMath.GetVectorsInDistance(unitTile.Position, unitTile.Unit.CurrentMovement)){
|
||||
for(Vector2 vector : HexMath.GetVectorsInDistance(unitTile.position, unitTile.unit.CurrentMovement)){
|
||||
if(tileGroups.containsKey(vector.toString()))
|
||||
tileGroups.get(vector.toString()).setColor(Color.WHITE);
|
||||
}
|
||||
@ -336,25 +335,25 @@ 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")){
|
||||
TextButton foundCityButton = new TextButton("Found City", skin);
|
||||
foundCityButton.getLabel().setFontScale(buttonScale);
|
||||
foundCityButton.addListener(new ClickListener(){
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
game.civInfo.addCity(selectedTile.Position);
|
||||
selectedTile.Unit = null; // Remove settler!
|
||||
game.civInfo.addCity(selectedTile.position);
|
||||
selectedTile.unit = null; // Remove settler!
|
||||
update();
|
||||
}
|
||||
});
|
||||
|
||||
if(game.civInfo.tileMap.getTilesInDistance(selectedTile.Position,2).any(new Predicate<TileInfo>() {
|
||||
if(game.civInfo.tileMap.getTilesInDistance(selectedTile.position,2).any(new Predicate<TileInfo>() {
|
||||
@Override
|
||||
public boolean evaluate(TileInfo arg0) {
|
||||
return arg0.IsCityCenter();
|
||||
return arg0.isCityCenter();
|
||||
}
|
||||
})){
|
||||
foundCityButton.setDisabled(true);
|
||||
foundCityButton.setTouchable(Touchable.disabled);
|
||||
foundCityButton.setColor(Color.GRAY);
|
||||
}
|
||||
|
||||
@ -363,9 +362,9 @@ public class WorldScreen extends CameraStageBaseScreen {
|
||||
.size(foundCityButton.getWidth() * buttonScale, foundCityButton.getHeight() * buttonScale);
|
||||
}
|
||||
|
||||
if(selectedTile.Unit.Name.equals("Worker")) {
|
||||
String improvementButtonText = selectedTile.ImprovementInProgress == null ?
|
||||
"Construct\r\nimprovement" : selectedTile.ImprovementInProgress+"\r\nin progress";
|
||||
if(selectedTile.unit.Name.equals("Worker")) {
|
||||
String improvementButtonText = selectedTile.improvementInProgress == null ?
|
||||
"Construct\r\nimprovement" : selectedTile.improvementInProgress +"\r\nin progress";
|
||||
TextButton improvementButton = new TextButton(improvementButtonText, skin);
|
||||
improvementButton.getLabel().setFontScale(buttonScale);
|
||||
improvementButton.addListener(new ClickListener() {
|
||||
@ -375,11 +374,11 @@ public class WorldScreen extends CameraStageBaseScreen {
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
if(selectedTile.Unit.CurrentMovement==0 ||
|
||||
if(selectedTile.unit.CurrentMovement==0 ||
|
||||
!GameBasics.TileImprovements.linqValues().any(new Predicate<TileImprovement>() {
|
||||
@Override
|
||||
public boolean evaluate(TileImprovement arg0) {
|
||||
return selectedTile.CanBuildImprovement(arg0);
|
||||
return selectedTile.canBuildImprovement(arg0);
|
||||
}
|
||||
})){
|
||||
improvementButton.setColor(Color.GRAY);
|
||||
@ -414,8 +413,8 @@ public class WorldScreen extends CameraStageBaseScreen {
|
||||
|
||||
// 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))
|
||||
if(game.civInfo.civName.equals(tileInfo.owner))
|
||||
for(Vector2 adjacentLocation : HexMath.GetAdjacentVectors(tileInfo.position))
|
||||
ViewableVectorStrings.add(adjacentLocation.toString());
|
||||
|
||||
// Tiles within 2 tiles of units
|
||||
@ -423,10 +422,10 @@ public class WorldScreen extends CameraStageBaseScreen {
|
||||
.where(new Predicate<TileInfo>() {
|
||||
@Override
|
||||
public boolean evaluate(TileInfo arg0) {
|
||||
return arg0.Unit!=null;
|
||||
return arg0.unit !=null;
|
||||
}
|
||||
}))
|
||||
for(Vector2 vector : HexMath.GetVectorsInDistance(tile.Position,2))
|
||||
for(Vector2 vector : HexMath.GetVectorsInDistance(tile.position,2))
|
||||
ViewableVectorStrings.add(vector.toString());
|
||||
|
||||
for(String string : ViewableVectorStrings)
|
||||
@ -442,7 +441,7 @@ public class WorldScreen extends CameraStageBaseScreen {
|
||||
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) ;
|
||||
}
|
||||
});
|
||||
float x = TG.getX()-stage.getWidth()/2;
|
||||
|
@ -1,13 +1,10 @@
|
||||
package com.unciv.game;
|
||||
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Container;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.Predicate;
|
||||
import com.unciv.civinfo.CityInfo;
|
||||
import com.unciv.civinfo.CivilizationInfo;
|
||||
import com.unciv.civinfo.TileInfo;
|
||||
|
||||
|
||||
@ -27,11 +24,11 @@ public class WorldTileGroup extends TileGroup {
|
||||
void update(WorldScreen worldScreen) {
|
||||
super.update();
|
||||
|
||||
if(tileInfo.WorkingCity != null && populationImage==null) addPopulationIcon();
|
||||
if(tileInfo.WorkingCity == null && populationImage!=null) removePopulationIcon();
|
||||
if(tileInfo.workingCity != null && populationImage==null) addPopulationIcon();
|
||||
if(tileInfo.workingCity == null && populationImage!=null) removePopulationIcon();
|
||||
|
||||
|
||||
if (tileInfo.Owner != null && hexagon == null) {
|
||||
if (tileInfo.owner != null && hexagon == null) {
|
||||
hexagon = ImageGetter.getImageByFilename("TerrainIcons/Hexagon.png");
|
||||
float imageScale = terrainImage.getWidth() * 1.3f / hexagon.getWidth();
|
||||
hexagon.setScale(imageScale);
|
||||
@ -42,8 +39,8 @@ public class WorldTileGroup extends TileGroup {
|
||||
}
|
||||
|
||||
|
||||
final CityInfo city = tileInfo.GetCity();
|
||||
if (tileInfo.IsCityCenter()) {
|
||||
final CityInfo city = tileInfo.getCity();
|
||||
if (tileInfo.isCityCenter()) {
|
||||
if (cityButton == null) {
|
||||
cityButton = new Container<TextButton>();
|
||||
cityButton.setActor(new TextButton("", worldScreen.skin));
|
||||
@ -54,7 +51,7 @@ public class WorldTileGroup extends TileGroup {
|
||||
cityButton.getActor().addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
game.civInfo.CurrentCity = game.civInfo.Cities.indexOf(city);
|
||||
game.civInfo.currentCity = game.civInfo.cities.indexOf(city);
|
||||
game.setScreen(new CityScreen(game));
|
||||
}
|
||||
});
|
||||
@ -63,7 +60,7 @@ public class WorldTileGroup extends TileGroup {
|
||||
setZIndex(getParent().getChildren().size);
|
||||
}
|
||||
|
||||
String cityButtonText = city.Name+" ("+city.cityPopulation.Population+")"
|
||||
String cityButtonText = city.name +" ("+city.cityPopulation.Population+")"
|
||||
+ "\r\n" + city.cityBuildings.CurrentBuilding + " in "
|
||||
+ city.cityBuildings.TurnsToBuilding(city.cityBuildings.CurrentBuilding);
|
||||
TextButton button = cityButton.getActor();
|
||||
|
@ -30,7 +30,7 @@ public class BuildingPickerScreen extends PickerScreen {
|
||||
rightSideButton.addListener(new ClickListener(){
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
game.civInfo.GetCurrentCity().cityBuildings.CurrentBuilding = selectedBuilding.Name;
|
||||
game.civInfo.getCurrentCity().cityBuildings.CurrentBuilding = selectedBuilding.Name;
|
||||
game.setScreen(new CityScreen(game));
|
||||
dispose();
|
||||
}
|
||||
@ -38,7 +38,7 @@ public class BuildingPickerScreen extends PickerScreen {
|
||||
rightSideButton.setTouchable(Touchable.disabled);
|
||||
rightSideButton.setColor(Color.GRAY);
|
||||
|
||||
CityBuildings cityBuildings = game.civInfo.GetCurrentCity().cityBuildings;
|
||||
CityBuildings cityBuildings = game.civInfo.getCurrentCity().cityBuildings;
|
||||
for(final Building building : GameBasics.Buildings.values()) {
|
||||
if(!cityBuildings.CanBuild(building)) continue;
|
||||
TextButton TB = new TextButton(building.Name+"\r\n"+cityBuildings.TurnsToBuilding(building.Name)+" turns", skin);
|
||||
|
@ -1,15 +1,12 @@
|
||||
package com.unciv.game.pickerscreens;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.Touchable;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.SplitPane;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.unciv.game.CameraStageBaseScreen;
|
||||
import com.unciv.game.UnCivGame;
|
||||
import com.unciv.models.gamebasics.GameBasics;
|
||||
import com.unciv.models.gamebasics.TileImprovement;
|
||||
@ -25,7 +22,7 @@ public class ImprovementPickerScreen extends PickerScreen {
|
||||
rightSideButton.addListener(new ClickListener(){
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
tileInfo.StartWorkingOnImprovement(SelectedImprovement);
|
||||
tileInfo.startWorkingOnImprovement(SelectedImprovement);
|
||||
game.setWorldScreen();
|
||||
dispose();
|
||||
}
|
||||
@ -34,8 +31,10 @@ public class ImprovementPickerScreen extends PickerScreen {
|
||||
rightSideButton.setTouchable(Touchable.disabled);
|
||||
rightSideButton.setColor(Color.GRAY);
|
||||
|
||||
VerticalGroup regularImprovements = new VerticalGroup();
|
||||
regularImprovements.space(10);
|
||||
for(final TileImprovement improvement : GameBasics.TileImprovements.values()) {
|
||||
if(!tileInfo.CanBuildImprovement(improvement) || improvement.Name.equals(tileInfo.Improvement)) continue;
|
||||
if(!tileInfo.canBuildImprovement(improvement) || improvement.Name.equals(tileInfo.improvement)) continue;
|
||||
TextButton TB = new TextButton(improvement.Name+"\r\n"+improvement.TurnsToBuild+" turns", skin);
|
||||
TB.addListener(new ClickListener(){
|
||||
@Override
|
||||
@ -47,8 +46,8 @@ public class ImprovementPickerScreen extends PickerScreen {
|
||||
descriptionLabel.setText(improvement.GetDescription());
|
||||
}
|
||||
});
|
||||
topTable.add(TB).pad(10);
|
||||
topTable.row();
|
||||
regularImprovements.addActor(TB);
|
||||
}
|
||||
topTable.add(regularImprovements);
|
||||
}
|
||||
}
|
@ -18,7 +18,7 @@ public class TechPickerScreen extends PickerScreen {
|
||||
|
||||
HashMap<String, TextButton> techNameToButton = new HashMap<String, TextButton>();
|
||||
Technology SelectedTech;
|
||||
com.unciv.civinfo.CivilizationTech civTech = game.civInfo.Tech;
|
||||
com.unciv.civinfo.CivilizationTech civTech = game.civInfo.tech;
|
||||
ArrayList<String> TechsToResearch = new ArrayList<String>(civTech.TechsToResearch);
|
||||
|
||||
public void SetButtonsInfo() {
|
||||
@ -48,7 +48,7 @@ public class TechPickerScreen extends PickerScreen {
|
||||
TB.setText(TB.getText() + " (" + TechsToResearch.indexOf(techName) + ")");
|
||||
}
|
||||
|
||||
if(!civTech.IsResearched(techName)) TB.setText(TB.getText() + "\r\n" + game.civInfo.TurnsToTech(techName) + " turns");
|
||||
if(!civTech.IsResearched(techName)) TB.setText(TB.getText() + "\r\n" + game.civInfo.turnsToTech(techName) + " turns");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import com.unciv.models.stats.NamedStats;
|
||||
import java.util.Collection;
|
||||
|
||||
public class Terrain extends NamedStats implements ICivilopedia {
|
||||
public String Type; // BaseTerrain or TerrainFeature
|
||||
public String Type; // baseTerrain or terrainFeature
|
||||
|
||||
/// <summary>
|
||||
/// For base terrain - comma-delimited 256 RGB values, e.g. "116,88,62"
|
||||
|
@ -34,7 +34,7 @@ public class TileImprovement extends NamedStats implements ICivilopedia {
|
||||
stringBuilder.append("\r\n"+statsString+" for "+ StringUtils.join(", ",statsToResourceNames.get(statsString)));
|
||||
}
|
||||
|
||||
if(TechRequired!=null) stringBuilder.append("\r\nTech required: "+TechRequired);
|
||||
if(TechRequired!=null) stringBuilder.append("\r\ntech required: "+TechRequired);
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
Reference in New Issue
Block a user