public ConverterRadiationToEnergyToolItem(EditorOptions options, SolarPanelShape shape)
     : base(options)
 {
     this.Shape = shape;
     this.TabName = PartToolItemBase.TAB_SHIPPART;
     _visual2D = PartToolItemBase.GetVisual2D(this.Name, this.Description, options, this);
 }
Пример #2
0
 public EditShipTransfer(Player player, SpaceDockPanel spaceDock, Editor editor, EditorOptions editorOptions, World world, int material_Ship, Map map, ShipExtraArgs shipExtra)
 {
     _player = player;
     _spaceDock = spaceDock;
     _editor = editor;
     _editorOptions = editorOptions;
     _world = world;
     _material_Ship = material_Ship;
     _map = map;
     _shipExtra = shipExtra;
 }
Пример #3
0
        public NPCNest(NPCNestDNA dna, double radius, World world, Map map, KeepItems2D keepItems2D, MaterialIDs materialIDs, Viewport3D viewport, EditorOptions editorOptions, ItemOptionsArco itemOptions, IGravityField gravity, DragHitShape dragPlane)
        {
            // Store stuff
            _world = world;
            _map = map;
            _keepItems2D = keepItems2D;
            _materialIDs = materialIDs;
            _viewport = viewport;
            _editorOptions = editorOptions;
            _itemOptions = itemOptions;
            _gravity = gravity;
            _dragPlane = dragPlane;

            // DNA
            NPCNestDNA fixedDNA = GetFinalDNA(dna);
            _shellColors = fixedDNA.ShellColors;
            _botDNA = fixedDNA.BotDNA;
            _weaponDNA = fixedDNA.WeaponDNA;

            //TODO: Hand this a winner list, and filter criteria
            _dreamer = new EvolutionDreamer(_itemOptions, _shellColors, 4);     //TODO: Num bots should come from item options
            _dreamer.WeaponDNA = EvolutionDreamer.GetRandomDNA().Item2;

            #region WPF Model

            var models = GetModel(_shellColors, radius);
            this.Model = models.Item1;
            _eggModels = models.Item2;

            _rotateTransform = new QuaternionRotation3D();
            _translateTransform = new TranslateTransform3D();

            Transform3DGroup transform = new Transform3DGroup();
            transform.Children.Add(new RotateTransform3D(_rotateTransform));
            transform.Children.Add(_translateTransform);

            ModelVisual3D visual = new ModelVisual3D();
            visual.Transform = transform;
            visual.Content = this.Model;

            this.Visuals3D = new Visual3D[] { visual };

            #endregion

            // Energy tank
            _energy = new Container();
            _energy.QuantityMax = _itemOptions.Nest_Energy_Max * radius;
            _energy.QuantityCurrent = _energy.QuantityMax * .5d;

            // Finish
            this.Token = TokenGenerator.NextToken();
            this.Radius = radius;
            this.CreationTime = DateTime.UtcNow;
        }
Пример #4
0
        public ThrusterToolItem(EditorOptions options, Vector3D[] directions, string name)
            : base(options)
        {
            this.ThrusterType = ThrusterType.Custom;

            _subName = name;
            _directions = directions;

            this.TabName = PartToolItemBase.TAB_SHIPPART;

            _visual2D = PartToolItemBase.GetVisual2D(this.Name, this.Description, options, this);
        }
Пример #5
0
        public ThrusterToolItem(EditorOptions options, ThrusterType thrusterType)
            : base(options)
        {
            if (thrusterType == ThrusterType.Custom)
            {
                throw new ArgumentException("Can't pass custom into this overload");
            }

            this.ThrusterType = thrusterType;

            _subName = thrusterType.ToString().ToLower().Replace('_', ' ');
            _directions = null;

            this.TabName = PartToolItemBase.TAB_SHIPPART;

            _visual2D = PartToolItemBase.GetVisual2D(this.Name, this.Description, options, this);
        }
Пример #6
0
        public Icon3D(ShipPartDNA dna, EditorOptions options)
        {
            InitializeComponent();

            // Need to set position to zero, or the image won't be centered (part's model considers position/orientation)
            dna = ShipPartDNA.Clone(dna);
            dna.Position = new Point3D();
            dna.Orientation = Quaternion.Identity;

            PartDesignBase part = BotConstructor.GetPartDesign(dna, options, false);

            this.ItemName = part.PartType;
            this.Part = part;

            lblName.Text = this.ItemName;

            lblName.Visibility = _showName ? Visibility.Visible : Visibility.Collapsed;

            InitializeTrackball();

            RenderPart();
            InitializeLight();
        }
        public void SetInventory(Inventory inventory, string name, decimal credits, double? creditsPercent, double? volumePercent, World world, string[] actionButtons, EditorOptions options)
        {
            // Icon
            pnlIcon.Content = BuildIcon(inventory, world, options, this);

            // Name
            lblName.Text = name;

            if (inventory.Count == 1)
            {
                lblMultipleX.Visibility = Visibility.Collapsed;
                lblMultiple.Visibility = Visibility.Collapsed;
            }
            else
            {
                lblMultipleX.Visibility = Visibility.Visible;
                lblMultiple.Visibility = Visibility.Visible;
                lblMultiple.Text = inventory.Count.ToString("N0");
            }

            // Price
            lblPrice.Text = credits.ToString("N0");
            if (creditsPercent == null)
            {
                lblPricePercent.Visibility = Visibility.Collapsed;
            }
            else
            {
                lblPricePercent.Text = GetPercentText(creditsPercent.Value);
            }

            // Volume
            lblVolume.Text = Math.Round(inventory.Volume, 2).ToString();
            if (volumePercent == null)
            {
                lblVolumePercent.Visibility = Visibility.Collapsed;
            }
            else
            {
                lblVolumePercent.Text = GetPercentText(volumePercent.Value);
            }

            // Mass
            //lblMass.Text = Math.Round(inventory.Mass, 2).ToString();
            lblMass.Text = inventory.Mass.ToStringSignificantDigits(2);

            // Action Buttons
            pnlActionButtons.Children.Clear();

            switch (actionButtons.Length)
            {
                case 2:
                case 4:
                    pnlActionButtons.Columns = 2;
                    break;

                default:
                    pnlActionButtons.Columns = 3;
                    break;
            }

            pnlActionButtons.Rows = Convert.ToInt32(Math.Ceiling(actionButtons.Length / Convert.ToDouble(pnlActionButtons.Columns)));

            foreach (string action in actionButtons)
            {
                pnlActionButtons.Children.Add(new Button()
                {
                    Content = action
                });
            }

            // Store props
            this.Inventory = inventory;
            this.InventoryName = name;
            this.Credits = credits;
        }
Пример #8
0
 public ShieldEnergyDesign(EditorOptions options, bool isFinalModel)
     : base(options, isFinalModel) { }
Пример #9
0
 public DesignPart(EditorOptions options)
 {
     _options = options;
 }
        private static Icon3D BuildIcon(Inventory inventory, World world, EditorOptions options, FrameworkElement parent)
        {
            Icon3D retVal = null;

            if (inventory.Ship != null)
            {
                retVal = new Icon3D("", inventory.Ship, world);       // don't want to autorotate the ship icons.  This is a 2D game, and the ships will always be viewed from the top
            }
            else if (inventory.Part != null)
            {
                retVal = new Icon3D(inventory.Part, options)
                {
                    AutoRotateOnMouseHover = true,
                    AutoRotateParent = parent,
                };
            }
            else if (inventory.Mineral != null)
            {
                retVal = new Icon3D(inventory.Mineral.MineralType)
                {
                    AutoRotateOnMouseHover = true,
                    AutoRotateParent = parent,
                };
            }

            if (retVal != null)
            {
                retVal.ShowName = false;
                retVal.ShowBorder = false;
            }

            return retVal;
        }
Пример #11
0
 public ShieldKineticDesign(EditorOptions options, bool isFinalModel)
     : base(options, isFinalModel) { }
Пример #12
0
        public EnergyTank(EditorOptions options, ItemOptions itemOptions, ShipPartDNA dna)
            : base(options, dna, itemOptions.EnergyTank_Damage.HitpointMin, itemOptions.EnergyTank_Damage.HitpointSlope, itemOptions.EnergyTank_Damage.Damage)
        {
            _itemOptions = itemOptions;

            this.Design = new EnergyTankDesign(options, true);
            this.Design.SetDNA(dna);

            double radius;
            _container = GetContainer(out _scaleActual, out radius, itemOptions, dna);

            this.Radius = radius;

            _mass = _container.QuantityMax * itemOptions.EnergyTank_Density;

            _neuron = new Neuron_SensorPosition(new Point3D(0, 0, 0), false);

            this.Destroyed += EnergyTank_Destroyed;
        }
Пример #13
0
 public BrainRGBRecognizerDesign(EditorOptions options, bool isFinalModel)
     : base(options, isFinalModel) { }
Пример #14
0
        public BrainRGBRecognizer(EditorOptions options, ItemOptions itemOptions, BrainRGBRecognizerDNA dna, IContainer energyTanks)
            : base(options, dna, itemOptions.Brain_Damage.HitpointMin, itemOptions.Brain_Damage.HitpointSlope, itemOptions.Brain_Damage.Damage)
        {
            _itemOptions = itemOptions;
            _energyTanks = energyTanks;

            this.Design = new BrainRGBRecognizerDesign(options, true);
            this.Design.SetDNA(dna);

            _dnaExtra = dna.Extra ?? BrainRGBRecognizerDNAExtra.GetDefaultDNA();

            _isColor = _dnaExtra.IsColor;
            _finalResolution = _dnaExtra.FinalResolution;
            if (_dnaExtra.UseEdgeDetect)
            {
                _convolution = Convolutions.GetEdgeSet_Sobel();
            }
            else
            {
                _convolution = null;
            }

            _somDiscardDupes = _dnaExtra.ShouldSOMDiscardDupes;
            _somIsColor = _isColor;

            _shortTermMemory = new ShortTermMemory<double[]>(itemOptions.ShortTermMemory_MillisecondsBetween, itemOptions.ShortTermMemory_Size);
            //TODO: Get params from itemOptions
            _nonLifeEventSnapshots = new NonLifeEventSnapshots<double[]>();
            //_nonLifeEventSnapshots = new NonLifeEventSnapshots<double[]>(.25, .6, 2);     // faster times for debugging

            GetMass(out _mass, out _volume, out _radius, out _scaleActual, dna, itemOptions);
        }
Пример #15
0
        public SwarmBay(EditorOptions options, ItemOptions itemOptions, ShipPartDNA dna, Map map, World world, int material_SwarmBot, IContainer plasma, SwarmObjectiveStrokes strokes)
            : base(options, dna, itemOptions.SwarmBay_Damage.HitpointMin, itemOptions.SwarmBay_Damage.HitpointSlope, itemOptions.SwarmBay_Damage.Damage)
        {
            _itemOptions = itemOptions;
            _map = map;
            _world = world;
            _material_SwarmBot = material_SwarmBot;
            _plasma = plasma;
            _strokes = strokes;

            this.Design = new SwarmBayDesign(options, true);
            this.Design.SetDNA(dna);

            double volume, radius;
            GetMass(out _mass, out volume, out radius, out _scaleActual, dna, itemOptions);
            //this.Radius = radius;

            _timeBetweenBots = StaticRandom.NextPercent(itemOptions.SwarmBay_BirthRate, .1);

            int maxCount = (itemOptions.SwarmBay_MaxCount * Math1D.Avg(dna.Scale.X, dna.Scale.Y, dna.Scale.Z)).ToInt_Round();
            if (maxCount < 0)
            {
                maxCount = 1;
            }
            _maxBots = maxCount;

            _plasmaTankThreshold = itemOptions.SwarmBay_Birth_TankThresholdPercent;

            _birthCost = itemOptions.SwarmBay_BirthCost;
            _birthRadius = itemOptions.SwarmBay_BirthSize / 2d;

            if (_map != null)
            {
                _map.ItemRemoved += Map_ItemRemoved;
            }

            this.Destroyed += SwarmBay_Destroyed;
        }
Пример #16
0
 public BrainDesign(EditorOptions options, bool isFinalModel)
     : base(options, isFinalModel) { }
 public SensorInternalForceDesign(EditorOptions options, bool isFinalModel)
     : base(options, isFinalModel) { }
 public SensorInternalForceToolItem(EditorOptions options)
     : base(options)
 {
     this.TabName = PartToolItemBase.TAB_SHIPPART;
     _visual2D = PartToolItemBase.GetVisual2D(this.Name, this.Description, options, this);
 }
Пример #19
0
        public const PartDesignAllowedScale ALLOWEDSCALE = PartDesignAllowedScale.XYZ;		// This is here so the scale can be known through reflection

        #endregion

        #region Constructor

        public GrappleGunDesign(EditorOptions options, bool isFinalModel)
            : base(options, isFinalModel) { }
Пример #20
0
        private readonly double _volume;		// this is used to calculate energy draw

        #endregion

        #region Constructor

        public Brain(EditorOptions options, ItemOptions itemOptions, ShipPartDNA dna, IContainer energyTanks)
            : base(options, dna, itemOptions.Brain_Damage.HitpointMin, itemOptions.Brain_Damage.HitpointSlope, itemOptions.Brain_Damage.Damage)
        {
            _itemOptions = itemOptions;
            _energyTanks = energyTanks;

            this.Design = new BrainDesign(options, true);
            this.Design.SetDNA(dna);

            // Build the neurons (not doing the links yet - or maybe do the internal links?)
            _brainChemicals = CreateBrainChemicals(dna, itemOptions);
            _neurons = CreateNeurons(dna, itemOptions, _brainChemicals.Select(o => o.Position).ToArray());
            //_design.NeuronLocations = _neurons.Select(o => o.Position).ToArray();

            double radius;
            GetMass(out _mass, out _volume, out radius, dna, itemOptions);

            this.Radius = radius;
            _scaleActual = new Vector3D(radius * 2d, radius * 2d, radius * 2d);
        }
Пример #21
0
        public SensorVision(EditorOptions options, ItemOptionsArco itemOptions, ShipPartDNA dna, Map map, double searchRadius, Type filterType = null)
            : base(options, dna, itemOptions.VisionSensor_Damage.HitpointMin, itemOptions.VisionSensor_Damage.HitpointSlope, itemOptions.VisionSensor_Damage.Damage)
        {
            _itemOptions = itemOptions;
            _map = map;
            _filterType = filterType;

            this.Design = new SensorVisionDesign(options, true);
            this.Design.SetDNA(dna);

            double radius, volume;
            GetMass(out _mass, out volume, out radius, out _scaleActual, dna, itemOptions);

            this.Radius = radius;

            _neurons = CreateNeurons(dna, itemOptions, itemOptions.VisionSensor_NeuronDensity, true, true);

            #region Store stats about neurons

            if (_neurons.Length == 0)
            {
                throw new ApplicationException("CreateNeurons should have guaranteed at least one neuron");
            }
            else if (_neurons.Length == 1)
            {
                // Since the neuron was forced to not be at the origin, just take the offset from origin (a single neuron vision
                // field is pretty useless anyway)
                _neuronDistBetween = _neurons[0].Position.ToVector().Length;
            }
            else
            {
                // Get the distance between each neuron
                List<Tuple<int, int, double>> distances = new List<Tuple<int, int, double>>();

                for (int outer = 0; outer < _neurons.Length - 1; outer++)
                {
                    for (int inner = outer + 1; inner < _neurons.Length; inner++)
                    {
                        double distance = (_neurons[outer].Position - _neurons[inner].Position).LengthSquared;

                        distances.Add(Tuple.Create(outer, inner, distance));
                    }
                }

                // Get the average of the minimum distance of each index
                _neuronDistBetween = Enumerable.Range(0, _neurons.Length).
                    Select(o => distances.
                        Where(p => p.Item1 == o || p.Item2 == o).       // get the disances that mention this index
                        Min(p => p.Item3)).     // only keep the smallest of those distances
                    Average();      // get the average of all the mins
            }

            // Find the one that's farthest away from the origin (since they form a circle, there will be an outer ring of them that
            // are about the same distance from the center)
            _neuronMaxRadius = _neurons.Max(o => o.PositionLength);

            #endregion

            this.SearchRadius = searchRadius;       // need to set this last, because it populates _distProps
        }
Пример #22
0
 public SwarmBayDesign(EditorOptions options, bool isFinalModel)
     : base(options, isFinalModel) { }
Пример #23
0
 public SensorVisionDesign(EditorOptions options, bool isFinalModel)
     : base(options, isFinalModel) { }
Пример #24
0
 public BrainRGBRecognizerToolItem(EditorOptions options)
     : base(options)
 {
     this.TabName = PartToolItemBase.TAB_SHIPPART;
     _visual2D = PartToolItemBase.GetVisual2D(this.Name, this.Description, options, this);
 }
Пример #25
0
        public const PartDesignAllowedScale ALLOWEDSCALE = PartDesignAllowedScale.X_Y_Z;		// This is here so the scale can be known through reflection

        #endregion

        #region Constructor

        public HangarBayDesign(EditorOptions options, bool isFinalModel)
            : base(options, isFinalModel) { }
Пример #26
0
        public ShieldKinetic(EditorOptions options, ItemOptions itemOptions, ShipPartDNA dna, IContainer plasma)
            : base(options, dna, itemOptions.Shield_Damage.HitpointMin, itemOptions.Shield_Damage.HitpointSlope, itemOptions.Shield_Damage.Damage)
        {
            _itemOptions = itemOptions;
            _plasma = plasma;

            this.Design = new ShieldKineticDesign(options, true);
            this.Design.SetDNA(dna);

            double volume, radius;
            ShieldEnergy.GetMass(out _mass, out volume, out radius, out _scaleActual, dna, itemOptions);

            //this.Radius = radius;

        }
 public ConverterMatterToAmmoToolItem(EditorOptions options)
     : base(options)
 {
     this.TabName = PartToolItemBase.TAB_SHIPPART;
     _visual2D = PartToolItemBase.GetVisual2D(this.Name, this.Description, options, this);
 }
Пример #28
0
 public EnergyTankToolItem(EditorOptions options)
     : base(options)
 {
     this.TabName = PartToolItemBase.TAB_SHIPPART;
     _visual2D = PartToolItemBase.GetVisual2D(this.Name, this.Description, options, this);
 }
        /// <summary>
        /// NOTE: It's assumed that energyTanks and ammoBoxes are actually container groups holding the actual tanks, but it
        /// could be the tanks passed in directly
        /// </summary>
        public ConverterMatterToAmmo(EditorOptions options, ItemOptions itemOptions, ShipPartDNA dna, IContainer ammoBoxes)
            : base(options, dna, itemOptions.MatterConverter_Damage.HitpointMin, itemOptions.MatterConverter_Damage.HitpointSlope, itemOptions.MatterConverter_Damage.Damage)
        {
            _itemOptions = itemOptions;
            _ammoBoxes = ammoBoxes;

            this.Design = new ConverterMatterToAmmoDesign(options, true);
            this.Design.SetDNA(dna);

            double volume;
            ConverterMatterToFuel.GetMass(out _dryMass, out volume, out _scaleActual, _itemOptions, dna);

            this.MaxVolume = volume;

            if (_ammoBoxes != null)
            {
                double scaleVolume = _scaleActual.X * _scaleActual.Y * _scaleActual.Z;      // can't use volume from above, because that is the amount of matter that can be held.  This is to get conversion ratios
                _converter = new Converter(this, _ammoBoxes, _itemOptions.MatterToAmmo_ConversionRate, _itemOptions.MatterToAmmo_AmountToDraw * scaleVolume);
            }

            this.Destroyed += ConverterMatterToAmmo_Destroyed;
        }
Пример #30
0
 public EnergyTankDesign(EditorOptions options, bool isFinalModel)
     : base(options, isFinalModel) { }
 public ConverterMatterToAmmoDesign(EditorOptions options, bool isFinalModel)
     : base(options, isFinalModel) { }