public static int GetPrizeToCreateColony(Settlement.SettlementType type)
 {
     int i = 1;
     if (type == Settlement.SettlementType.COMMUNITY)
         i = 500;
     else if (type == Settlement.SettlementType.INHABITED)
         i = 400;
     else if (type == Settlement.SettlementType.MILITARY)
         i = 150;
     return i;
 }
        /// <summary>
        /// Metodo che crea gli imperi
        /// </summary>
        private static void CreateEmpires()
        {
            Random rnd = new Random();
            // Terrascore minimo definito a partire dal numero degli imperi da creare
            int terrascore = 24;
            int empireNumber = GameParams.empireNumber;
            if (empireNumber < 150)
                terrascore = 27;
            else if (empireNumber < 125)
                terrascore = 30;

            int empireCount = 0;
            foreach(SolarSystem ss in solarSystems)
            {
                foreach(Planet p in ss.Planets)
                {
                    // Se il terrascore va bene e non si sono creati abbastanza imperi, creane uno
                    if(p.Terrascore >= terrascore && empireCount < empireNumber)
                    {
                        Empire empire = new Empire(ss);
                        int money = rnd.Next(10000, 100000); // Soldi e abitanti random
                        int inhabitants = rnd.Next(10000, 1000000);

                        // Definisci potenza di attacco e difese a seconda della religione
                        int minD = 300; int minO = 10;
                        if (empire.EmpireReligion == Religion.ReligionType.ATOM || empire.EmpireReligion == Religion.ReligionType.BLESS)
                            minD = 1000;
                        else if (empire.EmpireReligion == Religion.ReligionType.CURSER)
                            minO = 100;
                        int defense = rnd.Next(minD, 10000);
                        int offense = rnd.Next(minO, 200);
                        // Crea insediamento
                        Settlement settlement = new Settlement(Settlement.SettlementType.CAPITAL, money, inhabitants, defense, offense, empire.EmpireReligion);
                        p.CreateSettlement(settlement);
                        empire.SetEmpireCapital(p);
                        // Aggiungilo agli imperi
                        empires.Add(empire);
                        empireCount++;
                        break;
                    }
                }
                // Se si sono creati tutti gli imperi, esci da for
                if (empireCount > empireNumber)
                    break;
            }
        }
 static bool CreateSettlement()
 {
     bool result = false;
     foreach(Button b in ChoiceButtons)
     {
         if(b.WasPressed())
         {
             if(b.Type == "YesButton")
             {
                 Settlement.SettlementType type = Settlement.GetSettlementTypeFromString(settlementType);
                 Settlement capitalSett = GameManager.PlayerCapital.PlanetSettlement;
                 Settlement s = new Settlement(type, prize / 2, capitalSett.Inhabitants / 16, capitalSett.DefensiveArmy, capitalSett.OffensiveArmy,
                     capitalSett.InhaGrowthRate, capitalSett.ScienceLevel, capitalSett.ScienceGrowthRate, capitalSett.CommerceLevel, capitalSett.CommerceGrowthRate,
                     capitalSett.TecnoLevel, capitalSett.TecnoGrowthRate);
                 GameSystemDesigner.ActualPlanet.CreateSettlement(s);
                 GameManager.SetActualSystemOwner(GameManager.PlayerEmpire);
                 PlayerShip.Money -= prize;
                 state = PanelState.WAIT;
                 settlementType = "";
                 prize = int.MaxValue;
                 return true;
             }
             else if(b.Type == "CancelButton")
             {
                 state = PanelState.WAIT;
                 settlementType = "";
                 prize = int.MaxValue;
                 return false;
             }
         }
     }
     return result;
 }
Example #4
0
 public void CreateSettlement(Settlement settlement)
 {
     planetSettlement = settlement;
 }
        static void SaveSettlement(XmlWriter xw, Settlement s)
        {
            xw.WriteStartElement("SETTLEMENT");

            xw.WriteAttributeString("TYPE", s.Type.ToString());
            xw.WriteAttributeString("MONEY", s.Money.ToString());
            xw.WriteAttributeString("INHABITANTS", s.Inhabitants.ToString());
            xw.WriteAttributeString("INHARATE", s.InhaGrowthRate.ToString());
            xw.WriteAttributeString("SCIENCE", s.ScienceLevel.ToString());
            xw.WriteAttributeString("SCIENCERATE", s.ScienceGrowthRate.ToString());
            xw.WriteAttributeString("COMMERCE", s.CommerceLevel.ToString());
            xw.WriteAttributeString("COMMERCERATE", s.CommerceGrowthRate.ToString());
            xw.WriteAttributeString("TECNO", s.TecnoLevel.ToString());
            xw.WriteAttributeString("TECNORATE", s.TecnoGrowthRate.ToString());

            xw.WriteAttributeString("OFFENSIVE", s.OffensiveArmy.ToString());
            xw.WriteAttributeString("DEFENSIVE", s.DefensiveArmy.ToString());

            //Inserisci i prodotti dell'insediamento
            SaveProducts(xw, s.Products);
            xw.WriteEndElement();//Di SETTLEMENT
        }
        public void CreatePlanets(bool playerStartingSystem = false)
        {
            planets = new List<Planet>();
            for (int i = 1; i < 10; i++)
            {
                if (rnd.Next(0, 3) != 0) // non si crea il pianeta
                    continue;
                bool habitable = i < 4 || i > 6 ? false : true; //Se i è tra 4 e 6 il pianeta è abitabile
                int score = habitable ? rnd.Next(0, 32) : 0; //e gli si da un terrascore
                Vector3 startPosition = systemPosition;
                startPosition.X += i * 60; //posizione iniziale del pianeta
                string type;
                if (i <= 6)
                    type = "Type" + rnd.Next(1, 10); //Tipo del pianeta, se in posizione fino a 6 è roccioso, altrimenti gassoso
                else
                    type = "Gas" + rnd.Next(1, 9);
                Planet p = new Planet(habitable, score, startPosition, systemPosition, type, i * 60);//Crea il pianeta
                planets.Add(p); //ed aggiungilo alla lista
            }
            if(playerStartingSystem)
            {
                bool created = false;
                foreach(Planet p in planets)
                    if(p.IsHabitable)
                    {
                        p.Terrascore = 32;
                        Settlement settlement = new Settlement(Settlement.SettlementType.CAPITAL, GameParams.religionType);
                        p.CreateSettlement(settlement);
                        created = true;
                        break;
                    }
                if(!created)
                {
                    Vector3 startPosition = systemPosition;
                    startPosition.X += rnd.Next(4,7) * 60; //posizione iniziale del pianeta
                    string type = "Type" + rnd.Next(1, 10); //Tipo del pianeta, se in posizione fino a 6 è roccioso, altrimenti gassoso

                    Planet p = new Planet(true, 32, startPosition, systemPosition, type, startPosition.X - systemPosition.X);//Crea il pianeta
                    Settlement settlement = new Settlement(Settlement.SettlementType.CAPITAL, GameParams.religionType);
                    p.CreateSettlement(settlement);
                    planets.Add(p); //ed aggiungilo alla lista
                }
            }
        }
        static int ReturnLevelTypeForPowerUp(PlayerPowerUp.PowerUpType type, Settlement settlement)
        {
            int commerce = LevelManager.ActualLevel(settlement.CommerceLevel);
            int tecno = LevelManager.ActualLevel(settlement.TecnoLevel);
            int science = LevelManager.ActualLevel(settlement.ScienceLevel);

            int level = 1;
            switch (type)
            {
                case PlayerPowerUp.PowerUpType.CARGO:
                case PlayerPowerUp.PowerUpType.SHIELD:
                    level = commerce;
                    break;
                case PlayerPowerUp.PowerUpType.ENGINE:
                case PlayerPowerUp.PowerUpType.TERRAFORMER:
                    level = science;
                    break;
                case PlayerPowerUp.PowerUpType.LASER:
                case PlayerPowerUp.PowerUpType.ROCKET:
                    level = tecno;
                    break;

            }
            return level;
        }