Submarine can only be aimed by destroyers and submarines.
This commit is contained in:
parent
36d7b30279
commit
11871991d3
4 changed files with 10 additions and 0 deletions
|
@ -118,6 +118,12 @@ class UnitAutomation{
|
|||
if(tileCombatant==null) return false
|
||||
if(tileCombatant.getCivilization()==unit.civInfo ) return false
|
||||
if(!unit.civInfo.isAtWarWith(tileCombatant.getCivilization())) return false
|
||||
|
||||
//only submarine and destroyer can attack submarine
|
||||
if (tileCombatant.isInvisible()
|
||||
&& (!unit.hasUnique("Can attack submarines") || unit.civInfo.viewableInvisibleUnitsTiles.map { it.position }.contains(tile.position))){
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ class CityCombatant(val city: CityInfo) : ICombatant {
|
|||
override fun getTile(): TileInfo = city.getCenterTile()
|
||||
override fun getName(): String = city.name
|
||||
override fun isDefeated(): Boolean = city.health==1
|
||||
override fun isInvisible(): Boolean = false
|
||||
|
||||
override fun takeDamage(damage: Int) {
|
||||
city.health -= damage
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.unciv.logic.battle
|
||||
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.map.MapUnit
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.gamebasics.unit.UnitType
|
||||
|
||||
|
@ -14,6 +15,7 @@ interface ICombatant{
|
|||
fun isDefeated():Boolean
|
||||
fun getCivilization(): CivilizationInfo
|
||||
fun getTile(): TileInfo
|
||||
fun isInvisible(): Boolean
|
||||
|
||||
fun isMelee(): Boolean {
|
||||
return this.getUnitType().isMelee()
|
||||
|
|
|
@ -11,6 +11,7 @@ class MapUnitCombatant(val unit: MapUnit) : ICombatant {
|
|||
override fun getTile(): TileInfo = unit.getTile()
|
||||
override fun getName(): String = unit.name
|
||||
override fun isDefeated(): Boolean = unit.health <= 0
|
||||
override fun isInvisible(): Boolean = unit.isInvisible()
|
||||
|
||||
override fun takeDamage(damage: Int) {
|
||||
unit.health -= damage
|
||||
|
|
Loading…
Reference in a new issue