mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 06:51:30 -04:00
Added Triremes and water combat!
This commit is contained in:
parent
8912984e74
commit
c1e070018f
@ -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 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
|
* [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
|
* [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
|
* [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
|
* [Spear](https://thenounproject.com/search/?q=Spear&i=11432) By Stephen Copinger for Spearman
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
BIN
android/Images/UnitIcons/Trireme.png
Normal file
BIN
android/Images/UnitIcons/Trireme.png
Normal file
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 |
@ -70,6 +70,17 @@
|
|||||||
movement:4,
|
movement:4,
|
||||||
cost: 30,
|
cost: 30,
|
||||||
requiredTech:"Sailing",
|
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
|
hurryCostModifier:20
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,6 @@ import com.unciv.logic.civilization.CivilizationInfo
|
|||||||
import com.unciv.models.gamebasics.GameBasics
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
import com.unciv.models.gamebasics.tile.TerrainType
|
import com.unciv.models.gamebasics.tile.TerrainType
|
||||||
import com.unciv.models.gamebasics.unit.BaseUnit
|
import com.unciv.models.gamebasics.unit.BaseUnit
|
||||||
import com.unciv.models.gamebasics.unit.UnitType
|
|
||||||
import com.unciv.ui.utils.getRandom
|
import com.unciv.ui.utils.getRandom
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@ -98,17 +97,26 @@ class MapUnit {
|
|||||||
return "$name - $owner"
|
return "$name - $owner"
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
fun canPassThrough(tile: TileInfo):Boolean{
|
||||||
* Designates whether we can walk to the tile - without attacking
|
|
||||||
*/
|
|
||||||
fun canMoveTo(tile: TileInfo): Boolean {
|
|
||||||
val tileOwner = tile.getOwner()
|
val tileOwner = tile.getOwner()
|
||||||
if(tile.getBaseTerrain().type==TerrainType.Water && baseUnit.unitType.isLandUnit())
|
if(tile.getBaseTerrain().type==TerrainType.Water && baseUnit.unitType.isLandUnit())
|
||||||
return false
|
return false
|
||||||
if(tile.getBaseTerrain().type==TerrainType.Land && baseUnit.unitType.isWaterUnit())
|
if(tile.getBaseTerrain().type==TerrainType.Land && baseUnit.unitType.isWaterUnit())
|
||||||
return false
|
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
|
if(tileOwner!=null && tileOwner.civName!=owner
|
||||||
&& (tile.isCityCenter() || !civInfo.canEnterTiles(tileOwner))) return false
|
&& (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())
|
if (baseUnit().unitType.isCivilian())
|
||||||
return tile.civilianUnit==null && (tile.militaryUnit==null || tile.militaryUnit!!.owner==owner)
|
return tile.civilianUnit==null && (tile.militaryUnit==null || tile.militaryUnit!!.owner==owner)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.unciv.logic.map
|
package com.unciv.logic.map
|
||||||
|
|
||||||
import com.badlogic.gdx.math.Vector2
|
import com.badlogic.gdx.math.Vector2
|
||||||
import com.unciv.models.gamebasics.tile.TerrainType
|
|
||||||
|
|
||||||
class UnitMovementAlgorithms(val unit:MapUnit) {
|
class UnitMovementAlgorithms(val unit:MapUnit) {
|
||||||
val tileMap = unit.getTile().tileMap
|
val tileMap = unit.getTile().tileMap
|
||||||
@ -24,6 +23,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
|||||||
return to.lastTerrain.movementCost.toFloat() // no road
|
return to.lastTerrain.movementCost.toFloat() // no road
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun getDistanceToTilesWithinTurn(origin: Vector2, unitMovement: Float): HashMap<TileInfo, Float> {
|
fun getDistanceToTilesWithinTurn(origin: Vector2, unitMovement: Float): HashMap<TileInfo, Float> {
|
||||||
if(unitMovement==0f) return hashMapOf()
|
if(unitMovement==0f) return hashMapOf()
|
||||||
val distanceToTiles = LinkedHashMap<TileInfo, Float>()
|
val distanceToTiles = LinkedHashMap<TileInfo, Float>()
|
||||||
@ -36,13 +36,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
|||||||
for (tileToCheck in tilesToCheck)
|
for (tileToCheck in tilesToCheck)
|
||||||
for (neighbor in tileToCheck.neighbors) {
|
for (neighbor in tileToCheck.neighbors) {
|
||||||
var totalDistanceToTile:Float
|
var totalDistanceToTile:Float
|
||||||
val neighborOwner = neighbor.getOwner()
|
if (!unit.canPassThrough(neighbor))
|
||||||
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
|
|
||||||
)
|
|
||||||
totalDistanceToTile = unitMovement // Can't go here.
|
totalDistanceToTile = unitMovement // Can't go here.
|
||||||
// The reason that we don't just "return" is so that when calculating how to reach an enemy,
|
// 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
|
// You need to assume his tile is reachable, otherwise all movement algs on reaching enemy
|
||||||
|
@ -24,7 +24,7 @@ class BaseUnit : INamed, IConstruction, ICivilopedia {
|
|||||||
internal var unbuildable: Boolean = false // for special units like great people
|
internal var unbuildable: Boolean = false // for special units like great people
|
||||||
var requiredTech:String? = null
|
var requiredTech:String? = null
|
||||||
var requiredResource:String? = null
|
var requiredResource:String? = null
|
||||||
var uniques:HashSet<String>?=null
|
var uniques =HashSet<String>()
|
||||||
var obsoleteTech:String?=null
|
var obsoleteTech:String?=null
|
||||||
var upgradesTo:String? = null
|
var upgradesTo:String? = null
|
||||||
var replaces:String?=null
|
var replaces:String?=null
|
||||||
|
@ -8,6 +8,7 @@ enum class UnitType{
|
|||||||
Scout,
|
Scout,
|
||||||
Mounted,
|
Mounted,
|
||||||
WaterCivilian,
|
WaterCivilian,
|
||||||
|
WaterMelee,
|
||||||
Siege;
|
Siege;
|
||||||
|
|
||||||
fun isMelee(): Boolean {
|
fun isMelee(): Boolean {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user