Ejemplo n.º 1
0
        public ConstructionQueueListForm()
        {
            InitializeComponent();

            try { this.Icon = new Icon(FrEee.WinForms.Properties.Resources.FrEeeIcon); } catch { }

            RateMinerals.DefaultCellStyle.ForeColor     = Resource.Minerals.Color;
            RateOrganics.DefaultCellStyle.ForeColor     = Resource.Organics.Color;
            RateRadioactives.DefaultCellStyle.ForeColor = Resource.Radioactives.Color;

            // TODO - galaxy view background image can depend on galaxy template?
            galaxyView.BackgroundImage = Pictures.GetModImage(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Pictures", "UI", "Map", "quadrant"));
        }
Ejemplo n.º 2
0
        public Image GetIcon(string shipset)
        {
            // see if we have a positive number to use a sprite sheet
            int index = 0;

            int.TryParse(Name, out index);

            if (index > 0)
            {
                // use sprite sheets
                var   shipsetSpriteSheet = LoadShipsetSpriteSheet(shipset);
                Image spriteSheet;
                Point offset;
                if (shipsetSpriteSheet != null)
                {
                    // crop shipset sprite sheet
                    spriteSheet = shipsetSpriteSheet;
                    offset      = ShipsetSpriteOffset;
                }
                else if (GlobalSpriteSheet != null)
                {
                    // crop global sprite sheet
                    spriteSheet = GlobalSpriteSheet;
                    offset      = GlobalSpriteOffset;
                }
                else
                {
                    // no sprite sheets found
                    return(Pictures.GetModImage(
                               Path.Combine("Pictures", "Races", shipset, Name),
                               Path.Combine("Pictures", "Races", shipset, shipset + "_" + Name),
                               Path.Combine("Pictures", "Combat", Name)));
                }

                // make sprite
                var spritesAcross = (spriteSheet.Width - offset.X) / SpriteSize.Width;
                var num           = index - 1;
                var row           = num / spritesAcross;
                var col           = num % spritesAcross;
                var pos           = new Point(offset.X + SpriteSize.Width * col, offset.Y + SpriteSize.Height * row);
                return(spriteSheet.Crop(pos, SpriteSize));
            }
            else
            {
                // use individual sprites
                return(Pictures.GetModImage(
                           Path.Combine("Pictures", "Races", shipset, Name),
                           Path.Combine("Pictures", "Races", shipset, shipset + "_" + Name),
                           Path.Combine("Pictures", "Combat", Name)));
            }
        }
Ejemplo n.º 3
0
        public GameOverForm(bool victory)
        {
            InitializeComponent();

            if (victory)
            {
                Text      = "Victory!";
                pic.Image = Pictures.GetModImage(Path.Combine("Pictures", "Game", "Finale", "victory"));
                Music.Play(MusicMode.GameOver, MusicMood.Upbeat);
            }
            else
            {
                Text      = "Defeat!";
                pic.Image = Pictures.GetModImage(Path.Combine("Pictures", "Game", "Finale", "defeat"));
                Music.Play(MusicMode.GameOver, MusicMood.Sad);
            }
        }
Ejemplo n.º 4
0
        private void ShipListForm_Load(object sender, EventArgs e)
        {
            if (Galaxy.Current == null)
            {
                return;
            }

            // show ship/unit/fleet counts
            sobjs = Galaxy.Current.FindSpaceObjects <IMobileSpaceObject>().Where(o => !(o is Planet) && (!(o is IUnit && ((IUnit)o).Container == null)));
            var ours     = sobjs.Where(o => o.Owner == Empire.Current);
            var ourShips = ours.OfType <SpaceVehicle>();

            txtShips.Text = ourShips.Count().ToString();
            txtShipsOutsideFleets.Text = ourShips.Where(s => s.Container == null).Count().ToString();
            var ourFleets = ours.OfType <Fleet>();

            txtFleets.Text = ourFleets.Count().ToString();
            txtFleetsOutsideFleets.Text = ourFleets.Where(f => f.Container == null).Count().ToString();
            var alienShips = sobjs.OfType <SpaceVehicle>();

            txtAlienShips.Text      = alienShips.Count().ToString();
            txtAllyShips.Text       = alienShips.Where(s => s.Owner.IsAllyOf(Empire.Current, null)).Count().ToString();
            txtEnemyShips.Text      = alienShips.Where(s => s.Owner.IsEnemyOf(Empire.Current, null)).Count().ToString();
            txtNonAlignedShips.Text = alienShips.Where(s => s.Owner.IsNeutralTo(Empire.Current, null)).Count().ToString();

            resMaintenanaceMin.Amount = ourShips.Sum(s => s.MaintenanceCost[Resource.Minerals]);
            resMaintenanceOrg.Amount  = ourShips.Sum(s => s.MaintenanceCost[Resource.Organics]);
            resMaintenanceRad.Amount  = ourShips.Sum(s => s.MaintenanceCost[Resource.Radioactives]);

            // show ship/fleet/unit data
            grid.Data = sobjs.Where(o => o.Container == null).ToArray();
            grid.CreateDefaultGridConfig = ClientSettings.CreateDefaultShipListConfig;
            grid.LoadCurrentGridConfig   = () => ClientSettings.Instance.CurrentShipListConfig;
            grid.LoadGridConfigs         = () => ClientSettings.Instance.ShipListConfigs;
            grid.ResetGridConfigs        = () => new List <GridConfig> {
                ClientSettings.CreateDefaultShipListConfig(), ClientSettings.CreateDefaultAlienShipListConfig()
            };
            grid.Initialize();

            // show galaxy view background
            // TODO - galaxy view background image can depend on galaxy template?
            galaxyView.BackgroundImage = Pictures.GetModImage(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Pictures", "UI", "Map", "quadrant"));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Draws this planet's status icons on a picture.
        /// If the planet has special abilities (such as ruins), a ruins icon will be drawn.
        /// If the planet is uncolonized but colonizable with the current empire's technology, a colonizability circle will also be drawn:
        /// * Green for planets that and breathable by the current empire's primary race.
        /// * Yellow for planets that and breathable by any subjugated population.
        /// * Red for other colonizable planets.
        /// </summary>
        /// <param name="pic"></param>
        public void DrawStatusIcons(Image pic)
        {
            var g          = Graphics.FromImage(pic);
            var sizeFactor = 1f / 4f;
            var leftovers  = 1f - sizeFactor;

            if (IntrinsicAbilities.Any())
            {
                // draw ruins icon
                var path = Path.Combine("Pictures", "UI", "Map", "ruins");
                var img  = Pictures.GetModImage(path);
                if (img == null)
                {
                    throw new FileNotFoundException("Could not load ruins icon: " + Path.GetFullPath(path) + ".");
                }
                g.DrawImage(img, 0, 0, pic.Width * sizeFactor, pic.Height * sizeFactor);
            }
            if (Colony == null && Empire.Current != null && Empire.Current.UnlockedItems.OfType <ComponentTemplate>().Where(c => c.HasAbility(ColonizationAbilityName)).Any())
            {
                Brush brush;
                if (Atmosphere == Empire.Current.PrimaryRace.NativeAtmosphere)
                {
                    brush = Brushes.Green;
                }
                else if (
                    Empire.Current.ColonizedPlanets.Any(p => p.Colony.Population.Any(kvp => kvp.Key.NativeAtmosphere == Atmosphere)) ||
                    Empire.Current.OwnedSpaceObjects.OfType <ICargoContainer>().Any(cc => cc.Cargo.Population.Any(kvp => kvp.Key.NativeAtmosphere == Atmosphere))
                    )
                {
                    brush = Brushes.Yellow;
                }
                else
                {
                    brush = Brushes.Red;
                }
                g.DrawEllipse(new Pen(brush), pic.Width * leftovers - 1, 0, pic.Width * sizeFactor, pic.Height * sizeFactor);
                g.FillEllipse(brush, pic.Width * (leftovers + sizeFactor / 4f) - 1, pic.Width * sizeFactor / 4f, pic.Width * sizeFactor / 2f, pic.Height * sizeFactor / 2f);
            }
        }
Ejemplo n.º 6
0
 public Image LoadShipsetSpriteSheet(string shipset)
 {
     return(Pictures.GetModImage(Path.Combine("Pictures", "Races", shipset, ShipsetSpriteSheetName)));
 }
Ejemplo n.º 7
0
        private void PlanetListForm_Load(object sender, EventArgs e)
        {
            if (Galaxy.Current == null)
            {
                return;
            }

            // show planet counts
            var systems = Empire.Current.ExploredStarSystems;

            txtSystems.Text             = systems.Count().ToString();
            txtSystemsWithColonies.Text = systems.Where(s => s.FindSpaceObjects <Planet>(p => p.Owner == Empire.Current).Any()).Count().ToString();
            // HACK - why are there null explored star systems?
            planets         = systems.Where(sys => sys != null).SelectMany(sys => sys.FindSpaceObjects <Planet>());
            txtPlanets.Text = planets.Count().ToString();
            txtUs.Text      = Empire.Current.ColonizedPlanets.Count().ToString();
            var colonizable = planets.Where(p => p.Owner != Empire.Current && Empire.Current.CanColonize(p));

            txtColonizable.Text = colonizable.Count().ToString();
            txtEnemies.Text     = colonizable.Count(p => p.Owner != null && p.Owner.IsEnemyOf(Empire.Current, p.StarSystem)).ToString();
            txtAllies.Text      = colonizable.Count(p => p.Owner != null && p.Owner.IsAllyOf(Empire.Current, p.StarSystem)).ToString();
            txtNonAligned.Text  = colonizable.Count(p => p.Owner != null && p.Owner.IsNeutralTo(Empire.Current, p.StarSystem)).ToString();
            var uncolonized = colonizable.Where(p => p.Owner == null);

            txtUncolonized.Text  = uncolonized.Count().ToString();
            txtBreathableUs.Text = uncolonized.Where(p => p.Atmosphere == Empire.Current.PrimaryRace.NativeAtmosphere).Count().ToString();
            var otherAtmospheres = Empire.Current.ColonizedPlanets.SelectMany(p => p.Colony.Population).Select(kvp => kvp.Key.NativeAtmosphere).Distinct().Where(a => a != Empire.Current.PrimaryRace.NativeAtmosphere).Union(Empire.Current.OwnedSpaceObjects.OfType <ICargoContainer>().SelectMany(sobj => sobj.Cargo.Population.Keys.Select(r => r.NativeAtmosphere)).Distinct());

            txtBreathableOther.Text = uncolonized.Where(p => otherAtmospheres.Contains(p.Atmosphere)).Count().ToString();

            // show colony ship counts
            colonizers = Galaxy.Current.FindSpaceObjects <SpaceVehicle>(v =>
                                                                        v.Owner == Empire.Current &&
                                                                        (
                                                                            v.Abilities().Any(a => a.Rule.Name.StartsWith("Colonize Planet - "))
                                                                        ));
            txtShips.Text       = colonizers.Count().ToString();
            availableColonizers = colonizers.Where(v => v.Orders.Count == 0 && v.StrategicSpeed > 0);
            txtAvailable.Text   = availableColonizers.Count().ToString();

            // show population and resources
            txtPopulation.Text = Empire.Current.ColonizedPlanets.Sum(p => p.Colony.Population.Sum(kvp => kvp.Value)).ToUnitString(true);
            var stored  = Empire.Current.StoredResources;
            var income  = Empire.Current.NetIncomeLessConstruction;
            var storage = Empire.Current.ResourceStorage;

            resMin.Amount        = stored[Resource.Minerals];
            resMin.Change        = income[Resource.Minerals];
            resOrg.Amount        = stored[Resource.Organics];
            resOrg.Change        = income[Resource.Organics];
            resRad.Amount        = stored[Resource.Radioactives];
            resRad.Change        = income[Resource.Radioactives];
            resRes.Amount        = income[Resource.Research];
            resInt.Amount        = income[Resource.Intelligence];
            resStorageMin.Amount = storage[Resource.Minerals];
            resStorageOrg.Amount = storage[Resource.Organics];
            resStorageRad.Amount = storage[Resource.Radioactives];

            // show planet data
            grid.Data = planets.ToArray();
            grid.CreateDefaultGridConfig = ClientSettings.CreateDefaultPlanetListConfig;
            grid.LoadCurrentGridConfig   = () => ClientSettings.Instance.CurrentPlanetListConfig;
            grid.LoadGridConfigs         = () => ClientSettings.Instance.PlanetListConfigs;
            grid.ResetGridConfigs        = () => new List <GridConfig> {
                ClientSettings.CreateDefaultPlanetListConfig(), ClientSettings.CreateDefaultColonyPlanetListConfig()
            };
            grid.Initialize();

            // show galaxy view background
            // TODO - galaxy view background image can depend on galaxy template?
            galaxyView.BackgroundImage = Pictures.GetModImage(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Pictures", "UI", "Map", "quadrant"));
        }