Google play-able

Units with no turns left are now grayed out
Added culture pool to cities and tiles being added to cities when pool fills
Changed tile icon order and placing of resource icon
This commit is contained in:
Yair Morgenstern 2017-11-25 21:56:04 +02:00
parent a6ae95946c
commit d125c6ba3e
19 changed files with 123 additions and 55 deletions

View File

@ -6,7 +6,7 @@
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:icon="@drawable/uncivicon"
android:label="@string/app_name"
android:theme="@style/GdxTheme" >
<activity

BIN
android/android-release.apk Normal file

Binary file not shown.

View File

@ -18,10 +18,10 @@ android {
exclude 'META-INF/robovm/ios/robovm.xml'
}
defaultConfig {
applicationId "com.mygdx.game"
applicationId "com.unciv.game"
minSdkVersion 9
targetSdkVersion 25
versionCode 1
versionCode 3
versionName "1.0"
}
buildTypes {
@ -79,7 +79,7 @@ task run(type: Exec) {
}
def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.mygdx.game/AndroidLauncher'
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.unciv.game/AndroidLauncher'
}
// sets up the Android Eclipse project, using the old Ant based build.

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -20,9 +20,9 @@ allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
version = '1.0.1'
ext {
appName = "my-gdx-game"
appName = "unciv-game"
gdxVersion = '1.9.6'
roboVMVersion = '2.3.1'
box2DLightsVersion = '1.4'

View File

@ -76,7 +76,7 @@ public class CityBuildings
if(IsBuilt(building.Name)) return false;
// if (building.Name.equals("Worker") || building.Name.equals("Settler")) return false;
if(building.ResourceRequired) {
boolean containsResourceWithImprovement = GetCity().GetCityTiles()
boolean containsResourceWithImprovement = GetCity().getCityTiles()
.any(new Predicate<TileInfo>() {
@Override
public boolean evaluate(TileInfo tile) {

View File

@ -5,9 +5,12 @@ import com.badlogic.gdx.utils.Predicate;
import com.unciv.game.HexMath;
import com.unciv.game.UnCivGame;
import com.unciv.models.LinqCollection;
import com.unciv.models.gamebasics.ResourceType;
import com.unciv.models.gamebasics.TileResource;
import com.unciv.models.stats.FullStats;
import java.util.ArrayList;
import java.util.Comparator;
public class CityInfo {
public final Vector2 cityLocation;
@ -15,10 +18,13 @@ public class CityInfo {
public CityBuildings cityBuildings;
public CityPopulation cityPopulation;
public int cultureStored;
private int tilesClaimed;
public LinqCollection<Vector2> CityTileLocations = new LinqCollection<Vector2>();
public LinqCollection<TileInfo> GetCityTiles(){
public LinqCollection<TileInfo> getCityTiles(){
return CityTileLocations.select(new com.unciv.models.LinqCollection.Func<Vector2, TileInfo>() {
@Override
public TileInfo GetBy(Vector2 arg0) {
@ -27,13 +33,23 @@ public class CityInfo {
});
}
String[] CityNames = new String[]{"Assur", "Ninveh", "Nimrud", "Kar-Tukuli-Ninurta", "Dur-Sharrukin"};
private String[] CityNames = new String[]{"Assur", "Ninveh", "Nimrud", "Kar-Tukuli-Ninurta", "Dur-Sharrukin"};
public CityInfo(){
cityLocation = Vector2.Zero;
} // for json parsing, we need to have a default constructor
public CityInfo(CivilizationInfo civInfo, Vector2 cityLocation) {
public int getCultureToNextTile(){
// This one has conflicting sources -
// http://civilization.wikia.com/wiki/Mathematics_of_Civilization_V says it's 20+(10(t-1))^1.1
// https://www.reddit.com/r/civ/comments/58rxkk/how_in_gods_name_do_borders_expand_in_civ_vi/ has it
// (per game XML files) at 6*(t+0.4813)^1.3
// The second seems to be more based, so I'll go with that
double a = 6*Math.pow(tilesClaimed+1.4813,1.3);
return (int)Math.round(a);
}
CityInfo(CivilizationInfo civInfo, Vector2 cityLocation) {
Name = CityNames[civInfo.Cities.size()];
this.cityLocation = cityLocation;
cityBuildings = new CityBuildings(this);
@ -45,23 +61,23 @@ public class CityInfo {
CityTileLocations.add(vector);
}
AutoAssignWorker();
autoAssignWorker();
civInfo.Cities.add(this);
}
public ArrayList<String> GetLuxuryResources() {
ArrayList<String> getLuxuryResources() {
ArrayList<String> LuxuryResources = new ArrayList<String>();
for (TileInfo tileInfo : GetCityTiles()) {
for (TileInfo tileInfo : getCityTiles()) {
com.unciv.models.gamebasics.TileResource resource = tileInfo.GetTileResource();
if (resource != null && resource.ResourceType.equals("Luxury") && resource.Improvement.equals(tileInfo.Improvement))
if (resource != null && resource.ResourceType == ResourceType.Luxury && resource.Improvement.equals(tileInfo.Improvement))
LuxuryResources.add(tileInfo.Resource);
}
return LuxuryResources;
}
public int GetWorkingPopulation() {
return GetCityTiles().count(new Predicate<TileInfo>() {
private int getWorkingPopulation() {
return getCityTiles().count(new Predicate<TileInfo>() {
@Override
public boolean evaluate(TileInfo arg0) {
return arg0.IsWorked;
@ -69,12 +85,12 @@ public class CityInfo {
});
}
public int GetFreePopulation() {
return cityPopulation.Population - GetWorkingPopulation();
public int getFreePopulation() {
return cityPopulation.Population - getWorkingPopulation();
}
public boolean HasNonWorkingPopulation() {
return GetFreePopulation() > 0;
public boolean hasNonWorkingPopulation() {
return getFreePopulation() > 0;
}
public FullStats getCityStats() {
@ -85,11 +101,11 @@ public class CityInfo {
stats.Science += cityPopulation.Population;
// Working ppl
for (TileInfo cell : GetCityTiles()) {
for (TileInfo cell : getCityTiles()) {
if (cell.IsWorked || cell.IsCityCenter()) stats.add(cell.GetTileStats());
}
//idle ppl
stats.Production += GetFreePopulation();
stats.Production += getFreePopulation();
stats.Food -= cityPopulation.Population * 2;
stats.add(cityBuildings.GetStats());
@ -97,27 +113,60 @@ public class CityInfo {
return stats;
}
public void NextTurn() {
void nextTurn() {
FullStats stats = getCityStats();
if (cityBuildings.CurrentBuilding.equals(cityBuildings.Settler) && stats.Food > 0) {
if (cityBuildings.CurrentBuilding.equals(CityBuildings.Settler) && stats.Food > 0) {
stats.Production += stats.Food;
stats.Food = 0;
}
if (cityPopulation.NextTurn(stats.Food)) AutoAssignWorker();
if (cityPopulation.NextTurn(stats.Food)) autoAssignWorker();
cityBuildings.NextTurn(stats.Production);
for (TileInfo tileInfo : GetCityTiles()) {
for (TileInfo tileInfo : getCityTiles()) {
tileInfo.NextTurn();
}
cultureStored+=stats.Culture;
if(cultureStored>=getCultureToNextTile()){
addNewTile();
}
}
public void AutoAssignWorker() {
private void addNewTile(){
cultureStored -= getCultureToNextTile();
tilesClaimed++;
LinqCollection<Vector2> possibleNewTileVectors = new LinqCollection<Vector2>();
for (TileInfo tile : getCityTiles())
for (Vector2 vector : HexMath.GetAdjacentVectors(tile.Position))
if(!CityTileLocations.contains(vector) && !possibleNewTileVectors.contains(vector))
possibleNewTileVectors.add(vector);
LinqCollection<TileInfo> possibleNewTiles = new LinqCollection<TileInfo>();
TileMap tileMap = UnCivGame.Current.civInfo.tileMap;
for (Vector2 vector : possibleNewTileVectors)
if(tileMap.contains(vector) && tileMap.get(vector).GetCity()==null)
possibleNewTiles.add(tileMap.get(vector));
TileInfo TileChosen=null;
double TileChosenRank=0;
for(TileInfo tile : possibleNewTiles){
double rank = rankTile(tile);
if(rank>TileChosenRank){
TileChosenRank = rank;
TileChosen = tile;
}
}
CityTileLocations.add(TileChosen.Position);
}
private void autoAssignWorker() {
double maxValue = 0;
TileInfo toWork = null;
for (TileInfo tileInfo : GetCityTiles()) {
for (TileInfo tileInfo : getCityTiles()) {
if (tileInfo.IsWorked || tileInfo.IsCityCenter()) continue;
FullStats stats = tileInfo.GetTileStats();
@ -129,4 +178,17 @@ public class CityInfo {
}
toWork.IsWorked = true;
}
private double rankTile(TileInfo tile){
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
rank+=stats.Gold/2;
rank+=stats.Production;
rank+=stats.Science;
rank+=stats.Culture;
if(tile.Improvement==null) rank+=0.5; // Improvement potential!
return rank;
}
}

View File

@ -1,7 +1,6 @@
package com.unciv.civinfo;
import com.badlogic.gdx.math.Vector2;
import com.unciv.game.pickerscreens.GameSaver;
import com.unciv.models.LinqCollection;
import com.unciv.models.gamebasics.GameBasics;
import com.unciv.models.stats.CivStats;
@ -47,7 +46,7 @@ public class CivilizationInfo {
civStats.add(nextTurnStats);
if(Cities.size() > 0) Tech.NextTurn(nextTurnStats.Science);
for (CityInfo city : Cities.as(CityInfo.class)) city.NextTurn();
for (CityInfo city : Cities.as(CityInfo.class)) city.nextTurn();
for(TileInfo tile : tileMap.values()) if(tile.Unit!=null) tile.Unit.CurrentMovement = tile.Unit.MaxMovement;
@ -61,7 +60,7 @@ public class CivilizationInfo {
HashSet<String> LuxuryResources = new HashSet<String>();
for (CityInfo city : Cities) {
statsForTurn.add(city.getCityStats());
LuxuryResources.addAll(city.GetLuxuryResources());
LuxuryResources.addAll(city.getLuxuryResources());
}
statsForTurn.Happiness += LuxuryResources.size() * 5; // 5 happiness for each unique luxury in civ

View File

@ -7,6 +7,7 @@ import com.unciv.game.HexMath;
import com.unciv.models.LinqCollection;
import com.unciv.models.LinqHashMap;
import com.unciv.models.gamebasics.GameBasics;
import com.unciv.models.gamebasics.ResourceType;
import com.unciv.models.gamebasics.Terrain;
import com.unciv.models.gamebasics.TileResource;
@ -58,11 +59,11 @@ public class TileMap{
TileResource resource = null;
if (Math.random() < 1 / 5f) {
resource = GetRandomResource(TileResources, "Bonus");
resource = GetRandomResource(TileResources, ResourceType.Bonus);
} else if (Math.random() < 1 / 7f) {
resource = GetRandomResource(TileResources, "Strategic");
resource = GetRandomResource(TileResources, ResourceType.Strategic);
} else if (Math.random() < 1 / 10f) {
resource = GetRandomResource(TileResources, "Luxury");
resource = GetRandomResource(TileResources, ResourceType.Luxury);
}
if (resource != null) tileInfo.Resource = resource.Name;
@ -77,7 +78,7 @@ public class TileMap{
public LinqCollection<TileInfo> values(){return tiles.linqValues();}
public TileResource GetRandomResource(LinqCollection<TileResource> resources, final String resourceType) {
public TileResource GetRandomResource(LinqCollection<TileResource> resources, final ResourceType resourceType) {
return resources.where(new Predicate<TileResource>() {
@Override
public boolean evaluate(TileResource arg0) {

View File

@ -8,7 +8,6 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
@ -135,13 +134,13 @@ public class CityScreen extends CameraStageBaseScreen {
}
});
if(!cityInfo.GetCityTiles().contains(tileInfo)) group.setColor(0,0,0,0.3f);
if(!cityInfo.getCityTiles().contains(tileInfo)) group.setColor(0,0,0,0.3f);
else if(!tileInfo.IsCityCenter()) {
group.addPopulationIcon();
group.populationImage.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (cityInfo.GetFreePopulation() > 0 || tileInfo.IsWorked)
if (cityInfo.getFreePopulation() > 0 || tileInfo.IsWorked)
tileInfo.IsWorked = !tileInfo.IsWorked;
updateCityTable();
}
@ -204,8 +203,8 @@ public class CityScreen extends CameraStageBaseScreen {
CityStatsValues.put("Food",stats.Food+" ("+cityInfo.cityPopulation.FoodStored+"/"+cityInfo.cityPopulation.FoodToNextPopulation()+")");
CityStatsValues.put("Gold",stats.Gold+"");
CityStatsValues.put("Science",stats.Science+"");
CityStatsValues.put("Culture",stats.Culture+"");
CityStatsValues.put("Population",cityInfo.GetFreePopulation()+"/"+cityInfo.cityPopulation.Population);
CityStatsValues.put("Culture",stats.Culture+" ("+cityInfo.cultureStored+"/"+cityInfo.getCultureToNextTile()+")");
CityStatsValues.put("Population",cityInfo.getFreePopulation()+"/"+cityInfo.cityPopulation.Population);
for(String key : CityStatsValues.keySet()){
CityStatsTable.add(ImageGetter.getStatIcon(key)).align(Align.right);

View File

@ -28,10 +28,10 @@ public class TileGroup extends Group {
addActor(terrainImage);
}
void addPopulationIcon(){
populationImage = ImageGetter.getStatIcon("Population");
populationImage.setAlign(Align.bottomRight);
populationImage.setX(terrainImage.getWidth()-populationImage.getWidth());
populationImage.moveBy(0, terrainImage.getHeight()-populationImage.getHeight()); // top left
addActor(populationImage);
}
@ -46,8 +46,8 @@ public class TileGroup extends Group {
if (tileInfo.HasViewableResource() && resourceImage == null) { // Need to add the resource image!
String fileName = "ResourceIcons/" + tileInfo.Resource + "_(Civ5).png";
Image image = ImageGetter.getImageByFilename(fileName);
image.setScale(0.5f);
image.setOrigin(Align.topRight);
image.setSize(20,20);
image.moveBy(terrainImage.getWidth()-image.getWidth(), 0); // bottom right
resourceImage = image;
addActor(image);
}
@ -55,7 +55,7 @@ public class TileGroup extends Group {
if (tileInfo.Unit != null && unitImage == null) {
unitImage = ImageGetter.getImageByFilename("StatIcons/" + tileInfo.Unit.Name + "_(Civ5).png");
addActor(unitImage);
unitImage.setSize(20, 20);
unitImage.setSize(20, 20); // not moved - is at bottom left
}
if (tileInfo.Unit == null && unitImage != null) {
@ -63,12 +63,18 @@ public class TileGroup extends Group {
unitImage = null;
}
if(unitImage!=null){
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");
addActor(improvementImage);
improvementImage.setSize(20, 20);
improvementImage.moveBy(0, terrainImage.getHeight() - improvementImage.getHeight());
improvementImage.moveBy(terrainImage.getWidth()-improvementImage.getWidth(),
terrainImage.getHeight() - improvementImage.getHeight()); // top right
}
if(populationImage!=null){

View File

@ -55,7 +55,7 @@ public class WorldScreen extends CameraStageBaseScreen {
stage.addActor(TileTable);
Drawable tileTableBackground = new TextureRegionDrawable(new TextureRegion(new Texture("skin/tileTableBackground.png")))
.tint(new Color(0x0040804f));
.tint(new Color(0x004085bf));
tileTableBackground.setMinHeight(0);
tileTableBackground.setMinWidth(0);
TileTable.setBackground(tileTableBackground);
@ -63,7 +63,7 @@ public class WorldScreen extends CameraStageBaseScreen {
TextureRegionDrawable civBackground = new TextureRegionDrawable(new TextureRegion(new Texture("skin/civTableBackground.png")));
// civBackground.tint(new Color(0x0040804f));
CivTable.setBackground(civBackground.tint(new Color(0x0040804f)));
CivTable.setBackground(civBackground.tint(new Color(0x004085bf)));
stage.addActor(CivTable);
@ -267,6 +267,7 @@ public class WorldScreen extends CameraStageBaseScreen {
lastScale = scrollPane.getScaleX();
}
float scale = (float) Math.sqrt(distance / initialDistance) * lastScale;
if(scale<1) return;
scrollPane.setScale(scale);
game.settings.tilesZoom = scale;
}
@ -375,7 +376,8 @@ public class WorldScreen extends CameraStageBaseScreen {
dispose();
}
});
if(!GameBasics.TileImprovements.linqValues().any(new Predicate<TileImprovement>() {
if(selectedTile.Unit.CurrentMovement==0 ||
!GameBasics.TileImprovements.linqValues().any(new Predicate<TileImprovement>() {
@Override
public boolean evaluate(TileImprovement arg0) {
return selectedTile.CanBuildImprovement(arg0);

View File

@ -1,8 +1,7 @@
package com.unciv.models.gamebasics;
/**
* Created by LENOVO on 11/25/2017.
*/
class ResourceType {
public enum ResourceType{
Luxury,
Strategic,
Bonus
}

View File

@ -6,7 +6,7 @@ import com.unciv.models.stats.FullStats;
import java.util.Collection;
public class TileResource extends NamedStats implements ICivilopedia {
public String ResourceType;
public ResourceType ResourceType;
public Collection<String> TerrainsCanBeFoundOn;
public String Improvement;
public FullStats ImprovementStats;

BIN
keystore.jks Normal file

Binary file not shown.