AddShips() public method

public AddShips ( Ship ship, int amount ) : void
ship Ship
amount int
return void
示例#1
0
 public void CheckForBuiltShips()
 {
     foreach (Planet planet in PlanetManager.Planets)
     {
         int  amount;
         Ship result = planet.CheckIfShipBuilt(out amount);
         if (amount > 0 && result != null)
         {
             Fleet newFleet = new Fleet();
             newFleet.Empire         = this;
             newFleet.GalaxyX        = planet.System.X;
             newFleet.GalaxyY        = planet.System.Y;
             newFleet.AdjacentSystem = planet.System;
             newFleet.AddShips(result, amount);
             FleetManager.AddFleet(newFleet);
             SitRepManager.AddItem(new SitRepItem(Screen.Galaxy, planet.System, planet, new Point(planet.System.X, planet.System.Y), planet.Name + " has produced " + amount + " " + result.Name + " ship" + (amount > 1 ? "s." : ".")));
         }
     }
     FleetManager.MergeIdleFleets();
 }
示例#2
0
        public void SplitFleet(Empire empire)
        {
            Fleet fleet = new Fleet();

            fleet.Empire         = FleetToSplit.Empire;
            fleet.GalaxyX        = FleetToSplit.GalaxyX;
            fleet.GalaxyY        = FleetToSplit.GalaxyY;
            fleet.AdjacentSystem = FleetToSplit.AdjacentSystem;

            foreach (KeyValuePair <Ship, int> ship in FleetToSplit.Ships)
            {
                if (ship.Value > 0)
                {
                    SelectedFleet.SubtractShips(ship.Key, ship.Value);
                    fleet.AddShips(ship.Key, ship.Value);
                }
            }
            foreach (var transport in FleetToSplit.TransportShips)
            {
                if (transport.amount > 0)
                {
                    SelectedFleet.SubtractTransport(transport.raceOnShip, transport.amount);
                    fleet.AddTransport(transport.raceOnShip, transport.amount);
                }
            }
            SelectedFleet.ClearEmptyShips();
            fleet.ClearEmptyShips();
            fleet.TravelNodes = FleetToSplit.TravelNodes;
            if (SelectedFleet.Ships.Count == 0 && SelectedFleet.TransportShips.Count == 0)
            {
                Fleets.Remove(SelectedFleet);
                empire.FleetManager.RemoveFleet(SelectedFleet);
            }
            if (fleet.Ships.Count > 0 || fleet.TransportShips.Count > 0)
            {
                Fleets.Add(fleet);
                empire.FleetManager.AddFleet(fleet);
            }
            SelectedFleet = fleet;
        }
示例#3
0
        public void SplitFleet(Empire empire)
        {
            Fleet fleet = new Fleet();
            fleet.Empire = FleetToSplit.Empire;
            fleet.GalaxyX = FleetToSplit.GalaxyX;
            fleet.GalaxyY = FleetToSplit.GalaxyY;
            fleet.AdjacentSystem = FleetToSplit.AdjacentSystem;

            foreach (KeyValuePair<Ship, int> ship in FleetToSplit.Ships)
            {
                if (ship.Value > 0)
                {
                    SelectedFleet.SubtractShips(ship.Key, ship.Value);
                    fleet.AddShips(ship.Key, ship.Value);
                }
            }
            foreach (var transport in FleetToSplit.TransportShips)
            {
                if (transport.amount > 0)
                {
                    SelectedFleet.SubtractTransport(transport.raceOnShip, transport.amount);
                    fleet.AddTransport(transport.raceOnShip, transport.amount);
                }
            }
            SelectedFleet.ClearEmptyShips();
            fleet.ClearEmptyShips();
            fleet.TravelNodes = FleetToSplit.TravelNodes;
            if (SelectedFleet.Ships.Count == 0 && SelectedFleet.TransportShips.Count == 0)
            {
                Fleets.Remove(SelectedFleet);
                empire.FleetManager.RemoveFleet(SelectedFleet);
            }
            if (fleet.Ships.Count > 0 || fleet.TransportShips.Count > 0)
            {
                Fleets.Add(fleet);
                empire.FleetManager.AddFleet(fleet);
            }
            SelectedFleet = fleet;
        }
示例#4
0
        public void SelectFleet(int whichFleet)
        {
            if (whichFleet < Fleets.Count)
            {
                SelectedFleet = Fleets[whichFleet];

                FleetToSplit = new Fleet();
                FleetToSplit.Empire = SelectedFleet.Empire;
                FleetToSplit.TravelNodes = SelectedFleet.TravelNodes;
                FleetToSplit.TentativeNodes = SelectedFleet.TentativeNodes;
                FleetToSplit.AdjacentSystem = SelectedFleet.AdjacentSystem;
                FleetToSplit.GalaxyX = SelectedFleet.GalaxyX;
                FleetToSplit.GalaxyY = SelectedFleet.GalaxyY;
                foreach (KeyValuePair<Ship, int> ship in SelectedFleet.Ships)
                {
                    FleetToSplit.AddShips(ship.Key, ship.Value);
                }
                foreach (var transport in SelectedFleet.TransportShips)
                {
                    FleetToSplit.AddTransport(transport.raceOnShip, transport.amount);
                }
            }
        }
示例#5
0
        public void SelectFleet(int whichFleet)
        {
            if (whichFleet < Fleets.Count)
            {
                SelectedFleet = Fleets[whichFleet];

                FleetToSplit                = new Fleet();
                FleetToSplit.Empire         = SelectedFleet.Empire;
                FleetToSplit.TravelNodes    = SelectedFleet.TravelNodes;
                FleetToSplit.TentativeNodes = SelectedFleet.TentativeNodes;
                FleetToSplit.AdjacentSystem = SelectedFleet.AdjacentSystem;
                FleetToSplit.GalaxyX        = SelectedFleet.GalaxyX;
                FleetToSplit.GalaxyY        = SelectedFleet.GalaxyY;
                foreach (KeyValuePair <Ship, int> ship in SelectedFleet.Ships)
                {
                    FleetToSplit.AddShips(ship.Key, ship.Value);
                }
                foreach (var transport in SelectedFleet.TransportShips)
                {
                    FleetToSplit.AddTransport(transport.raceOnShip, transport.amount);
                }
            }
        }
示例#6
0
 public void CheckForBuiltShips()
 {
     foreach (Planet planet in PlanetManager.Planets)
     {
         int amount;
         Ship result = planet.CheckIfShipBuilt(out amount);
         if (amount > 0 && result != null)
         {
             Fleet newFleet = new Fleet();
             newFleet.Empire = this;
             newFleet.GalaxyX = planet.System.X;
             newFleet.GalaxyY = planet.System.Y;
             newFleet.AdjacentSystem = planet.System;
             newFleet.AddShips(result, amount);
             FleetManager.AddFleet(newFleet);
             SitRepManager.AddItem(new SitRepItem(Screen.Galaxy, planet.System, planet, new Point(planet.System.X, planet.System.Y), planet.Name + " has produced " + amount + " " + result.Name + " ship" + (amount > 1 ? "s." : ".")));
         }
     }
     FleetManager.MergeIdleFleets();
 }
示例#7
0
        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);
        }
示例#8
0
        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);
        }