Ejemplo n.º 1
0
        public static string PlanetTypeToString(PLANET_TYPE planetType)
        {
            switch (planetType)
            {
            case PLANET_TYPE.ARCTIC: return("Arctic");

            case PLANET_TYPE.BADLAND: return("Badlands");

            case PLANET_TYPE.BARREN: return("Barren");

            case PLANET_TYPE.DEAD: return("Dead");

            case PLANET_TYPE.DESERT: return("Desert");

            case PLANET_TYPE.JUNGLE: return("Jungle");

            case PLANET_TYPE.NONE: return("None");

            case PLANET_TYPE.OCEAN: return("Oceanic");

            case PLANET_TYPE.RADIATED: return("Radiated");

            case PLANET_TYPE.STEPPE: return("Steppe");

            case PLANET_TYPE.TERRAN: return("Terran");

            case PLANET_TYPE.TOXIC: return("Toxic");

            case PLANET_TYPE.TUNDRA: return("Tundra");

            case PLANET_TYPE.VOLCANIC: return("Volcanic");
            }
            return(String.Empty);
        }
Ejemplo n.º 2
0
        private void SetValues(string name, string type, int maxPop, StarSystem system, Empire empire, Random r)
        {
            _whichSystem = system;
            this._name = name;
            _races = new List<Race>();
            _racePopulations = new Dictionary<Race, float>();
            TransferSystem = new KeyValuePair<TravelNode, int>(new TravelNode(), 0);
            TransferSystemID = new KeyValuePair<int, int>();
            RelocateToSystem = null;
            Owner = empire;
            _populationMax = maxPop;

            switch (type)
            {
                case ARCTIC:
                    {
                        _planetType = PLANET_TYPE.ARCTIC;
                        SmallSprite = SpriteManager.GetSprite("ArcticPlanetSmall", r);
                        GroundSprite = SpriteManager.GetSprite("ArcticGround", r);
                    } break;
                case BADLANDS:
                    {
                        _planetType = PLANET_TYPE.BADLAND;
                        SmallSprite = SpriteManager.GetSprite("BadlandsPlanetSmall", r);
                        GroundSprite = SpriteManager.GetSprite("BadlandsGround", r);
                    } break;
                case BARREN:
                    {
                        _planetType = PLANET_TYPE.BARREN;
                        SmallSprite = SpriteManager.GetSprite("BarrenPlanetSmall", r);
                        GroundSprite = SpriteManager.GetSprite("BarrenGround", r);
                    } break;
                case DEAD:
                    {
                        _planetType = PLANET_TYPE.DEAD;
                        SmallSprite = SpriteManager.GetSprite("DeadPlanetSmall", r);
                        GroundSprite = SpriteManager.GetSprite("DeadGround", r);
                    } break;
                case DESERT:
                    {
                        _planetType = PLANET_TYPE.DESERT;
                        SmallSprite = SpriteManager.GetSprite("DesertPlanetSmall", r);
                        GroundSprite = SpriteManager.GetSprite("DesertGround", r);
                    } break;
                case JUNGLE:
                    {
                        _planetType = PLANET_TYPE.JUNGLE;
                        SmallSprite = SpriteManager.GetSprite("JunglePlanetSmall", r);
                        GroundSprite = SpriteManager.GetSprite("JungleGround", r);
                    } break;
                case NONE:
                    {
                        _planetType = PLANET_TYPE.NONE;
                        SmallSprite = SpriteManager.GetSprite("AsteroidsPlanetSmall", r);
                    } break;
                case OCEANIC:
                    {
                        _planetType = PLANET_TYPE.OCEAN;
                        SmallSprite = SpriteManager.GetSprite("OceanicPlanetSmall", r);
                        GroundSprite = SpriteManager.GetSprite("OceanicGround", r);
                    } break;
                case RADIATED:
                    {
                        _planetType = PLANET_TYPE.RADIATED;
                        SmallSprite = SpriteManager.GetSprite("RadiatedPlanetSmall", r);
                        GroundSprite = SpriteManager.GetSprite("RadiatedGround", r);
                    } break;
                case STEPPE:
                    {
                        _planetType = PLANET_TYPE.STEPPE;
                        SmallSprite = SpriteManager.GetSprite("SteppePlanetSmall", r);
                        GroundSprite = SpriteManager.GetSprite("SteppeGround", r);
                    } break;
                case TERRAN:
                    {
                        _planetType = PLANET_TYPE.TERRAN;
                        SmallSprite = SpriteManager.GetSprite("TerranPlanetSmall", r);
                        GroundSprite = SpriteManager.GetSprite("TerranGround", r);
                    } break;
                case TOXIC:
                    {
                        _planetType = PLANET_TYPE.TOXIC;
                        SmallSprite = SpriteManager.GetSprite("ToxicPlanetSmall", r);
                        GroundSprite = SpriteManager.GetSprite("ToxicGround", r);
                    } break;
                case TUNDRA:
                    {
                        _planetType = PLANET_TYPE.TUNDRA;
                        SmallSprite = SpriteManager.GetSprite("TundraPlanetSmall", r);
                        GroundSprite = SpriteManager.GetSprite("TundraGround", r);
                    } break;
                case VOLCANIC:
                    {
                        _planetType = PLANET_TYPE.VOLCANIC;
                        SmallSprite = SpriteManager.GetSprite("VolcanicPlanetSmall", r);
                        GroundSprite = SpriteManager.GetSprite("VolcanicGround", r);
                    } break;
            }

            _planetTypeString = Utility.PlanetTypeToString(_planetType);
        }
Ejemplo n.º 3
0
        //Used for end of turn processing
        public void UpdatePlanet()
        {
            bool setInfrastructureToZero = false;
            bool setDefenseToZero = false;
            bool setEnvironmentToZero = false;
            bool setConstructionToZero = false; //Only used when Stargates are built
            //Update ship construction
            if (ConstructionAmount > 0)
            {
                ShipConstructionAmount += ConstructionAmount * 0.01f * ActualProduction;
            }

            Factories += AmountOfBuildingsThisTurn;
            _factoryInvestments += AmountLostToRefitThisTurn;
            _factoryInvestments += AmountOfBuildingsThisTurn * _owner.TechnologyManager.FactoryCost;

            if (Factories >= TotalMaxPopulation * _owner.TechnologyManager.RoboticControls)
            {
                setInfrastructureToZero = true;
                //TODO: Notify player
            }

            Waste = AmountOfWasteCleanupNeeded;
            if (Waste > PopulationMax - 10)
            {
                Waste = PopulationMax - 10;
            }

            if (AmountLostToUpgradeThisTurn > 0)
            {
                _baseInvestments += AmountLostToUpgradeThisTurn;
                AmountLostToUpgradeThisTurn = 0;
            }
            if (AmountToInvestInShield > 0)
            {
                _shieldProjectRevenues += AmountToInvestInShield;
                if (_shieldProjectRevenues >= 500)
                {
                    //Upgrade the shield to next level
                    ShieldLevel += 5;
                    _shieldProjectRevenues -= 500;
                    if (ShieldLevel == _owner.TechnologyManager.HighestPlanetaryShield)
                    {
                        //TODO: Notify player that shield has been built, and invest the remaining BCs into bases, then set military spending to 0
                        float amountOfBCs = _shieldProjectRevenues;
                        setDefenseToZero = true;
                        if (Bases * _owner.TechnologyManager.MissileBaseCost < _baseInvestments)
                        {
                            float amountNeeded = (Bases * _owner.TechnologyManager.MissileBaseCost) - _baseInvestments;
                            if (amountOfBCs < amountNeeded)
                            {
                                _baseInvestments += amountOfBCs;
                            }
                            else
                            {
                                _baseInvestments += amountNeeded;
                                AmountOfBaseInvestmentThisTurn += amountOfBCs - amountNeeded;
                            }
                        }
                        else
                        {
                            //Free to build new bases
                            AmountOfBaseInvestmentThisTurn += amountOfBCs;
                        }
                    }
                }
            }
            if (AmountOfBaseInvestmentThisTurn > 0)
            {
                //Add to investment, and see if we built some bases
                NextBaseInvestment += AmountOfBaseInvestmentThisTurn;
                _baseInvestments += AmountOfBaseInvestmentThisTurn;
                //TODO: Factor in Nebula
                while (NextBaseInvestment >= _owner.TechnologyManager.MissileBaseCost)
                {
                    Bases++;
                    NextBaseInvestment -= _owner.TechnologyManager.MissileBaseCost;
                }
            }

            if (TerraformProjectInvestment > 0)
            {
                if (_owner.TechnologyManager.HasAtmosphericTerraform && (_planetType == PLANET_TYPE.RADIATED ||
                    _planetType == PLANET_TYPE.TOXIC || _planetType == PLANET_TYPE.VOLCANIC || _planetType == PLANET_TYPE.DEAD ||
                    _planetType == PLANET_TYPE.TUNDRA || _planetType == PLANET_TYPE.BARREN))
                {
                    //Invest into changing this to Arctic planet
                    _terraformProjectRevenues += TerraformProjectInvestment;
                    TerraformProjectInvestment = 0;
                    if (_terraformProjectRevenues >= 200) //Converted to Arctic
                    {
                        _terraformProjectRevenues -= 200;
                        //Barren planets get no population bonus.
                        if (_planetType == PLANET_TYPE.TUNDRA || _planetType == PLANET_TYPE.DEAD)
                        {
                            _populationMax += 10;
                        }
                        else if (_planetType != PLANET_TYPE.BARREN)
                        {
                            _populationMax += 20;
                        }
                        _planetType = PLANET_TYPE.ARCTIC;
                        EnvironmentBonus = PLANET_ENVIRONMENT_BONUS.AVERAGE;
                        TerraformProjectInvestment = _terraformProjectRevenues; //Roll over into next terraforming project
                        _terraformProjectRevenues = 0;
                        //TODO: Notify player
                    }
                }
                if (TerraformProjectInvestment > 0)
                {
                    //Handle soil/advanced soil enrichment here
                    if ((_owner.TechnologyManager.HasSoilEnrichment || _owner.TechnologyManager.HasAdvancedSoilEnrichment) && !(_planetType == PLANET_TYPE.RADIATED ||
                        _planetType == PLANET_TYPE.TOXIC || _planetType == PLANET_TYPE.VOLCANIC || _planetType == PLANET_TYPE.DEAD ||
                        _planetType == PLANET_TYPE.TUNDRA || _planetType == PLANET_TYPE.BARREN))
                    {
                        if (EnvironmentBonus == PLANET_ENVIRONMENT_BONUS.AVERAGE)
                        {
                            _terraformProjectRevenues += TerraformProjectInvestment;
                            TerraformProjectInvestment = 0;
                            if (_terraformProjectRevenues >= 150)
                            {
                                //it is now fertile
                                EnvironmentBonus = PLANET_ENVIRONMENT_BONUS.FERTILE;
                                _terraformProjectRevenues -= 150;
                                _populationMax += (((_populationMax - 5) / 20) + 1) * 5;
                                if (!_owner.TechnologyManager.HasAdvancedSoilEnrichment)
                                {
                                    TerraformProjectInvestment = _terraformProjectRevenues; //Stop at fertile, not gaia, and roll over BCs into terraforming
                                    _terraformProjectRevenues = 0;
                                    //TODO: Notify player
                                }
                            }
                        }
                        if (EnvironmentBonus == PLANET_ENVIRONMENT_BONUS.FERTILE && _owner.TechnologyManager.HasAdvancedSoilEnrichment)
                        {
                            //Gaia development here
                            _terraformProjectRevenues += TerraformProjectInvestment;
                            TerraformProjectInvestment = 0;
                            if (_terraformProjectRevenues >= 150) //Already deducted 150 for Fertile process from Gaia's 300 cost
                            {
                                EnvironmentBonus = PLANET_ENVIRONMENT_BONUS.GAIA;
                                _terraformProjectRevenues -= 150;
                                _populationMax += (((_populationMax - 20) / 25) + 1) * 5;
                                TerraformProjectInvestment = _terraformProjectRevenues;
                                _terraformProjectRevenues = 0; //No more projects at this point, only terraforming
                                //TODO: Notify player
                            }
                        }
                    }
                }
                if (TerraformProjectInvestment > 0)
                {
                    //Handle terraforming and pop growth here
                    if (_terraformPop < _owner.TechnologyManager.MaxTerraformPop)
                    {
                        _terraformPop += TerraformProjectInvestment / _owner.TechnologyManager.TerraformCost;
                        if (_terraformPop >= _owner.TechnologyManager.MaxTerraformPop)
                        {
                            float excess = _terraformPop - _owner.TechnologyManager.MaxTerraformPop;
                            _terraformPop = _owner.TechnologyManager.MaxTerraformPop;
                            TerraformProjectInvestment = excess * _owner.TechnologyManager.TerraformCost;
                            //TODO: Notify player
                        }
                    }
                    if (TerraformProjectInvestment > 0)
                    {
                        //Finally add population
                        ExtraPopulationCloned += TerraformProjectInvestment / _owner.TechnologyManager.CloningCost;
                        if (TotalPopulation + ExtraPopulationCloned > TotalMaxPopulation)
                        {
                            ExtraPopulationCloned = TotalMaxPopulation - TotalPopulation;
                            //Excess BC are wasted, matching MoO 1's handling
                        }
                    }
                }
            }
            if (ExtraPopulationCloned > 0)
            {
                float totalPop = TotalPopulation;
                //Sanity check
                if (TotalPopulation + ExtraPopulationCloned > TotalMaxPopulation)
                {
                    ExtraPopulationCloned = TotalMaxPopulation - TotalPopulation;
                }
                foreach (var race in _races)
                {
                    _racePopulations[race] += ExtraPopulationCloned * (_racePopulations[race] / totalPop);
                }
                if (TotalPopulation >= TotalMaxPopulation)
                {
                    setEnvironmentToZero = true;
                    //Extra population will die off due to growth formula, this is very minor, in decimal place.
                    //TODO: Notify player
                }
            }

            foreach (Race race in _races)
            {
                _racePopulations[race] += CalculateRaceGrowth(race);
            }

            _races.Sort((a, b) => { return (_racePopulations[a].CompareTo(_racePopulations[b])); });

            if (setConstructionToZero)
            {
                SetOutputAmount(OUTPUT_TYPE.CONSTRUCTION, 0, true);
            }
            if (setEnvironmentToZero)
            {
                SetOutputAmount(OUTPUT_TYPE.ENVIRONMENT, 0, true);
            }
            if (setInfrastructureToZero)
            {
                SetOutputAmount(OUTPUT_TYPE.INFRASTRUCTURE, 0, true);
            }
            if (setDefenseToZero)
            {
                SetOutputAmount(OUTPUT_TYPE.DEFENSE, 0, true);
            }
            //Update the enviroment to at least sufficient to clean up waste
            SetCleanup();
            UpdateOutputs();

            //Deduct reserves if any exists
            if (Reserves > 0)
            {
                Reserves -= (TotalProductionWithTrade - ProductionLostFromExpenses);
                if (Reserves < 0)
                {
                    Reserves = 0;
                }
            }
        }
Ejemplo n.º 4
0
 //Set this planet as homeworld
 public void SetHomeworld(Empire owner, Random r)
 {
     _owner = owner;
     _planetType = PLANET_TYPE.TERRAN;
     _planetTypeString = Utility.PlanetTypeToString(_planetType);
     SmallSprite = SpriteManager.GetSprite("TerranPlanetSmall", r);
     _populationMax = 100;
     _races.Add(owner.EmpireRace);
     _racePopulations.Add(owner.EmpireRace, 40);
     Factories = 30;
     _factoryInvestments = 300; //Start with 300 BCs invested in factories
     SetOutputAmount(OUTPUT_TYPE.INFRASTRUCTURE, 100, true);
     ResearchBonus = PLANET_RESEARCH_BONUS.AVERAGE;
     ConstructionBonus = PLANET_CONSTRUCTION_BONUS.AVERAGE;
     EnvironmentBonus = PLANET_ENVIRONMENT_BONUS.AVERAGE;
 }
Ejemplo n.º 5
0
 public static string PlanetTypeToString(PLANET_TYPE planetType)
 {
     switch (planetType)
     {
         case PLANET_TYPE.ARCTIC: return "Arctic";
         case PLANET_TYPE.BADLAND: return "Badlands";
         case PLANET_TYPE.BARREN: return "Barren";
         case PLANET_TYPE.DEAD: return "Dead";
         case PLANET_TYPE.DESERT: return "Desert";
         case PLANET_TYPE.JUNGLE: return "Jungle";
         case PLANET_TYPE.NONE: return "None";
         case PLANET_TYPE.OCEAN: return "Oceanic";
         case PLANET_TYPE.RADIATED: return "Radiated";
         case PLANET_TYPE.STEPPE: return "Steppe";
         case PLANET_TYPE.TERRAN: return "Terran";
         case PLANET_TYPE.TOXIC: return "Toxic";
         case PLANET_TYPE.TUNDRA: return "Tundra";
         case PLANET_TYPE.VOLCANIC: return "Volcanic";
     }
     return String.Empty;
 }