Exemplo n.º 1
0
        public void SelectGroup(ShipGroupInfo group, long quantity, double population)
        {
            if (group == null)
            {
                throw new ArgumentNullException(nameof(group));
            }

            quantity = Methods.Clamp(quantity, 0, group.Quantity);
            if (quantity <= 0)
            {
                this.DeselectGroup(group);
                return;
            }

            var minPopulation = group.Population - (group.Quantity - quantity) * group.Design.ColonizerPopulation;

            population = Methods.Clamp(population, minPopulation, group.Population);

            this.selection[group.Data.Design] = new ShipSelection(quantity, this.selection[group.Data.Design].Ships, population);
            this.calcCarriers();

            if (!this.CanMove)
            {
                this.simulationWaypoints.Clear();
            }

            this.calcSimulation();
        }
Exemplo n.º 2
0
        public void DeselectGroup(ShipGroupInfo group)
        {
            this.selection[group.Data.Design] = new ShipSelection(0, this.selection[group.Data.Design].Ships, 0);

            if (!this.CanMove)
            {
                this.simulationWaypoints.Clear();
            }
        }
Exemplo n.º 3
0
        public void DeselectGroup(ShipGroupInfo group)
        {
            selection.Remove(group.Data.Design);

            if (!this.CanMove)
            {
                this.simulationWaypoints.Clear();
            }
        }
Exemplo n.º 4
0
        public long SelectionCount(ShipGroupInfo group)
        {
            if (group == null)
            {
                throw new ArgumentNullException(nameof(group));
            }

            return(this.selection[group.Data.Design].Quantity);
        }
Exemplo n.º 5
0
        public void SelectGroup(ShipGroupInfo group, long quantity)
        {
            if (group == null)
            {
                throw new ArgumentNullException(nameof(group));
            }

            this.SelectGroup(group, quantity, group.Population * quantity / (double)group.Quantity);
        }
Exemplo n.º 6
0
        public double SelectionPopulation(ShipGroupInfo group)
        {
            if (group == null)
            {
                throw new ArgumentNullException(nameof(group));
            }

            return(this.selection[group.Data.Design].Population);
        }
Exemplo n.º 7
0
        public void SetData(ShipGroupInfo groupInfo, PlayerInfo owner)
        {
            this.Data = groupInfo;

            var thousandsFormat = new ThousandsFormatter();

            this.hullThumbnail.Image     = ImageCache.Get[groupInfo.Design.ImagePath];
            this.hullThumbnail.BackColor = owner.Color;
            this.quantityLabel.Text      = this.Data.Design.Name + Environment.NewLine + thousandsFormat.Format(groupInfo.Quantity);
        }
Exemplo n.º 8
0
        private string shipGroupText(ShipGroupInfo group)
        {
            var selected = this.selectedFleetControl.SelectionCount(group);

            if (selected == 0 || selected == group.Quantity)
            {
                return(group.Design.Name + Environment.NewLine + new ThousandsFormatter().Format(group.Quantity));
            }

            var thousandsFormat = new ThousandsFormatter(group.Quantity);

            return(group.Design.Name + Environment.NewLine +
                   thousandsFormat.Format(selected) + " / " + thousandsFormat.Format(group.Quantity));
        }
Exemplo n.º 9
0
        public void DeselectGroup(ShipGroupInfo group)
        {
            if (group == null)
            {
                throw new ArgumentNullException(nameof(group));
            }

            this.selection[group.Data.Design] = new ShipSelection(0, this.selection[group.Data.Design].Ships, 0);
            this.calcCarriers();

            if (!this.CanMove)
            {
                this.simulationWaypoints.Clear();
            }
        }
Exemplo n.º 10
0
        public bool IsTowed(ShipGroupInfo group)
        {
            if (group == null)
            {
                throw new ArgumentNullException(nameof(group));
            }

            var selected = this.selectedCount(group.Design.Data);

            if (selected == 0 || group.Design.Data.IsDrive != null)
            {
                return(false);
            }

            return(this.carriedSelection.ContainsKey(group.Design.Data) && this.CanMove);
        }
Exemplo n.º 11
0
        public bool IsCarried(ShipGroupInfo group)
        {
            if (group == null)
            {
                throw new ArgumentNullException(nameof(group));
            }

            var selected = this.selectedCount(group.Design.Data);

            if (selected == 0)
            {
                return(false);
            }

            return(!this.carriedSelection.TryGetValue(group.Design.Data, out var uncarried) || uncarried < selected);
        }
Exemplo n.º 12
0
        public void SelectGroup(ShipGroupInfo group, long quantity)
        {
            quantity = Methods.Clamp(quantity, 0, this.Fleet.FleetData.Ships.WithDesign[group.Data.Design].Quantity);
            selection[group.Data.Design] = quantity;

            if (selection[group.Data.Design] <= 0)
            {
                selection.Remove(group.Data.Design);
            }

            if (!this.CanMove)
            {
                this.simulationWaypoints.Clear();
            }

            this.calcEta();
        }
Exemplo n.º 13
0
        private IEnumerable <Sprite> shipImages(ShipGroupInfo x)
        {
            yield return(new Sprite(GalaxyTextures.Get.Sprite(x.Design.ImagePath)));

            var traits = new List <TextureInfo>();

            if (this.selectedFleetControl.IsCarried(x))
            {
                traits.Add(GalaxyTextures.Get.Hangar);
            }
            if (this.selectedFleetControl.IsTowed(x))
            {
                traits.Add(GalaxyTextures.Get.Tow);
            }

            for (int i = 0; i < traits.Count; i++)
            {
                yield return(new Sprite(
                                 traits[i],
                                 Color.White,
                                 Matrix4.CreateScale(0.3f, 0.3f, 1) * Matrix4.CreateTranslation(0.3f, -0.3f + i * 0.35f, 0)));
            }
        }
Exemplo n.º 14
0
 public double SelectionPopulation(ShipGroupInfo group)
 {
     return(this.selection[group.Data.Design].Population);
 }
Exemplo n.º 15
0
 public long SelectionCount(ShipGroupInfo group)
 {
     return(this.selection[group.Data.Design].Quantity);
 }
Exemplo n.º 16
0
 public void SelectGroup(ShipGroupInfo group, long quantity)
 {
     this.SelectGroup(group, quantity, group.Population * quantity / (double)group.Quantity);
 }