Ejemplo n.º 1
0
        private void UpdateCargoContainer(ref ProgressBarGame progressBar, CargoBayGroup cargoBays, string name, Color color)
        {
            double damagePercent         = 0d;
            Tuple <double, double> cargo = null;

            if (cargoBays != null)
            {
                cargo         = cargoBays.CargoVolume;
                damagePercent = cargoBays.DamagePercent;
            }

            if (cargo != null && cargo.Item2 > 0d)
            {
                if (progressBar != null)
                {
                    progressBar.Maximum        = cargo.Item2;
                    progressBar.Value          = cargo.Item1;
                    progressBar.DamagedPercent = damagePercent;
                }
                else
                {
                    progressBar = CreateProgressBar(cargo.Item1, cargo.Item2, damagePercent, name, color);
                }
            }
            else if (progressBar != null)
            {
                _panel.Children.Remove(progressBar);
                progressBar = null;
            }
        }
Ejemplo n.º 2
0
        private void UpdateStandardContainer(ref ProgressBarGame progressBar, IContainer container, string name, Color color)
        {
            #region damage %

            double damagePercent = 0d;
            if (container != null)
            {
                if (container is ContainerGroup)
                {
                    damagePercent = ((ContainerGroup)container).DamagePercent;
                }
                else if (container is ITakesDamage && ((ITakesDamage)container).IsDestroyed)
                {
                    damagePercent = 1d;
                }
            }

            #endregion

            if (progressBar != null && container != null)
            {
                progressBar.Maximum        = container.QuantityMax;
                progressBar.Value          = container.QuantityCurrent;
                progressBar.DamagedPercent = damagePercent;
            }
            else if (progressBar == null && container != null)
            {
                progressBar = CreateProgressBar(container.QuantityCurrent, container.QuantityMax, damagePercent, name, color);
            }
            else if (progressBar != null && container == null)
            {
                _panel.Children.Remove(progressBar);
                progressBar = null;
            }
        }
Ejemplo n.º 3
0
        private static void ProgressColorChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            ProgressBarGame senderCast = sender as ProgressBarGame;

            if (senderCast == null)
            {
                return;         // this should never happen
            }

            Color color = (Color)e.NewValue;

            // Turn the color into a slight gradient
            LinearGradientBrush brush = new LinearGradientBrush();

            brush.StartPoint = new Point(0, 0);
            brush.EndPoint   = new Point(0, 1);

            GradientStopCollection gradients = new GradientStopCollection();

            gradients.Add(new GradientStop(UtilityWPF.AlphaBlend(Colors.White, color, .5d), 0d));
            gradients.Add(new GradientStop(UtilityWPF.AlphaBlend(Colors.White, color, .25d), .1d));
            gradients.Add(new GradientStop(color, .4d));
            gradients.Add(new GradientStop(UtilityWPF.AlphaBlend(Colors.Black, color, .2d), .9d));
            gradients.Add(new GradientStop(UtilityWPF.AlphaBlend(Colors.Black, color, .25d), 1d));
            brush.GradientStops = gradients;

            // The progress bar is actually tied to this property
            senderCast.ProgressBrush = brush;
        }
Ejemplo n.º 4
0
        protected virtual void ClearProgressBars()
        {
            _energy = null;
            _fuel   = null;
            _plasma = null;
            _cargo  = null;
            _ammo   = null;

            _panel.Children.Clear();
        }
Ejemplo n.º 5
0
        protected ProgressBarGame CreateProgressBar(double quantityCurrent, double quantityMax, double damagePercent, string name, Color color)
        {
            ProgressBarGame retVal = new ProgressBarGame
            {
                RightLabelVisibility = Visibility.Visible,
                RightLabelText       = name,
                Foreground           = this.Foreground,
                ProgressColor        = color,

                Minimum        = 0,
                Maximum        = quantityMax,
                Value          = quantityCurrent,
                DamagedPercent = damagePercent
            };

            _panel.Children.Add(retVal);

            return(retVal);
        }
        private void UpdateCargoContainer(ref ProgressBarGame progressBar, CargoBayGroup cargoBays, string name, Color color)
        {
            double damagePercent = 0d;
            Tuple<double, double> cargo = null;
            if (cargoBays != null)
            {
                cargo = cargoBays.CargoVolume;
                damagePercent = cargoBays.DamagePercent;
            }

            if (cargo != null && cargo.Item2 > 0d)
            {
                if (progressBar != null)
                {
                    progressBar.Maximum = cargo.Item2;
                    progressBar.Value = cargo.Item1;
                    progressBar.DamagedPercent = damagePercent;
                }
                else
                {
                    progressBar = CreateProgressBar(cargo.Item1, cargo.Item2, damagePercent, name, color);
                }
            }
            else if (progressBar != null)
            {
                _panel.Children.Remove(progressBar);
                progressBar = null;
            }

        }
        private void UpdateStandardContainer(ref ProgressBarGame progressBar, IContainer container, string name, Color color)
        {
            #region damage %

            double damagePercent = 0d;
            if (container != null)
            {
                if (container is ContainerGroup)
                {
                    damagePercent = ((ContainerGroup)container).DamagePercent;
                }
                else if (container is ITakesDamage && ((ITakesDamage)container).IsDestroyed)
                {
                    damagePercent = 1d;
                }
            }

            #endregion

            if (progressBar != null && container != null)
            {
                progressBar.Maximum = container.QuantityMax;
                progressBar.Value = container.QuantityCurrent;
                progressBar.DamagedPercent = damagePercent;
            }
            else if (progressBar == null && container != null)
            {
                progressBar = CreateProgressBar(container.QuantityCurrent, container.QuantityMax, damagePercent, name, color);
            }
            else if (progressBar != null && container == null)
            {
                _panel.Children.Remove(progressBar);
                progressBar = null;
            }
        }
        protected ProgressBarGame CreateProgressBar(double quantityCurrent, double quantityMax, double damagePercent, string name, Color color)
        {
            ProgressBarGame retVal = new ProgressBarGame();
            retVal.RightLabelVisibility = Visibility.Visible;
            retVal.RightLabelText = name;
            retVal.Foreground = this.Foreground;
            retVal.ProgressColor = color;

            retVal.Minimum = 0;
            retVal.Maximum = quantityMax;
            retVal.Value = quantityCurrent;
            retVal.DamagedPercent = damagePercent;

            _panel.Children.Add(retVal);

            return retVal;
        }
        protected virtual void ClearProgressBars()
        {
            _energy = null;
            _fuel = null;
            _plasma = null;
            _cargo = null;
            _ammo = null;

            _panel.Children.Clear();
        }