Added Triremes and water combat!

This commit is contained in:
Yair Morgenstern 2018-10-15 22:57:33 +03:00
parent 8912984e74
commit c1e070018f
10 changed files with 311 additions and 289 deletions

View file

@ -17,6 +17,7 @@ All the following are from [the Noun Project](https://thenounproject.com) licenc
* [Bow And Arrow](https://thenounproject.com/search/?q=Bow%20and%20Arrow&i=338261) By Viktor Ostrovsky for Archer
* [Bow](https://thenounproject.com/search/?q=bow&i=101736) By Arthur Shlain for Bowman
* [Fishing Vessel](https://thenounproject.com/term/fishing-vessel/23815/) By Luis Prado for Work Boats
* [Greek Trireme](https://thenounproject.com/search/?q=ancient%20boat&i=1626303) By Zachary McCune for Trireme
* [Chariot](https://thenounproject.com/search/?q=Chariot&i=1189930) By Andrew Doane for Chariot Archer
* [Spear](https://thenounproject.com/search/?q=Spear&i=11432) By Stephen Copinger for Spearman

View file

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 897 KiB

After

Width:  |  Height:  |  Size: 897 KiB

View file

@ -70,6 +70,17 @@
movement:4,
cost: 30,
requiredTech:"Sailing",
uniques:["Cannot enter ocean tiles until Astronomy"]
hurryCostModifier:20
},
{
name:"Trireme",
unitType:"WaterMelee",
movement:4,
strength:10,
cost: 45,
requiredTech:"Sailing",
uniques:["Cannot enter ocean tiles"]
hurryCostModifier:20
},
{

View file

@ -8,7 +8,6 @@ import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.tile.TerrainType
import com.unciv.models.gamebasics.unit.BaseUnit
import com.unciv.models.gamebasics.unit.UnitType
import com.unciv.ui.utils.getRandom
import java.text.DecimalFormat
import java.util.*
@ -98,17 +97,26 @@ class MapUnit {
return "$name - $owner"
}
/**
* Designates whether we can walk to the tile - without attacking
*/
fun canMoveTo(tile: TileInfo): Boolean {
fun canPassThrough(tile: TileInfo):Boolean{
val tileOwner = tile.getOwner()
if(tile.getBaseTerrain().type==TerrainType.Water && baseUnit.unitType.isLandUnit())
return false
if(tile.getBaseTerrain().type==TerrainType.Land && baseUnit.unitType.isWaterUnit())
return false
if(tile.baseTerrain=="Ocean" && baseUnit.uniques.contains("Cannot enter ocean tiles until Astronomy")
&& !civInfo.tech.isResearched("Astronomy"))
return false
if(tile.baseTerrain=="Ocean" && baseUnit.uniques.contains("Cannot enter ocean tiles")) return false
if(tileOwner!=null && tileOwner.civName!=owner
&& (tile.isCityCenter() || !civInfo.canEnterTiles(tileOwner))) return false
return true
}
/**
* Designates whether we can walk to the tile - without attacking
*/
fun canMoveTo(tile: TileInfo): Boolean {
if(!canPassThrough(tile)) return false
if (baseUnit().unitType.isCivilian())
return tile.civilianUnit==null && (tile.militaryUnit==null || tile.militaryUnit!!.owner==owner)

View file

@ -1,7 +1,6 @@
package com.unciv.logic.map
import com.badlogic.gdx.math.Vector2
import com.unciv.models.gamebasics.tile.TerrainType
class UnitMovementAlgorithms(val unit:MapUnit) {
val tileMap = unit.getTile().tileMap
@ -24,6 +23,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
return to.lastTerrain.movementCost.toFloat() // no road
}
fun getDistanceToTilesWithinTurn(origin: Vector2, unitMovement: Float): HashMap<TileInfo, Float> {
if(unitMovement==0f) return hashMapOf()
val distanceToTiles = LinkedHashMap<TileInfo, Float>()
@ -36,13 +36,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
for (tileToCheck in tilesToCheck)
for (neighbor in tileToCheck.neighbors) {
var totalDistanceToTile:Float
val neighborOwner = neighbor.getOwner()
val isOwnedByEnemy = neighborOwner!=null && neighborOwner!=unit.civInfo
if ( (unit.baseUnit.unitType.isLandUnit() && neighbor.getBaseTerrain().type== TerrainType.Water)
|| (isOwnedByEnemy && neighbor.isCityCenter())// Enemy city,
|| (neighbor.getUnits().isNotEmpty() && neighbor.getUnits().first().civInfo!=unit.civInfo) // Enemy unit
|| (isOwnedByEnemy && !unit.civInfo.canEnterTiles(neighborOwner!!)) // enemyTile
)
if (!unit.canPassThrough(neighbor))
totalDistanceToTile = unitMovement // Can't go here.
// The reason that we don't just "return" is so that when calculating how to reach an enemy,
// You need to assume his tile is reachable, otherwise all movement algs on reaching enemy

View file

@ -24,7 +24,7 @@ class BaseUnit : INamed, IConstruction, ICivilopedia {
internal var unbuildable: Boolean = false // for special units like great people
var requiredTech:String? = null
var requiredResource:String? = null
var uniques:HashSet<String>?=null
var uniques =HashSet<String>()
var obsoleteTech:String?=null
var upgradesTo:String? = null
var replaces:String?=null

View file

@ -8,6 +8,7 @@ enum class UnitType{
Scout,
Mounted,
WaterCivilian,
WaterMelee,
Siege;
fun isMelee(): Boolean {