Added worker automation

Solved multiple small bugs
This commit is contained in:
Yair Morgenstern 2017-12-21 20:32:33 +02:00
parent effe3b55d0
commit 3f20e9b82e
20 changed files with 159 additions and 870 deletions

View file

@ -1,74 +0,0 @@
fileFormatVersion: 2
guid: 6a3167ea11aabe149b48ccf74d32522d
timeCreated: 1504549534
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,74 +0,0 @@
fileFormatVersion: 2
guid: 321bb463467bd11479afff2e8f1e8808
timeCreated: 1504555636
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,74 +0,0 @@
fileFormatVersion: 2
guid: 62dca01c03840c54f80ccef8f8b2842e
timeCreated: 1504549534
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,74 +0,0 @@
fileFormatVersion: 2
guid: c956af91abda1954db1d833fa9126aec
timeCreated: 1504549534
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,74 +0,0 @@
fileFormatVersion: 2
guid: cb19f36509e59214994bd6042a2af70f
timeCreated: 1504549534
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,74 +0,0 @@
fileFormatVersion: 2
guid: a5af63bfa8d4a824cb7de3cff9de012c
timeCreated: 1504549534
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,74 +0,0 @@
fileFormatVersion: 2
guid: 61f4b1c3f3eff644587595005c3ac16c
timeCreated: 1504549534
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,74 +0,0 @@
fileFormatVersion: 2
guid: bae63480532174c4fa7b6645e23912f4
timeCreated: 1504555636
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,74 +0,0 @@
fileFormatVersion: 2
guid: 47d0fd593edb3cc40a5b295d521d5f9b
timeCreated: 1504549534
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,74 +0,0 @@
fileFormatVersion: 2
guid: 18ee547cb3112564494e8da9c87efb9f
timeCreated: 1504555636
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,74 +0,0 @@
fileFormatVersion: 2
guid: c8fd49106bc29284ba9e26df5f5e6e0e
timeCreated: 1504549534
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 B

View file

@ -1,7 +1,89 @@
package com.unciv.civinfo;
import com.badlogic.gdx.utils.Predicate;
import com.unciv.models.LinqCollection;
import com.unciv.models.LinqHashMap;
import com.unciv.models.gamebasics.GameBasics;
public class MapUnit{
public String name;
public int maxMovement;
public float currentMovement;
}
public String action; // work, automation, fortifying, I dunno what.
public void doAction(TileInfo tile){
if(tile.improvementInProgress!=null) workOnImprovement(tile);
if ("automation".equals(action)) doAutomatedAction(tile);
}
private void workOnImprovement(TileInfo tile){
tile.turnsToImprovement -= 1;
if(tile.turnsToImprovement == 0)
{
if (tile.improvementInProgress.startsWith("Remove")) tile.terrainFeature = null;
else if(tile.improvementInProgress.equals("Road")) tile.roadStatus = RoadStatus.Road;
else if(tile.improvementInProgress.equals("Railroad")) tile.roadStatus = RoadStatus.Railroad;
else tile.improvement = tile.improvementInProgress;
String notification = tile.improvementInProgress+" has been completed";
if(tile.workingCity!=null) notification+=" for "+tile.getCity().name;
else {
for (int i = 1; i < 3; i++) {
LinqCollection<TileInfo> tilesWithCity = CivilizationInfo.current().tileMap.getTilesInDistance(tile.position, i).where(new Predicate<TileInfo>() {
@Override
public boolean evaluate(TileInfo arg0) {
return arg0.isCityCenter();
}
});
if(tilesWithCity.isEmpty()) continue;
notification+=" near "+tilesWithCity.get(0).workingCity;
break;
}
}
CivilizationInfo.current().notifications.add(notification+"!");
tile.improvementInProgress = null;
}
}
private void doAutomatedAction(TileInfo tile){
if(tile.owner!=null && tile.improvement==null // We'll be working this tile
&& (tile.workingCity!=null || tile.resource!=null || tile.improvementInProgress!=null)
&& tile.canBuildImprovement(GameBasics.TileImprovements.get(chooseImprovement(tile))))
{
if(tile.improvementInProgress==null) tile.startWorkingOnImprovement(chooseImprovement(tile)); // and stay put.
return;
}
// We'll search for a tile that needs our help in the reachable area
LinqHashMap<TileInfo, Float> distanceToTiles =
CivilizationInfo.current().tileMap.getUnitDistanceToTiles(tile.position,currentMovement);
TileInfo tileWithinDistance = new LinqCollection<TileInfo>(distanceToTiles.keySet()).first(new Predicate<TileInfo>() {
@Override
public boolean evaluate(TileInfo tile) {
return tile.owner!=null && tile.improvement==null && tile.unit==null
&& (tile.workingCity!=null || tile.resource!=null || tile.improvementInProgress!=null)
&& tile.canBuildImprovement(GameBasics.TileImprovements.get(chooseImprovement(tile)));
}
});
if(tileWithinDistance!=null){
tile.moveUnitToTile(tileWithinDistance,distanceToTiles.get(tileWithinDistance)); // go there
doAction(tileWithinDistance); // And do the same from there
}
// If not, then we don't know what to do. Oh well.
}
private String chooseImprovement(final TileInfo tile){
if(tile.improvementInProgress!=null) return tile.improvementInProgress;
if("Forest".equals(tile.terrainFeature)) return "Lumber mill";
if("Jungle".equals(tile.terrainFeature)) return "Trading post";
if("Marsh".equals(tile.terrainFeature)) return "Remove Marsh";
if(tile.resource!=null) return tile.getTileResource().improvement;
if(tile.baseTerrain.equals("Hill")) return "Mine";
if(tile.baseTerrain.equals("Grassland") || tile.baseTerrain.equals("Desert") || tile.baseTerrain.equals("Plains"))
return "Farm";
if(tile.baseTerrain.equals("Tundra")) return "Trading post";
return null;
}
}

View file

@ -100,7 +100,7 @@ public class TileInfo
public boolean canBuildImprovement(TileImprovement improvement)
{
if(improvement.name.equals(this.improvement)) return false;
if(isCityCenter() || improvement.name.equals(this.improvement)) 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;
@ -111,10 +111,10 @@ public class TileInfo
return hasViewableResource() && getTileResource().improvement.equals(improvement.name);
}
public void startWorkingOnImprovement(String improvementName,int turnsToBuild)
public void startWorkingOnImprovement(String improvementName)
{
improvementInProgress = improvementName;
turnsToImprovement = turnsToBuild;
turnsToImprovement = GameBasics.TileImprovements.get(improvementName).getTurnsToBuild();
}
public void stopWorkingOnImprovement()
@ -124,35 +124,13 @@ public class TileInfo
public void nextTurn()
{
if(unit !=null) unit.currentMovement = unit.maxMovement;
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 if(improvementInProgress.equals("Road")) roadStatus = RoadStatus.Road;
else if(improvementInProgress.equals("Railroad")) roadStatus = RoadStatus.Railroad;
else improvement = improvementInProgress;
if (!unit.name.equals("Worker"))
return;
String notification = improvementInProgress+" has been completed";
if(workingCity!=null) notification+=" for "+getCity().name;
else {
for (int i = 1; i < 3; i++) {
LinqCollection<TileInfo> tilesWithCity = CivilizationInfo.current().tileMap.getTilesInDistance(position, i).where(new Predicate<TileInfo>() {
@Override
public boolean evaluate(TileInfo arg0) {
return arg0.isCityCenter();
}
});
if(tilesWithCity.isEmpty()) continue;
notification+=" near "+tilesWithCity.get(0).workingCity;
break;
}
}
notification+="!";
CivilizationInfo.current().notifications.add(notification);
improvementInProgress = null;
unit.doAction(this);
}
}
@ -179,4 +157,12 @@ public class TileInfo
if (unit.name.equals("Worker") && improvementInProgress != null) return false;
return true;
}
public void moveUnitToTile(TileInfo otherTile, float movementDistance){
if(otherTile.unit!=null) return; // Fail.
unit.currentMovement -= movementDistance;
if(unit.currentMovement < 0.1) unit.currentMovement =0; // silly floats which are "almost zero"
otherTile.unit = unit;
unit = null;
}
}

View file

@ -84,7 +84,7 @@ public class TileMap{
return tiles;
}
public LinqHashMap<TileInfo,Float> getDistanceToTiles(Vector2 origin, float maximumMovement){
public LinqHashMap<TileInfo,Float> getUnitDistanceToTiles(Vector2 origin, float maximumMovement){
LinqHashMap<TileInfo,Float> distanceToTiles = new LinqHashMap<TileInfo, Float>();
distanceToTiles.put(get(origin), 0f);
LinqCollection<TileInfo> tilesToCheck = new LinqCollection<TileInfo>();

View file

@ -14,15 +14,19 @@ import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Predicate;
import com.unciv.civinfo.CityInfo;
import com.unciv.civinfo.CivilizationInfo;
import com.unciv.civinfo.IConstruction;
import com.unciv.civinfo.TileInfo;
import com.unciv.game.pickerscreens.ConstructionPickerScreen;
import com.unciv.game.pickerscreens.ImprovementPickerScreen;
import com.unciv.game.utils.CameraStageBaseScreen;
import com.unciv.game.utils.HexMath;
import com.unciv.game.utils.ImageGetter;
import com.unciv.models.gamebasics.Building;
import com.unciv.models.gamebasics.GameBasics;
import com.unciv.models.gamebasics.TileImprovement;
import com.unciv.models.stats.FullStats;
import java.util.ArrayList;
@ -370,6 +374,32 @@ public class CityScreen extends CameraStageBaseScreen {
TileTable.row();
}
// TextButton actionButton = new TextButton("Request improvement", skin);
// actionButton.getLabel().setFontScale(buttonScale);
// actionButton.addListener(action);
// if (selectedTile.unit.currentMovement == 0 || !canAct) {
// actionButton.setColor(Color.GRAY);
// actionButton.setTouchable(Touchable.disabled);
// }
//
// tileTable.row();
// tileTable.add(actionButton).colspan(2)
// .size(actionButton.getWidth() * buttonScale, actionButton.getHeight() * buttonScale);
//
// 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(game, selectedTile));}
// } );
TileTable.pack();
TileTable.setPosition(stage.getWidth()-10- TileTable.getWidth(), 10);

View file

@ -305,13 +305,9 @@ public class WorldScreen extends CameraStageBaseScreen {
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.getDistanceToTiles(unitTile.position,unitTile.unit.currentMovement);
LinqHashMap<TileInfo, Float> distanceToTiles = game.civInfo.tileMap.getUnitDistanceToTiles(unitTile.position,unitTile.unit.currentMovement);
if(distanceToTiles.containsKey(selectedTile)) {
unitTile.unit.currentMovement -= distanceToTiles.get(selectedTile);
//unitTile.unit.currentMovement = round(unitTile.unit.currentMovement,3);
if(unitTile.unit.currentMovement < 0.1) unitTile.unit.currentMovement =0; // silly floats which are "almost zero"
group.tileInfo.unit = unitTile.unit;
unitTile.unit = null;
unitTile.moveUnitToTile(group.tileInfo,distanceToTiles.get(selectedTile));
unitTile = null;
selectedTile = group.tileInfo;
}
@ -420,7 +416,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(TileInfo tile : game.civInfo.tileMap.getDistanceToTiles(unitTile.position,unitTile.unit.currentMovement).keySet()){
for(TileInfo tile : game.civInfo.tileMap.getUnitDistanceToTiles(unitTile.position,unitTile.unit.currentMovement).keySet()){
tileGroups.get(tile.position.toString()).setColor(Color.WHITE);
}
@ -465,6 +461,16 @@ public class WorldScreen extends CameraStageBaseScreen {
@Override
public void clicked(InputEvent event, float x, float y) {game.setScreen(new ImprovementPickerScreen(game, 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))
selectedTile.unit.action = null;
else selectedTile.unit.action = "automation";
update();
}
});
}
if(selectedTile.unit.name.equals("Great Scientist")){
@ -510,14 +516,14 @@ public class WorldScreen extends CameraStageBaseScreen {
}
if(selectedTile.unit.name.equals("Great Engineer")){
final CityConstructions cityConstructions = selectedTile.getCity().cityConstructions;
addUnitAction(tileTable, "Hurry Wonder",selectedTile.isCityCenter() &&
cityConstructions.getCurrentConstruction() instanceof Building &&
((Building)cityConstructions.getCurrentConstruction()).isWonder,
selectedTile.getCity().cityConstructions.getCurrentConstruction() instanceof Building &&
((Building)selectedTile.getCity().cityConstructions.getCurrentConstruction()).isWonder,
new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
cityConstructions.addConstruction(300 + (30 * selectedTile.getCity().population)); //http://civilization.wikia.com/wiki/Great_engineer_(Civ5)
selectedTile.getCity().cityConstructions.addConstruction(300 + (30 * selectedTile.getCity().population)); //http://civilization.wikia.com/wiki/Great_engineer_(Civ5)
selectedTile.unit=null; // destroy!
update();
}
@ -533,7 +539,6 @@ public class WorldScreen extends CameraStageBaseScreen {
});
}
if(selectedTile.unit.name.equals("Great Merchant")){
final CityConstructions cityConstructions = selectedTile.getCity().cityConstructions;
addUnitAction(tileTable, "Conduct Trade Mission",true,
new ClickListener(){
@Override

View file

@ -6,25 +6,22 @@ import com.badlogic.gdx.scenes.scene2d.Touchable;
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.civinfo.CivilizationInfo;
import com.unciv.civinfo.TileInfo;
import com.unciv.game.UnCivGame;
import com.unciv.models.gamebasics.GameBasics;
import com.unciv.models.gamebasics.TileImprovement;
public class ImprovementPickerScreen extends PickerScreen {
String SelectedImprovement;
int TurnsToImprovement;
private String SelectedImprovement;
public ImprovementPickerScreen(final UnCivGame game, final TileInfo tileInfo) {
super(game);
rightSideButton.setText("Pick improvement");
rightSideButton.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
tileInfo.startWorkingOnImprovement(SelectedImprovement, TurnsToImprovement);
tileInfo.startWorkingOnImprovement(SelectedImprovement);
game.setWorldScreen();
dispose();
}
@ -37,15 +34,12 @@ public class ImprovementPickerScreen extends PickerScreen {
regularImprovements.space(10);
for(final TileImprovement improvement : GameBasics.TileImprovements.values()) {
if(!tileInfo.canBuildImprovement(improvement) || improvement.name.equals(tileInfo.improvement)) continue;
int turnsToBuild = improvement.turnsToBuild;
if(CivilizationInfo.current().getBuildingUniques().contains("WorkerConstruction")) turnsToBuild= (int) Math.round(0.75*turnsToBuild);
TextButton TB = new TextButton(improvement.name +"\r\n"+turnsToBuild +" turns", skin);
final int finalTurnsToBuild = turnsToBuild;
TextButton TB = new TextButton(improvement.name +"\r\n"+improvement.getTurnsToBuild()+" turns", skin);
TB.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
SelectedImprovement = improvement.name;
TurnsToImprovement = finalTurnsToBuild;
rightSideButton.setTouchable(Touchable.enabled);
rightSideButton.setText(improvement.name);
rightSideButton.setColor(Color.WHITE);

View file

@ -132,7 +132,7 @@ public class TechPickerScreen extends PickerScreen {
CheckPrerequisites.add(tech.name);
while (!CheckPrerequisites.isEmpty()) {
String techNameToCheck = CheckPrerequisites.pop();
if (civTech.isResearched(techNameToCheck))
if (civTech.isResearched(techNameToCheck) || Prerequisites.contains(techNameToCheck))
continue; //no need to add or check prerequisites
Technology techToCheck = GameBasics.Technologies.get(techNameToCheck);
for (String str : techToCheck.prerequisites)

View file

@ -1,5 +1,6 @@
package com.unciv.models.gamebasics;
import com.unciv.civinfo.CivilizationInfo;
import com.unciv.models.stats.FullStats;
import com.unciv.models.stats.NamedStats;
@ -14,7 +15,12 @@ public class TileImprovement extends NamedStats implements ICivilopedia {
public String improvingTech;
public FullStats improvingTechStats;
public int turnsToBuild;
private int turnsToBuild; // This is the base cost.
public int getTurnsToBuild(){
int realTurnsToBuild = turnsToBuild;
if(CivilizationInfo.current().getBuildingUniques().contains("WorkerConstruction")) realTurnsToBuild = (int) Math.round(0.75*turnsToBuild);
return realTurnsToBuild;
}
@Override
public String getDescription() {