コード例 #1
0
        public YieldSummary GetYieldOfTerrain(CellTerrain terrain)
        {
            switch (terrain)
            {
            case CellTerrain.Grassland:    return(GrasslandYield);

            case CellTerrain.Plains:       return(PlainsYield);

            case CellTerrain.Desert:       return(DesertYield);

            case CellTerrain.Tundra:       return(TundraYield);

            case CellTerrain.Snow:         return(SnowYield);

            case CellTerrain.ShallowWater: return(ShallowWaterYield);

            case CellTerrain.DeepWater:    return(DeepWaterYield);

            case CellTerrain.FreshWater:   return(FreshWaterYield);

            case CellTerrain.FloodPlains:  return(FloodPlainsYield);

            default: throw new NotImplementedException();
            }
        }
コード例 #2
0
        public int GetWeightFromTerrain(CellTerrain terrain)
        {
            switch (terrain)
            {
            case CellTerrain.Grassland:    return(GrasslandWeight);

            case CellTerrain.Plains:       return(PlainsWeight);

            case CellTerrain.Desert:       return(DesertWeight);

            case CellTerrain.FloodPlains:  return(FloodPlainsWeight);

            case CellTerrain.Tundra:       return(TundraWeight);

            case CellTerrain.Snow:         return(SnowWeight);

            case CellTerrain.ShallowWater: return(ShallowWaterWeight);

            case CellTerrain.DeepWater:    return(-1000);

            case CellTerrain.FreshWater:   return(-1000);

            default: throw new NotImplementedException();
            }
        }
コード例 #3
0
        private IHexCell BuildCell(
            CellTerrain terrain       = CellTerrain.Grassland,
            CellShape shape           = CellShape.Flatlands,
            CellVegetation vegetation = CellVegetation.None,
            CellFeature feature       = CellFeature.None,
            bool hasRoads             = false,
            bool hasRiver             = false,
            ICity city = null
            )
        {
            var mockCell = new Mock <IHexCell>();

            mockCell.SetupAllProperties();

            var newCell = mockCell.Object;

            newCell.Terrain    = terrain;
            newCell.Shape      = shape;
            newCell.Vegetation = vegetation;
            newCell.Feature    = feature;
            newCell.HasRoads   = hasRoads;

            MockRiverCanon.Setup(canon => canon.HasRiver(newCell)).Returns(hasRiver);

            MockCityLocationCanon.Setup(canon => canon.GetPossessionsOfOwner(newCell))
            .Returns(city != null ? new List <ICity>()
            {
                city
            } : new List <ICity>());

            return(newCell);
        }
コード例 #4
0
 public void SetActiveTerrain(int index)
 {
     IsPaintingTerrain = index >= 0;
     if (IsPaintingTerrain)
     {
         ActiveTerrain = (CellTerrain)index;
     }
 }
コード例 #5
0
        private IHexCell BuildCell(CellTerrain terrain)
        {
            var mockCell = new Mock <IHexCell>();

            mockCell.Setup(cell => cell.Terrain).Returns(terrain);

            return(mockCell.Object);
        }
コード例 #6
0
        private IHexCell BuildCell(CellTerrain terrain, CellShape shape, CellVegetation vegetation)
        {
            var mockCell = new Mock <IHexCell>();

            mockCell.Setup(cell => cell.Terrain).Returns(terrain);
            mockCell.Setup(cell => cell.Shape).Returns(shape);
            mockCell.Setup(cell => cell.Vegetation).Returns(vegetation);

            return(mockCell.Object);
        }
コード例 #7
0
        public CellYieldModificationData(bool mustBeUnderwater, YieldSummary bonusYield)
        {
            _propertyConsidered = CellPropertyType.CellIsUnderwater;
            _mustBeUnderwater   = mustBeUnderwater;
            _bonusYield         = bonusYield;

            _terrainRequired    = CellTerrain.Grassland;
            _shapeRequired      = CellShape.Flatlands;
            _vegetationRequired = CellVegetation.None;
        }
コード例 #8
0
        public CellYieldModificationData(CellVegetation featureRequired, YieldSummary bonusYield)
        {
            _propertyConsidered = CellPropertyType.Vegetation;
            _vegetationRequired = featureRequired;
            _bonusYield         = bonusYield;

            _terrainRequired  = CellTerrain.Grassland;
            _shapeRequired    = CellShape.Flatlands;
            _mustBeUnderwater = false;
        }
コード例 #9
0
        public int GetTreePlacementCostForTerrain(CellTerrain terrain)
        {
            switch (terrain)
            {
            case CellTerrain.Grassland: return(TreesOnGrasslandCrawlCost);

            case CellTerrain.Plains:    return(TreesOnPlainsCrawlCost);

            case CellTerrain.Tundra:    return(TreesOnTundraCrawlCost);

            default: return(-1000);
            }
        }
コード例 #10
0
        public float GetTerrainDefensiveness(CellTerrain terrain)
        {
            var index = (int)terrain;

            if (index >= TerrainDefensiveness.Count)
            {
                return(0);
            }
            else
            {
                return(TerrainDefensiveness[index]);
            }
        }
コード例 #11
0
        private IHexCell BuildCell(CellTerrain terrain, CellShape shape, params IImprovement[] improvements)
        {
            var mockCell = new Mock <IHexCell>();

            mockCell.Setup(cell => cell.Terrain).Returns(terrain);
            mockCell.Setup(cell => cell.Shape).Returns(shape);

            var newCell = mockCell.Object;

            MockImprovementLocationCanon.Setup(canon => canon.GetPossessionsOfOwner(newCell)).Returns(improvements);

            return(newCell);
        }
コード例 #12
0
        public float GetIdealTemperatureForTerrain(CellTerrain terrain)
        {
            switch (terrain)
            {
            case CellTerrain.Grassland: return(IdealGrasslandTemperature);

            case CellTerrain.Plains:    return(IdealPlainsTemperature);

            case CellTerrain.Desert:    return(IdealDesertTemperature);

            default: throw new NotImplementedException("No ideal temperature for terrain " + terrain);
            }
        }
コード例 #13
0
        public float GetIdealPrecipitationForTerrain(CellTerrain terrain)
        {
            switch (terrain)
            {
            case CellTerrain.Grassland: return(IdealGrasslandPrecipitation);

            case CellTerrain.Plains:    return(IdealPlainsPrecipitation);

            case CellTerrain.Desert:    return(IdealDesertPrecipitation);

            default: throw new NotImplementedException("No ideal precipitation for terrain " + terrain);
            }
        }
コード例 #14
0
        private IHexCell BuildCell(
            CellTerrain terrain       = CellTerrain.Grassland,
            CellShape shape           = CellShape.Flatlands,
            CellVegetation vegetation = CellVegetation.None,
            CellFeature feature       = CellFeature.None
            )
        {
            var mockCell = new Mock <IHexCell>();

            mockCell.Setup(cell => cell.Terrain).Returns(terrain);
            mockCell.Setup(cell => cell.Shape).Returns(shape);
            mockCell.Setup(cell => cell.Vegetation).Returns(vegetation);
            mockCell.Setup(cell => cell.Feature).Returns(feature);

            return(mockCell.Object);
        }
コード例 #15
0
        private IHexCell BuildCell(CellTerrain terrain, IEnumerable <IUnitTemplate> validTemplates)
        {
            var mockCell = new Mock <IHexCell>();

            mockCell.Setup(cell => cell.Terrain).Returns(terrain);

            var newCell = mockCell.Object;

            foreach (var template in validTemplates)
            {
                MockUnitPositionCanon.Setup(
                    canon => canon.CanPlaceUnitTemplateAtLocation(template, newCell, It.IsAny <ICivilization>())
                    ).Returns(true);
            }

            return(newCell);
        }
コード例 #16
0
        public void ChangeTerrainOfCell(IHexCell cell, CellTerrain terrain)
        {
            if (!CanChangeTerrainOfCell(cell, terrain))
            {
                throw new InvalidOperationException("CanChangeTerrainOfCell must return true on the given arguments");
            }

            cell.Terrain = terrain;

            if (terrain != CellTerrain.Grassland && cell.Vegetation == CellVegetation.Marsh)
            {
                ChangeVegetationOfCell(cell, CellVegetation.None);
            }

            if (cell.Vegetation == CellVegetation.Forest && (
                    cell.Terrain == CellTerrain.Snow || cell.Terrain == CellTerrain.Desert ||
                    cell.Terrain == CellTerrain.FloodPlains
                    ))
            {
                ChangeVegetationOfCell(cell, CellVegetation.None);
            }

            if (cell.Vegetation == CellVegetation.Jungle && cell.Terrain != CellTerrain.Grassland && cell.Terrain != CellTerrain.Plains)
            {
                ChangeVegetationOfCell(cell, CellVegetation.None);
            }

            if (cell.Terrain != CellTerrain.Desert && cell.Feature == CellFeature.Oasis)
            {
                ChangeFeatureOfCell(cell, CellFeature.None);
            }

            if (cell.Terrain.IsWater())
            {
                ChangeVegetationOfCell(cell, CellVegetation.None);
                ChangeShapeOfCell(cell, CellShape.Flatlands);

                RiverCanon.RemoveAllRiversFromCell(cell);

                ChangeHasRoadsOfCell(cell, false);
            }
        }
コード例 #17
0
        private Func <IHexCell, int> GetWeightFunction(CellTerrain terrain)
        {
            float idealTemperature   = Config.GetIdealTemperatureForTerrain(terrain);
            float idealPrecipitation = Config.GetIdealPrecipitationForTerrain(terrain);

            return(delegate(IHexCell cell) {
                if (!ModLogic.CanChangeTerrainOfCell(cell, terrain))
                {
                    return 0;
                }
                else
                {
                    float cellTemperature = CellClimateLogic.GetTemperatureOfCell(cell);
                    float cellPrecipitation = CellClimateLogic.GetPrecipitationOfCell(cell);

                    int weight = Config.BaseTerrainWeight -
                                 Config.TerrainTemperatureWeight * Mathf.RoundToInt(Mathf.Abs(idealTemperature - cellTemperature)) -
                                 Config.TerrainPrecipitationWeight * Mathf.RoundToInt(Mathf.Abs(idealPrecipitation - cellPrecipitation));

                    return Math.Max(weight, 0);
                }
            });
        }
コード例 #18
0
 public bool IsCostIgnoredOnTerrain(CellTerrain terrain)
 {
     return(TerrainsWithIgnoredCosts.Contains(terrain));
 }
コード例 #19
0
 public bool CanChangeTerrainOfCell(IHexCell cell, CellTerrain terrain)
 {
     return(terrain != CellTerrain.FloodPlains || cell.Shape == CellShape.Flatlands);
 }
コード例 #20
0
 public static bool IsArctic(this CellTerrain type)
 {
     return(type == CellTerrain.Tundra ||
            type == CellTerrain.Snow);
 }
コード例 #21
0
 public static bool IsDesert(this CellTerrain type)
 {
     return(type == CellTerrain.Desert ||
            type == CellTerrain.FloodPlains);
 }
コード例 #22
0
 public int GetBaseMoveCostOfTerrain(CellTerrain terrain)
 {
     return(BaseMoveCost);
 }
コード例 #23
0
 public static bool IsWater(this CellTerrain type)
 {
     return(type == CellTerrain.ShallowWater ||
            type == CellTerrain.DeepWater ||
            type == CellTerrain.FreshWater);
 }