Beispiel #1
0
        public override ShipPartDNA GetDNA()
        {
            ConverterRadiationToEnergyDNA retVal = new ConverterRadiationToEnergyDNA();

            base.FillDNA(retVal);
            retVal.Shape = this.Shape;

            return(retVal);
        }
Beispiel #2
0
        public override void SetDNA(ShipPartDNA dna)
        {
            if (!(dna is ConverterRadiationToEnergyDNA))
            {
                throw new ArgumentException("The class passed in must be ConverterRadiationToEnergyDNA");
            }

            ConverterRadiationToEnergyDNA dnaCast = (ConverterRadiationToEnergyDNA)dna;

            base.StoreDNA(dna);

            this.Shape = dnaCast.Shape;
        }
Beispiel #3
0
        public override bool IsEqual(ShipPartDNA dna, bool comparePositionOrientation = false, bool compareNeural = false)
        {
            ConverterRadiationToEnergyDNA cast = dna as ConverterRadiationToEnergyDNA;

            if (cast == null)
            {
                return(false);
            }

            if (!base.IsEqual(dna, comparePositionOrientation, compareNeural))
            {
                return(false);
            }

            if (this.Shape != cast.Shape)
            {
                return(false);
            }

            return(true);
        }
        private PartBase GetRandomPart()
        {
            Point3D position = Math3D.GetRandomVector(2d).ToPoint();
            Quaternion orientation = Math3D.GetRandomRotation();
            double radius = 1d + StaticRandom.NextDouble() * 4d;
            double height = 1d + StaticRandom.NextDouble() * 4d;

            switch (StaticRandom.Next(8))
            {
                case 0:
                    #region Spin

                    double spinSize = 5d + (StaticRandom.NextDouble() * 8d);
                    ShipPartDNA dnaSpin = new ShipPartDNA() { PartType = SensorSpin.PARTTYPE, Position = position, Orientation = orientation, Scale = new Vector3D(spinSize, spinSize, spinSize) };
                    return new SensorSpin(_editorOptions, _itemOptions, dnaSpin, null);

                    #endregion

                case 1:
                    #region Fuel

                    ShipPartDNA dnaFuel = new ShipPartDNA() { PartType = FuelTank.PARTTYPE, Position = position, Orientation = orientation, Scale = new Vector3D(radius, radius, height) };
                    FuelTank fuel = new FuelTank(_editorOptions, _itemOptions, dnaFuel);
                    fuel.QuantityCurrent = fuel.QuantityMax;		// without this, the fuel tank gets tossed around because it's so light
                    return fuel;

                    #endregion

                case 2:
                    #region Energy

                    ShipPartDNA dnaEnergy = new ShipPartDNA() { PartType = EnergyTank.PARTTYPE, Position = position, Orientation = orientation, Scale = new Vector3D(radius, radius, height) };
                    return new EnergyTank(_editorOptions, _itemOptions, dnaEnergy);

                    #endregion

                case 3:
                    #region Brain

                    ShipPartDNA dnaBrain = new ShipPartDNA() { PartType = Brain.PARTTYPE, Position = position, Orientation = orientation, Scale = new Vector3D(radius, radius, radius) };
                    return new Brain(_editorOptions, _itemOptions, dnaBrain, null);

                    #endregion

                case 4:
                    #region Thruster

                    ThrusterDNA dnaThruster1 = new ThrusterDNA() { PartType = Thruster.PARTTYPE, Position = position, Orientation = orientation, Scale = new Vector3D(height, height, height), ThrusterType = UtilityCore.GetRandomEnum(ThrusterType.Custom) };
                    return new Thruster(_editorOptions, _itemOptions, dnaThruster1, null);

                    #endregion

                case 5:
                    #region Solar

                    ConverterRadiationToEnergyDNA dnaSolar = new ConverterRadiationToEnergyDNA() { PartType = ConverterRadiationToEnergy.PARTTYPE, Position = position, Orientation = orientation, Scale = new Vector3D(height, 1d + StaticRandom.NextDouble() * 4d, 1d), Shape = UtilityCore.GetRandomEnum<SolarPanelShape>() };
                    return new ConverterRadiationToEnergy(_editorOptions, _itemOptions, dnaSolar, null, _radiation);

                    #endregion

                case 6:
                    #region Fuel->Energy

                    ShipPartDNA dnaBurner = new ShipPartDNA() { PartType = ConverterFuelToEnergy.PARTTYPE, Position = position, Orientation = orientation, Scale = new Vector3D(radius, radius, height) };
                    return new ConverterFuelToEnergy(_editorOptions, _itemOptions, dnaBurner, null, null);

                    #endregion

                case 7:
                    #region Energy->Ammo

                    ShipPartDNA dnaReplicator = new ShipPartDNA() { PartType = ConverterEnergyToAmmo.PARTTYPE, Position = position, Orientation = orientation, Scale = new Vector3D(radius, radius, height) };
                    return new ConverterEnergyToAmmo(_editorOptions, _itemOptions, dnaReplicator, null, null);

                    #endregion

                default:
                    throw new ApplicationException("Unexpected integer");
            }
        }
        public ConverterRadiationToEnergy(EditorOptions options, ItemOptions itemOptions, ConverterRadiationToEnergyDNA dna, IContainer energyTanks, RadiationField radiationField)
            : base(options, dna, itemOptions.SolarPanel_Damage.HitpointMin, itemOptions.SolarPanel_Damage.HitpointSlope, itemOptions.SolarPanel_Damage.Damage)
        {
            _itemOptions = itemOptions;
            _energyTanks = energyTanks;
            _radiationField = radiationField;

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

            this.ClarityPercent_Front = 1d;
            this.ClarityPercent_Back = 1d;

            Point3D center;
            Vector3D normal;
            GetStats(out _mass, out center, out normal, out _scaleActual);

            // Store the center and normals
            Transform3DGroup transform = new Transform3DGroup();
            transform.Children.Add(new RotateTransform3D(new QuaternionRotation3D(dna.Orientation)));
            transform.Children.Add(new TranslateTransform3D(dna.Position.ToVector()));

            _centerPoint = transform.Transform(center);
            _normalFront = transform.Transform(normal);
            _normalBack = transform.Transform(normal * -1d);
        }
        public override ShipPartDNA GetDNA()
        {
            ConverterRadiationToEnergyDNA retVal = new ConverterRadiationToEnergyDNA();

            base.FillDNA(retVal);
            retVal.Shape = this.Shape;

            return retVal;
        }
        private void btnStandaloneSolarPanel_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                RadiationField radiation = new RadiationField();
                radiation.AmbientRadiation = 1d;

                ConverterRadiationToEnergyDNA dna = new ConverterRadiationToEnergyDNA()
                {
                    PartType = ConverterRadiationToEnergy.PARTTYPE,
                    Shape = UtilityCore.GetRandomEnum<SolarPanelShape>(),
                    Position = new Point3D(0, 0, 0),
                    Orientation = Quaternion.Identity,
                    Scale = new Vector3D(1, 1, 1)
                };
                ModifyDNA(dna, chkStandaloneRandSize.IsChecked.Value, chkStandaloneRandOrientation.IsChecked.Value);

                ConverterRadiationToEnergy solar = new ConverterRadiationToEnergy(_editorOptions, _itemOptions, dna, null, radiation);

                BuildStandalonePart(solar);

                if (chkStandaloneShowMassBreakdown.IsChecked.Value)
                {
                    double cellSize = Math1D.Max(dna.Scale.X, dna.Scale.Y, dna.Scale.Z) * UtilityCore.GetScaledValue_Capped(.1d, .3d, 0d, 1d, _rand.NextDouble());
                    DrawMassBreakdown(solar.GetMassBreakdown(cellSize), cellSize);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void btnSolarPanel_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ShipPartDNA dna = GetDefaultDNA(EnergyTank.PARTTYPE);
                EnergyTank energyTank = new EnergyTank(_editorOptions, _itemOptions, dna);

                RadiationField radiation = new RadiationField();
                radiation.AmbientRadiation = 1d;

                ConverterRadiationToEnergyDNA dna2 = new ConverterRadiationToEnergyDNA()
                {
                    PartType = ConverterRadiationToEnergy.PARTTYPE,
                    Shape = UtilityCore.GetRandomEnum<SolarPanelShape>(),
                    Position = new Point3D(0, 0, 0),
                    Orientation = Quaternion.Identity,
                    Scale = new Vector3D(1, 1, 1)
                };
                ConverterRadiationToEnergy solar = new ConverterRadiationToEnergy(_editorOptions, _itemOptions, dna2, energyTank, radiation);

                solar.Transfer(1d, Transform3D.Identity);
                solar.Transfer(1d, Transform3D.Identity);
                solar.Transfer(1d, Transform3D.Identity);
                solar.Transfer(1d, Transform3D.Identity);
                solar.Transfer(1d, Transform3D.Identity);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #9
0
        public ConverterRadiationToEnergy(EditorOptions options, ItemOptions itemOptions, ConverterRadiationToEnergyDNA dna, IContainer energyTanks, RadiationField radiationField)
            : base(options, dna, itemOptions.SolarPanel_Damage.HitpointMin, itemOptions.SolarPanel_Damage.HitpointSlope, itemOptions.SolarPanel_Damage.Damage)
        {
            _itemOptions    = itemOptions;
            _energyTanks    = energyTanks;
            _radiationField = radiationField;

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

            this.ClarityPercent_Front = 1d;
            this.ClarityPercent_Back  = 1d;

            Point3D  center;
            Vector3D normal;

            GetStats(out _mass, out center, out normal, out _scaleActual);

            // Store the center and normals
            Transform3DGroup transform = new Transform3DGroup();

            transform.Children.Add(new RotateTransform3D(new QuaternionRotation3D(dna.Orientation)));
            transform.Children.Add(new TranslateTransform3D(dna.Position.ToVector()));

            _centerPoint = transform.Transform(center);
            _normalFront = transform.Transform(normal);
            _normalBack  = transform.Transform(normal * -1d);
        }