Beyond_Beyaan.FleetManager.SetupStarterFleet C# (CSharp) Метод

SetupStarterFleet() публичный Метод

public SetupStarterFleet ( StarSystem homeSystem ) : void
homeSystem StarSystem
Результат void
        public void SetupStarterFleet(StarSystem homeSystem)
        {
            Technology retroEngine = null;
            Technology titaniumArmor = null;
            Technology laser = null;
            Technology nuclearMissile = null;
            Technology nuclearBomb = null;

            foreach (var tech in _empire.TechnologyManager.ResearchedPropulsionTechs)
            {
                if (tech.Speed == 1)
                {
                    retroEngine = tech;
                    break;
                }
            }
            foreach (var tech in _empire.TechnologyManager.ResearchedConstructionTechs)
            {
                if (tech.Armor == Technology.TITANIUM_ARMOR)
                {
                    titaniumArmor = tech;
                    break;
                }
            }
            foreach (var tech in _empire.TechnologyManager.ResearchedWeaponTechs)
            {
                if (tech.TechName == "Laser")
                {
                    laser = tech;
                }
                else if (tech.TechName == "Nuclear Missile")
                {
                    nuclearMissile = tech;
                }
                else if (tech.TechName == "Nuclear Bomb")
                {
                    nuclearBomb = tech;
                }
            }
            Ship scout = new Ship();
            scout.Name = "Scout";
            scout.Owner = _empire;
            scout.Size = Ship.SMALL;
            scout.WhichStyle = 0;
            scout.Armor = new Equipment(titaniumArmor, false);
            foreach (var tech in _empire.TechnologyManager.ResearchedConstructionTechs)
            {
                if (tech.ReserveFuelTanks)
                {
                    scout.Specials[0] = new Equipment(tech, false);
                    break;
                }
            }
            scout.Engine = new KeyValuePair<Equipment, float>(new Equipment(retroEngine, false), scout.PowerUsed / (retroEngine.Speed * 10));
            scout.DesignID = _currentShipDesignID;
            CurrentDesigns.Add(scout);
            _currentShipDesignID++;

            Ship fighter = new Ship();
            fighter.Name = "Fighter";
            fighter.Owner = _empire;
            fighter.Size = Ship.SMALL;
            fighter.WhichStyle = 1;
            fighter.Weapons[0] = new KeyValuePair<Equipment, int>(new Equipment(laser, false), 1);
            fighter.Armor = new Equipment(titaniumArmor, false);
            fighter.Engine = new KeyValuePair<Equipment, float>(new Equipment(retroEngine, false), fighter.PowerUsed / (retroEngine.Speed * 10));
            CurrentDesigns.Add(fighter);
            _currentShipDesignID++;

            Ship destroyer = new Ship();
            destroyer.Name = "Destroyer";
            destroyer.Owner = _empire;
            destroyer.Size = Ship.MEDIUM;
            destroyer.WhichStyle = 0;
            destroyer.Weapons[0] = new KeyValuePair<Equipment, int>(new Equipment(nuclearMissile, false), 1);
            destroyer.Weapons[1] = new KeyValuePair<Equipment, int>(new Equipment(laser, false), 3);
            destroyer.Armor = new Equipment(titaniumArmor, false);
            destroyer.Engine = new KeyValuePair<Equipment, float>(new Equipment(retroEngine, false), destroyer.PowerUsed / (retroEngine.Speed * 10));
            CurrentDesigns.Add(destroyer);
            _currentShipDesignID++;

            Ship bomber = new Ship();
            bomber.Name = "Bomber";
            bomber.Owner = _empire;
            bomber.Size = Ship.MEDIUM;
            bomber.WhichStyle = 1;
            bomber.Weapons[0] = new KeyValuePair<Equipment, int>(new Equipment(nuclearBomb, false), 2);
            bomber.Weapons[1] = new KeyValuePair<Equipment, int>(new Equipment(laser, false), 2);
            bomber.Armor = new Equipment(titaniumArmor, false);
            bomber.Engine = new KeyValuePair<Equipment, float>(new Equipment(retroEngine, false), bomber.PowerUsed / (retroEngine.Speed * 10));
            CurrentDesigns.Add(bomber);
            _currentShipDesignID++;

            Ship colonyShip = new Ship();
            colonyShip.Name = "Colony Ship";
            colonyShip.Owner = _empire;
            colonyShip.Size = Ship.LARGE;
            colonyShip.WhichStyle = 0;
            colonyShip.Armor = new Equipment(titaniumArmor, false);
            foreach (var tech in _empire.TechnologyManager.ResearchedPlanetologyTechs)
            {
                if (tech.Colony == Technology.STANDARD_COLONY)
                {
                    colonyShip.Specials[0] = new Equipment(tech, false);
                    break;
                }
            }
            colonyShip.Engine = new KeyValuePair<Equipment, float>(new Equipment(retroEngine, false), colonyShip.PowerUsed / (retroEngine.Speed * 10));
            colonyShip.DesignID = _currentShipDesignID;
            CurrentDesigns.Add(colonyShip);
            _currentShipDesignID++;

            LastShipDesign = new Ship(scout); //Make a copy so we don't accidentally modify the original ship

            Fleet starterFleet = new Fleet();
            starterFleet.GalaxyX = homeSystem.X;
            starterFleet.GalaxyY = homeSystem.Y;
            starterFleet.AdjacentSystem = homeSystem;
            starterFleet.Empire = _empire;
            starterFleet.AddShips(CurrentDesigns[0], 2);
            starterFleet.AddShips(CurrentDesigns[4], 1);
            _fleets.Add(starterFleet);
        }

Usage Example

Пример #1
0
 public void SetHomeSystem(StarSystem homeSystem, Planet homePlanet)
 {
     selectedSystem     = homeSystem;
     lastSelectedSystem = homeSystem;
     PlanetManager.AddOwnedPlanet(homePlanet);
     FleetManager.SetupStarterFleet(homeSystem);
     homePlanet.ShipBeingBuilt = FleetManager.CurrentDesigns[0];
     homePlanet.SetCleanup();
     homePlanet.UpdateOutputs();
 }