Exemple #1
0
    void Start()
    {
        rectX = gameObject.GetComponent<RectTransform>().rect.width;
        rectY = gameObject.GetComponent<RectTransform>().rect.height;
        startx =  rectX - 334;
        starty = rectY - 680;
        int slotAmount = 0;
        itemOptions = options.GetComponent<ItemOptions>();
        database = GameObject.FindGameObjectWithTag("ItemDatabase").GetComponent<ItemDatabase>();
        for (int i = 1; i < 5; i++)
        {
            for (int p = 1; p < 5; p++)
            {
                GameObject slot = Instantiate(slots) as GameObject;
                slot.GetComponent<SlotScript>().slotNumber = slotAmount;
                Slots.Add(slot);
                Items.Add(new Item());
                slot.transform.parent = this.gameObject.transform;
                slot.GetComponent<RectTransform>().localPosition = new Vector3(startx, starty, 0);
                slot.name = "slot" + i + "." + p;
                startx = startx + 60;
                if (p == 4)
                {
                    startx = -90;
                    starty = starty - 60;

                }
                slotAmount++;

            }
        }
    }
Exemple #2
0
        private void BrainNEAT_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_experiment == null || _ea == null)
                {
                    //NOTE: Just doing this for laziness.  I don't want to write a bunch of logic to train a phenome up front
                    MessageBox.Show("Need to have a running experiment", this.Title, MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }

                // Get a genome
                NeatGenome genome = _ea.CurrentChampGenome;

                // Create a phenome
                IBlackBox phenome = ExperimentNEATBase.GetBlackBox(genome, _experimentArgs.Activation, _hyperneatArgs);

                // Instantiate a BrainNEAT
                EditorOptions options     = new EditorOptions();
                ItemOptions   itemOptions = new ItemOptions();

                Container energy = new Container()
                {
                    QuantityMax     = 1000,
                    QuantityCurrent = 1000,
                };

                BrainNEATDNA dnaBrain = new BrainNEATDNA()
                {
                    PartType = BrainNEAT.PARTTYPE, Position = new Point3D(0, 0, 0), Orientation = Quaternion.Identity, Scale = new Vector3D(1, 1, 1)
                };

                BrainNEAT brain = new BrainNEAT(options, itemOptions, dnaBrain, energy);


                brain.SetPhenome(phenome, genome, _experimentArgs.Activation, _hyperneatArgs);


                for (int cntr = 0; cntr < 100; cntr++)
                {
                    foreach (INeuron neuron in brain.Neruons_Writeonly)
                    {
                        neuron.SetValue(StaticRandom.NextDouble(-2.5, 2.5));
                    }

                    brain.Update_AnyThread(1);
                }



                #region save/load test2

                // let BrainNEAT do the save/load

                BrainNEATDNA dna2     = (BrainNEATDNA)brain.GetNewDNA();
                string       dna2Text = XamlServices.Save(dna2).Replace('"', '\'');
                BrainNEAT    brain2   = new BrainNEAT(options, itemOptions, dna2, energy);

                for (int cntr = 0; cntr < 100; cntr++)
                {
                    foreach (INeuron neuron in brain2.Neruons_Writeonly)
                    {
                        neuron.SetValue(StaticRandom.NextDouble(-2.5, 2.5));
                    }

                    brain2.Update_AnyThread(1);
                }

                BrainNEATDNA dna3   = (BrainNEATDNA)brain2.GetNewDNA();
                BrainNEAT    brain3 = new BrainNEAT(options, itemOptions, dna3, energy);

                for (int cntr = 0; cntr < 100; cntr++)
                {
                    foreach (INeuron neuron in brain3.Neruons_Writeonly)
                    {
                        neuron.SetValue(StaticRandom.NextDouble(-2.5, 2.5));
                    }

                    brain3.Update_AnyThread(1);
                }

                #endregion
                #region save/load test1

                // initial test, building minimum necessary dna

                BrainNEATDNA brainDNA = new BrainNEATDNA()
                {
                    Activation           = _experimentArgs.Activation,
                    Hyper                = _hyperneatArgs,
                    NEATPositions_Input  = brain.Neruons_Readonly.Select(o => o.Position).ToArray(),
                    NEATPositions_Output = brain.Neruons_Writeonly.Select(o => o.Position).ToArray(),
                    Genome               = ExperimentNEATBase.SavePopulation(new[] { genome }),
                };


                // Make sure this can be serialized/deserialized
                string testString = XamlServices.Save(brainDNA);
                brainDNA = UtilityCore.Clone(brainDNA);


                List <NeatGenome> genomeList = null;
                if (_hyperneatArgs == null)
                {
                    genomeList = ExperimentNEATBase.LoadPopulation(brainDNA.Genome, brainDNA.Activation, brainDNA.NEATPositions_Input.Length, brainDNA.NEATPositions_Output.Length);
                }
                else
                {
                    genomeList = ExperimentNEATBase.LoadPopulation(brainDNA.Genome, brainDNA.Activation, _hyperneatArgs);
                }

                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #3
0
 void Awake()
 {
     S = this;
 }
Exemple #4
0
        private static void GetMass(out double mass, out double volume, out double radius, out Vector3D actualScale, ShipPartDNA dna, ItemOptions itemOptions)
        {
            radius = (dna.Scale.X + dna.Scale.Y + dna.Scale.Z) / (3d * 2d);		// they should be identical anyway
            radius *= SwarmBayDesign.SCALE;		// scale it

            volume = 4d / 3d * Math.PI * radius * radius * radius;
            mass = volume * itemOptions.SwarmBay_Density;

            actualScale = new Vector3D(radius * 2d, radius * 2d, radius * 2d);
        }
Exemple #5
0
        private static Neuron_Fade[] CreateBrainChemicals(ShipPartDNA dna, ItemOptions itemOptions)
        {
            const double K_UP = 50d;
            const double K_DOWN = 750d;
            const double VALUECUTOFF = .75d;

            // Figure out how many to make
            double radius, volume;
            GetNeuronVolume(out radius, out volume, dna, itemOptions);

            int count = Convert.ToInt32(Math.Round(itemOptions.Brain_ChemicalDensity * volume));
            if (count == 0)
            {
                return new Neuron_Fade[0];
            }

            // The brain chemicals are stored in dna.AltNeurons
            Point3D[] brainChemPositions = null;
            if (dna.AltNeurons != null && dna.AltNeurons.Length > 0)
            {
                if (dna.AltNeurons.Length != 1)
                {
                    throw new ApplicationException("dna.AltNeurons.Length should be exactly 1 (" + dna.AltNeurons.Length.ToString() + ")");
                }

                brainChemPositions = dna.AltNeurons[0];
            }

            // Figure out the positions
            //NOTE: Only let them go to half radius.  Cluster% then needs to be doubled (doubling it again so that the brain chemicals don't get
            //too close together)
            Vector3D[] positions = GetNeuronPositions_Cluster(brainChemPositions, count, radius * .5d, itemOptions.Brain_NeuronMinClusterDistPercent * 4d);

            // Exit Function
            return positions.Select(o => new Neuron_Fade(o.ToPoint(), K_UP, K_DOWN, VALUECUTOFF)).ToArray();
        }
        /// <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;
        }
Exemple #7
0
        /// <summary>
        /// inputs are located at +Z, outputs are -Z
        /// </summary>
        private static (Neuron_Direct[] input, Neuron_Direct[] output) CreateNeurons(ShipPartDNA dna, ItemOptions itemOptions)
        {
            const double MAXANGLE = 83;

            GetNeuronVolume(out double radius, out double volume, dna, itemOptions);

            int inputCount  = Math.Max(1, (volume * itemOptions.BrainNEAT_NeuronDensity_Input).ToInt_Round());
            int outputCount = Math.Max(1, (volume * itemOptions.BrainNEAT_NeuronDensity_Output).ToInt_Round());

            Point3D[] inputs  = null;
            Point3D[] outputs = null;
            if (dna.Neurons != null)
            {
                inputs = dna.Neurons.
                         Where(o => o.Z >= 0).  // there's a band around the equator that has no neurons, so even minor mutations shouldn't cross over
                         ToArray();

                outputs = dna.Neurons.
                          Where(o => o.Z < 0).
                          ToArray();
            }

            //NOTE: This will repair positions to keep neurons evenly spaced.  Other parts are more allowing of mutation, but this is a wrapper to a trained
            //neural net, so mutation would just unnecessarily blur the signals - but even with the position repair, there could be drift over many generations,
            //especially if scale causes neuron counts to change
            inputs  = GetNeuronPositions(inputs, inputCount, radius, new Vector3D(0, 0, 1), MAXANGLE);
            outputs = GetNeuronPositions(outputs, outputCount, radius, new Vector3D(0, 0, -1), MAXANGLE);

            return
                (
                inputs.
                Select(o => new Neuron_Direct(o, false)).
                ToArray(),

                outputs.
                Select(o => new Neuron_Direct(o, false)).
                ToArray()
                );
        }
Exemple #8
0
 public Boolean Remove(int ItemId)
 {
     return(ItemOptions.eliminar(ItemId));
 }
Exemple #9
0
        public static void GetMass(out double mass, out double volume, out double radius, out Vector3D actualScale, ShipPartDNA dna, ItemOptions itemOptions)
        {
            volume  = dna.Scale.X * dna.Scale.Y * dna.Scale.Z;          // get volume of the cube
            volume *= SensorGravityDesign.SIZEPERCENTOFSCALE;           // scale it

            radius  = (dna.Scale.X + dna.Scale.Y + dna.Scale.Z) / (3d * 2d);
            radius *= SensorGravityDesign.SIZEPERCENTOFSCALE;

            mass = volume * itemOptions.Sensor_Density;

            actualScale = new Vector3D(dna.Scale.X * SensorGravityDesign.SIZEPERCENTOFSCALE, dna.Scale.Y * SensorGravityDesign.SIZEPERCENTOFSCALE, dna.Scale.Z * SensorGravityDesign.SIZEPERCENTOFSCALE);
        }
Exemple #10
0
    // 190208 LifeBalance
    // Activate Item by UseItem method
    private void ActivateItem(ItemOptions itemOptionInfo)
    {
        //Debug.Log("Activate " + itemOptionIndex);
        //ItemType itemtype = itemOption[itemOptionNum].itemTypeEnum;

        if (itemOptionInfo.useSound != null)
        {
            SoundManager.Instance.ShortSpeaker(SoundManager.Speaker.Center, itemOptionInfo.useSound);
        }


        // 아이템 유지시간 아이콘 코드
        if (itemOptionInfo.active == false)
        {
            if (itemOptionInfo.usingItemCreate == true)
            {
                if (itemOptionInfo.usingItem == null)
                {
                    itemOptionInfo.usingItem = Instantiate(itemUseCheckBlockBox, itemUseCheckBlock.transform);
                    itemOptionInfo.usingItem.SetItem(itemOptionInfo.duration, itemOptionInfo.sprite);
                }
            }
        }
        if (itemOptionInfo.active == true && (itemOptionInfo.typeEnum != ItemType.GetCredit))
        {
            if (itemOptionInfo.usingItemCreate == true)
            {
                if (itemOptionInfo.usingItem == null)
                {
                    itemOptionInfo.usingItem = Instantiate(itemUseCheckBlockBox, itemUseCheckBlock.transform);
                    itemOptionInfo.usingItem.SetItem(itemOptionInfo.duration, itemOptionInfo.sprite);
                }
                else
                {
                    itemOptionInfo.usingItem.ResetTimer();
                }
            }
        }



        switch (itemOptionInfo.typeEnum)
        {
        case ItemType.GetCredit:
            // 크레딧 UI 를 따로 제작할 것
            RefreshCredit((int)itemOptionInfo.duration);
            break;

        case ItemType.ScoreBooster:
            itemOptionInfo.active      = true;
            itemOptionInfo.activeTimer = 0;
            igsScoreMultifly           = (int)itemOptionInfo.magnification;
            //Debug.Log(itemOptionInfo.typeEnum + " : " + itemOptionInfo.active);
            break;

        case ItemType.BigShield:
            itemOptionInfo.active      = true;
            itemOptionInfo.activeTimer = 0;
            playerScript.OP_BigShield(itemOptionInfo.magnification * playerScript.op_shieldOriginalSize);
            //Debug.Log(itemOptionInfo.typeEnum + " : " + itemOptionInfo.active);
            break;

        case ItemType.ShieldFullCharge:
            itemOptionInfo.active      = true;
            itemOptionInfo.activeTimer = 0;
            playerScript.OP_ShieldFullCharge(true);
            playerScript.OP_BigShield(itemOptionInfo.magnification * playerScript.op_shieldOriginalSize);
            //Debug.Log(itemOptionInfo.typeEnum + " : " + itemOptionInfo.active);
            break;

        case ItemType.ShieldRecovery:
            itemOptionInfo.active      = true;
            itemOptionInfo.activeTimer = 0;
            playerScript.OP_ShieldRecovery(itemOptionInfo.duration);
            //Debug.Log(itemOptionInfo.typeEnum + " : " + itemOptionInfo.active);
            break;

        case ItemType.Bomb:
            //Debug.Log("YOU ACTIVATE BOMB ! ! !");
            CBUseItemBomb();
            break;

        case ItemType.PowerBooster:
            itemOptionInfo.active      = true;
            itemOptionInfo.activeTimer = 0;
            playerScript.OP_PowerBooster(itemOptionInfo.magnification);
            playerScript.OP_PowerBoosterDamage(2.0f);
            //Debug.Log(itemOptionInfo.typeEnum + " : " + itemOptionInfo.active);
            break;
        }
    }
Exemple #11
0
        /// <summary>
        /// Creates a "ConnectToken" that provides an "AccessToken" for client-side communication.
        /// </summary>
        /// <returns>An object containing an accessToken</returns>
        public async Task <ConnectTokenResponse> CreateConnectToken(Guid?itemId = null, ItemOptions options = null)
        {
            try
            {
                var body = new Dictionary <string, object>
                {
                    { "itemId", itemId?.ToString() },
                    { "options", options }
                };
                return(await httpService.PostAsync <ConnectTokenResponse>(URL_CONNECT_TOKEN, body));
            }
            catch (ApiException e)
            {
                if (e.ApiError != null && e.ApiError.Errors != null)
                {
                    throw new ValidationException(e.StatusCode, e.ApiError);
                }

                throw e;
            }
        }
Exemple #12
0
    // 190121 LifeBalance
    // DropItem according to probability (gasha)

    public void DropItem(Vector2 position, bool isBoss = false)
    {
        if (isBoss == false)
        {
            // 190227 LifeBalance
            // Debug State
            if (isDebug == true)
            {
                for (int i = 0; i < itemOption.Length; i++)
                {
                    if (itemOption[i].typeEnum == debugAlwaysCreateThisItem)
                    {
                        item.spriteRenderer.sprite = itemOption[i].sprite;
                        Item forScript = Instantiate(item, position, Quaternion.Euler(Vector2.zero));
                        //forScript.spriteRenderer.sprite = itemOption[i].sprite;
                        //Debug.Log(" : : : " + forScript.spriteRenderer.sprite.name);
                        forScript.name = (i - 1).ToString();

                        if (itemOption[i].typeEnum == ItemType.GetCredit)
                        {
                            forScript.ActiveCoinAnimation(true);
                        }

                        return;
                    }
                }
            }


            // 190128 LifeBalance
            // Change Item droptable algorhythm

            //int itemValue = Random.Range(0, itemOption[itemOption.Length - 1].itemDropChance);
            int itemValue = Random.Range(0, itemAllChanceValue);
            int currValue = 0;
            //Debug.Log(itemValue);


            // Normal state
            for (int i = 0; i < itemOption.Length; i++)
            {
                currValue += itemOption[i].dropChance;
                if (i == 0)
                {
                    if (itemValue < currValue)
                    {
                        //Debug.Log("Failed");
                        return;
                    }
                }
                // 'i' is bigger than 0 && 'i' is smaller than items.Length - 1
                else
                {
                    // If itemValue is between current and next
                    if (itemValue > itemOption[i - 1].dropChance && itemValue <= currValue)
                    {
                        item.spriteRenderer.sprite = itemOption[i].sprite;
                        Item forScript = Instantiate(item, position, Quaternion.Euler(Vector2.zero));
                        //forScript.spriteRenderer.sprite = itemOption[i].sprite;
                        //Debug.Log(" : : : " + forScript.spriteRenderer.sprite.name);
                        forScript.name = (i - 1).ToString();

                        if (itemOption[i].typeEnum == ItemType.GetCredit)
                        {
                            forScript.ActiveCoinAnimation(true);
                        }

                        //Debug.Log("Create : " + item.name + "//// itemValue : " + itemValue + "//// currValue : " + currValue);
                        return;
                    }
                }
            }
        }
        else // isBoss == true
        {
            // Change Item droptable algorhythm
            int         itemEaExceptCredit     = itemDropBossModeEa - 3;
            ItemOptions itemGetCreditInfo      = new ItemOptions();
            int         itemGetCreditInfoIndex = 0;
            // Find GetCredit Info and Set It to itemGetCreditInfo;
            foreach (ItemOptions info in itemOption)
            {
                if (info.typeEnum == ItemType.GetCredit)
                {
                    itemGetCreditInfo = info;
                    break;
                }
                else
                {
                    itemGetCreditInfoIndex++;
                }
            }

            for (int itemDropNumber = 0; itemDropNumber < (itemDropBossModeEa + level); itemDropNumber++)
            {
                Vector2 addForce = new Vector2(Random.Range(-0.5f, 0.5f), Random.Range(-0.5f, 0.5f));

                // Normal state
                // If itemValue is between current and next
                // 보스 아이템 드랍갯수 - 3 만큼 까지는 돈을 드랍한다
                if (itemDropNumber < itemEaExceptCredit)
                {
                    Item forScript;
                    item.spriteRenderer.sprite = itemGetCreditInfo.sprite;
                    forScript = Instantiate(item, position, Quaternion.Euler(Vector2.zero));
                    //forScript.spriteRenderer.sprite = itemOption[i].sprite;
                    //Debug.Log(" : : : " + forScript.spriteRenderer.sprite.name);
                    forScript.name = (itemGetCreditInfoIndex - 1).ToString();

                    if (itemGetCreditInfo.typeEnum == ItemType.GetCredit)
                    {
                        forScript.ActiveCoinAnimation(true);
                    }
                    forScript.ItemAddForce(addForce);
                }
                else
                {
                    int itemIndex = Random.Range(1, itemOption.Length);

                    if (itemOption[itemIndex].typeEnum == ItemType.GetCredit)
                    {
                        while (true)
                        {
                            itemIndex = Random.Range(1, itemOption.Length);
                            if (itemOption[itemIndex].typeEnum != ItemType.GetCredit)
                            {
                                break;
                            }
                        }
                    }
                    Item forScript;
                    item.spriteRenderer.sprite = itemOption[itemIndex].sprite;
                    forScript = Instantiate(item, position, Quaternion.Euler(Vector2.zero));
                    //forScript.spriteRenderer.sprite = itemOption[i].sprite;
                    //Debug.Log(" : : : " + forScript.spriteRenderer.sprite.name);
                    forScript.name = (itemIndex - 1).ToString();

                    if (itemOption[itemIndex].typeEnum == ItemType.GetCredit)
                    {
                        forScript.ActiveCoinAnimation(true);
                    }
                    forScript.ItemAddForce(addForce);
                    //Debug.Log("Create : " + item.name + "//// itemValue : " + itemValue + "//// currValue : " + currValue);
                }
            }
        }
    }
Exemple #13
0
 static void AssertItem(Item item, ItemOptions options)
 {
     AssertObject(item, options);
     Assert.AreEqual(item.RefId, options.RefId);
 }
Exemple #14
0
 static void SetItemOptions(ItemOptions options)
 {
     SetObjectOptions(options);
     options.Title = "3";
     options.RefId = "4";
 }
        /// <summary>
        /// NOTE: It's assumed that energyTanks and fuelTanks are actually container groups holding the actual tanks, but it
        /// could be the tanks passed in directly
        /// </summary>
        public ConverterEnergyToFuel(EditorOptions options, ItemOptions itemOptions, ShipPartDNA dna, IContainer energyTanks, IContainer fuelTanks)
            : base(options, dna, itemOptions.EnergyConverter_Damage.HitpointMin, itemOptions.EnergyConverter_Damage.HitpointSlope, itemOptions.EnergyConverter_Damage.Damage)
        {
            _itemOptions = itemOptions;

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

            double volume = GetVolume(out _scaleActual, dna);

            if (energyTanks != null && fuelTanks != null)
            {
                _converter = new Converter(energyTanks, fuelTanks, itemOptions.EnergyToFuel_ConversionRate, itemOptions.EnergyToFuel_AmountToDraw * volume);
            }

            _mass = volume * itemOptions.EnergyToFuel_Density;
        }
Exemple #16
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                _itemOptions = new ItemOptions();

                #region Init World

                _boundryMin = new Point3D(-BOUNDRYSIZEHALF, -BOUNDRYSIZEHALF, -BOUNDRYSIZEHALF);
                _boundryMax = new Point3D(BOUNDRYSIZEHALF, BOUNDRYSIZEHALF, BOUNDRYSIZEHALF);

                _world           = new World();
                _world.Updating += new EventHandler <WorldUpdatingArgs>(World_Updating);

                _world.SetCollisionBoundry(_boundryMin, _boundryMax);

                #endregion
                #region Materials

                _materialManager = new MaterialManager(_world);

                // Wall
                Game.Newt.v2.NewtonDynamics.Material material = new Game.Newt.v2.NewtonDynamics.Material();
                material.Elasticity = .1d;
                _material_Wall      = _materialManager.AddMaterial(material);

                // Ball
                material       = new Game.Newt.v2.NewtonDynamics.Material();
                _material_Ball = _materialManager.AddMaterial(material);

                #endregion
                #region Trackball

                // Trackball
                _trackball                       = new TrackBallRoam(_camera);
                _trackball.KeyPanScale           = 15d;
                _trackball.EventSource           = grdViewPort; //NOTE:  If this control doesn't have a background color set, the trackball won't see events (I think transparent is ok, just not null)
                _trackball.AllowZoomOnMouseWheel = true;
                _trackball.Mappings.AddRange(TrackBallMapping.GetPrebuilt(TrackBallMapping.PrebuiltMapping.MouseComplete_NoLeft));
                _trackball.Mappings.AddRange(TrackBallMapping.GetPrebuilt(TrackBallMapping.PrebuiltMapping.Keyboard_ASDW_In));
                _trackball.ShouldHitTestOnOrbit = true;
                //_trackball.UserMovedCamera += new EventHandler<UserMovedCameraArgs>(Trackball_UserMovedCamera);
                //_trackball.GetOrbitRadius += new EventHandler<GetOrbitRadiusArgs>(Trackball_GetOrbitRadius);

                #endregion

                #region Chased Ball

                _chasedBall = new ChasedBall();

                _chasedBall.MotionType_Position    = MotionType_Position.Stop;
                _chasedBall.MotionType_Orientation = MotionType_Orientation.Stop;

                _chasedBall.BoundrySizeChanged += new EventHandler(ChasedBall_BoundrySizeChanged);

                // Ball visual
                _chasedBallVisual           = GetChaseBallVisual_Position();
                _chasedBallTransform        = new TranslateTransform3D();
                _chasedBallVisual.Transform = _chasedBallTransform;
                _viewport.Children.Add(_chasedBallVisual);

                // Direction Visual
                var directionVisual = GetChaseBallVisual_Orientation();
                _chasedDirectionModel  = directionVisual.Item1;
                _chasedDirectionVisual = directionVisual.Item2;
                _viewport.Children.Add(_chasedDirectionVisual);

                // Panels (the act of instantiating them will update the ball's properties)
                pnlChasePosition.Content = new ChasedPosition(_chasedBall)
                {
                    Foreground = Brushes.White,
                };

                pnlChaseOrientation.Content = new ChasedOrientation(_chasedBall)
                {
                    Foreground = Brushes.White,
                };

                #endregion
                #region Debug Visuals

                // Put these on the viewport before the ball so that it is propertly semitransparent

                //TODO: Draw the bounding box.  Use XYZ colors.  This will help the user stay oriented

                #endregion
                #region Body Ball

                _bodyBall = new BodyBall(_world);

                //_bodyBall.PhysicsBody.AngularDamping = new Vector3D(.0001, .0001, .0001);
                //_bodyBall.PhysicsBody.AngularVelocity = new Vector3D(0, 0, 4 * Math.PI);

                _viewport.Children.AddRange(_bodyBall.Visuals3D);

                #endregion

                RedrawBoundry();

                _world.UnPause();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 public void RemoveAll()
 {
     Children.Clear();
     ItemOptions.Clear();
 }
Exemple #18
0
        private static void GetMass(out double dryMass, out double volume, out double radius, ItemOptions itemOptions, ShipPartDNA dna)
        {
            // The cargo bay is 1:1 with scale (a lot of the other parts are smaller than scale, but cargo bay is full sized)

            double surfaceArea = (2d * dna.Scale.X * dna.Scale.Y) + (2d * dna.Scale.X * dna.Scale.Z) + (2d * dna.Scale.Y * dna.Scale.Z);

            dryMass = surfaceArea * itemOptions.CargoBay_WallDensity;

            volume = dna.Scale.X * dna.Scale.Y * dna.Scale.Z;

            radius = (dna.Scale.X + dna.Scale.Y + dna.Scale.Z) / 3d;       // this is just approximate, and is used by INeuronContainer
        }
        internal static void GetMass(out double mass, out double volume, out double radius, out Vector3D actualScale, ShipPartDNA dna, ItemOptions itemOptions)
        {
            // Just assume it's a sphere
            double radX = dna.Scale.X * .5;
            double radY = dna.Scale.Y * .5;
            double radZ = dna.Scale.Z * .5;

            radius = (radX + radY + radZ) / 3d;

            actualScale = new Vector3D(radX * 2d, radY * 2d, radZ * 2d);

            volume = (4d / 3d) * Math.PI * radX * radY * radZ;

            mass = volume * itemOptions.Shield_Density;
        }
Exemple #20
0
        internal static void GetMass(out double mass, out double volume, out double radius, out Vector3D actualScale, ShipPartDNA dna, ItemOptions itemOptions)
        {
            // Just assume it's a sphere
            double radX = dna.Scale.X * .5;
            double radY = dna.Scale.Y * .5;
            double radZ = dna.Scale.Z * .5;

            radius = (radX + radY + radZ) / 3d;

            actualScale = new Vector3D(radX * 2d, radY * 2d, radZ * 2d);

            volume = (4d / 3d) * Math.PI * radX * radY * radZ;

            mass = volume * itemOptions.Shield_Density;
        }
        internal static void GetMass(out double dryMass, out double volume, out Vector3D scale, ItemOptions itemOptions, ShipPartDNA dna)
        {
            scale = dna.Scale * ConverterMatterToFuelDesign.SCALE;

            double surfaceArea = (2d * scale.X * scale.Y) + (2d * scale.X * scale.Z) + (2d * scale.Y * scale.Z);
            dryMass = surfaceArea * itemOptions.MatterConverter_WallDensity;

            volume = scale.X * scale.Y * scale.Z;
            volume *= itemOptions.MatterConverter_InternalVolume;        // this property should be between 0 and 1
        }
Exemple #22
0
        public async Task Run()
        {
            var options = _container.GetInstance <WvsGameOptions>();
            var info    = options.GameInfo;

            ChannelInformation = new ChannelInformation
            {
                ID           = info.ID,
                WorldID      = info.WorldID,
                Name         = info.Name,
                UserNo       = 0,
                AdultChannel = info.AdultChannel
            };

            CommandRegistry = _container.GetInstance <CommandRegistry>();

            ItemNames  = _container.GetInstance <ItemNameManager>();
            FieldNames = _container.GetInstance <FieldNameManager>();

            Logger.Info("Loading template names..");
            await Task.WhenAll(
                ItemNames.LoadAll(),
                FieldNames.LoadAll()
                );

            Logger.Info("Finished loading template names");

            ItemOptions = _container.GetInstance <EagerTemplateManager <ItemOptionTemplate> >();
            SetItemInfo = _container.GetInstance <EagerTemplateManager <SetItemInfoTemplate> >();
            await Task.WhenAll(
                Task.Run(async() =>
            {
                Logger.Info("Loading item options..");
                await ItemOptions.LoadAll();
                Logger.Info("Finished loading item options");
            }),
                Task.Run(async() =>
            {
                Logger.Info("Loading set item info..");
                await SetItemInfo.LoadAll();
                Logger.Info("Finished loading set item info");
            })
                );

            SkillTemplates = _container.GetInstance <LazyTemplateManager <SkillTemplate> >();
            ItemTemplates  = _container.GetInstance <LazyTemplateManager <ItemTemplate> >();
            FieldTemplates = _container.GetInstance <LazyTemplateManager <FieldTemplate> >();
            NpcTemplates   = _container.GetInstance <LazyTemplateManager <NPCTemplate> >();
            MobTemplates   = _container.GetInstance <LazyTemplateManager <MobTemplate> >();
            FieldFactory   = new FieldFactory(FieldTemplates, NpcTemplates, MobTemplates);

            using (var db = _container.GetInstance <DataContext>())
            {
                Logger.Info("Loading npc shops..");
                NPCShops = db.NPCShops
                           .Include(s => s.Items)
                           .ToDictionary(s => s.TemplateID, s => new NPCShopDlg(s));
                Logger.Info("Finished loading npc shops");
            }

            UserData.RegisterType <FieldUserSpeaker>();
            UserData.RegisterType <FieldNPCSpeaker>();
            NPCConversationManager = _container.GetInstance <ConversationManager <FieldUser, FieldNPC> >();

            InteropClient = new Client <CenterServerSocket>(
                options.InteropClientOptions,
                _container.GetInstance <CenterServerSocketFactory>()
                );

            GameServer = new Server <GameClientSocket>(
                options.GameServerOptions,
                _container.GetInstance <GameClientSocketFactory>()
                );

            await InteropClient.Run();

            Logger.Info($"Connected to interoperability server on {InteropClient.Channel.RemoteAddress}");

            await GameServer.Run();

            Logger.Info($"Bounded {ChannelInformation.Name} on {GameServer.Channel.LocalAddress}");

            while (InteropClient.Socket == null)
            {
                ;
            }

            using (var p = new OutPacket(InteropRecvOperations.ServerRegister))
            {
                p.Encode <byte>((byte)ServerType.Game);
                ChannelInformation.Encode(p);

                await InteropClient.Socket.SendPacket(p);
            }
        }
Exemple #23
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);
        }
        public PlasmaTank(EditorOptions options, ItemOptions itemOptions, ShipPartDNA dna)
            : base(options, dna, itemOptions.PlasmaTank_Damage.HitpointMin, itemOptions.PlasmaTank_Damage.HitpointSlope, itemOptions.PlasmaTank_Damage.Damage)
        {
            _itemOptions = itemOptions;

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

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

            _mass = _container.QuantityMax * itemOptions.PlasmaTank_Density;     // max quantity is the volume
            this.Radius = radius;

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

            this.Destroyed += PlasmaTank_Destroyed;
        }
Exemple #25
0
 private static void GetNeuronVolume(out double radius, out double volume, ShipPartDNA dna, ItemOptions itemOptions)
 {
     //NOTE: This radius isn't taking SCALE into account.  The other neural parts do this as well, so the neural density properties can be more consistent
     radius = (dna.Scale.X + dna.Scale.Y + dna.Scale.Z) / (3d * 2d);		// xyz should all be the same anyway
     volume = Math.Pow(radius, itemOptions.Brain_NeuronGrowthExponent);
 }
Exemple #26
0
        public PanelBeanProps(FlyingBeanOptions options, ItemOptions itemOptions)
        {
            InitializeComponent();

            _options     = options;
            _itemOptions = itemOptions;

            //PropertyInfo[] propsOptions = typeof(FlyingBeanOptions).GetProperties();
            PropertyInfo[] propsItems = typeof(ItemOptions).GetProperties();

            // Consumption
            _propLinks.Add(new SliderShowValues.PropSync(trkThrustForce, propsItems.Where(o => o.Name == "ThrusterStrengthRatio").First(), _itemOptions, 5, 100));
            _propLinks.Add(new SliderShowValues.PropSync(trkFuelDraw, propsItems.Where(o => o.Name == "FuelToThrustRatio").First(), _itemOptions, .001d, 5));
            _propLinks.Add(new SliderShowValues.PropSync(trkGravitySensorEnergyDraw, propsItems.Where(o => o.Name == "GravitySensorAmountToDraw").First(), _itemOptions, .1, 10));
            _propLinks.Add(new SliderShowValues.PropSync(trkSpinSensorEnergyDraw, propsItems.Where(o => o.Name == "SpinSensorAmountToDraw").First(), _itemOptions, .1, 10));
            _propLinks.Add(new SliderShowValues.PropSync(trkBrainEnergyDraw, propsItems.Where(o => o.Name == "BrainAmountToDraw").First(), _itemOptions, .1, 10));

            // Neural
            _propLinks.Add(new SliderShowValues.PropSync(trkGravSensorNeuronDensity, propsItems.Where(o => o.Name == "GravitySensorNeuronDensity").First(), _itemOptions, 4, 60));
            _propLinks.Add(new SliderShowValues.PropSync(trkBrainNeuronDensity, propsItems.Where(o => o.Name == "BrainNeuronDensity").First(), _itemOptions, 4, 60));
            _propLinks.Add(new SliderShowValues.PropSync(trkBrainChemicalDensity, propsItems.Where(o => o.Name == "BrainChemicalDensity").First(), _itemOptions, 0, 10));
            _propLinks.Add(new SliderShowValues.PropSync(trkBrainInternalLinks, propsItems.Where(o => o.Name == "BrainLinksPerNeuron_Internal").First(), _itemOptions, .5, 8));
            _propLinks.Add(new SliderShowValues.PropSync(trkBrainExternalLinkSensor, propsItems.Where(o => o.Name == "BrainLinksPerNeuron_External_FromSensor").First(), _itemOptions, .1, 5));
            _propLinks.Add(new SliderShowValues.PropSync(trkBrainExternalLinkBrain, propsItems.Where(o => o.Name == "BrainLinksPerNeuron_External_FromBrain").First(), _itemOptions, .1, 5));
            _propLinks.Add(new SliderShowValues.PropSync(trkThrusterExternalLinkSensor, propsItems.Where(o => o.Name == "ThrusterLinksPerNeuron_Sensor").First(), _itemOptions, .1, 5));
            _propLinks.Add(new SliderShowValues.PropSync(trkThrusterExternalLinkBrain, propsItems.Where(o => o.Name == "ThrusterLinksPerNeuron_Brain").First(), _itemOptions, .1, 5));

            // Density
            _propLinks.Add(new SliderShowValues.PropSync(trkBrainDensity, propsItems.Where(o => o.Name == "BrainDensity").First(), _itemOptions, 1, 5000));
            _propLinks.Add(new SliderShowValues.PropSync(trkGravSensorDensity, propsItems.Where(o => o.Name == "SensorDensity").First(), _itemOptions, 1, 5000));
            _propLinks.Add(new SliderShowValues.PropSync(trkEnergyTankDensity, propsItems.Where(o => o.Name == "EnergyTankDensity").First(), _itemOptions, 1, 5000));
            _propLinks.Add(new SliderShowValues.PropSync(trkFuelTankDensity, propsItems.Where(o => o.Name == "FuelTankWallDensity").First(), _itemOptions, 1, 5000));
            _propLinks.Add(new SliderShowValues.PropSync(trkFuelDensity, propsItems.Where(o => o.Name == "FuelDensity").First(), _itemOptions, 1, 5000));
            _propLinks.Add(new SliderShowValues.PropSync(trkThrusterDensity, propsItems.Where(o => o.Name == "ThrusterDensity").First(), _itemOptions, 1, 5000));

            // TODO: this one should have a log scale
            //trkMomentOfInertia.Normalize_SliderToValue += //convert a linear to nonlinear
            //trkMomentOfInertia.Normalize_ValueToSlider += //convert a nonlinear to linear
            _propLinks.Add(new SliderShowValues.PropSync(trkMomentOfInertia, propsItems.Where(o => o.Name == "MomentOfInertiaMultiplier").First(), _itemOptions, .01, 10));



            //TODO: When I start saving the options to file, also need to set the min/max from options (in case the user changed the range)
            //TODO: This is a lot of hard coding.  Store the linkage between slider and property in a list, and just have one event listener for all sliders

            //trkThrustForce.Value = _itemOptions.ThrusterStrengthRatio;
            //trkFuelDraw.Minimum = .000000001;
            //trkFuelDraw.Maximum = .000005;
            //trkFuelDraw.Value = _itemOptions.FuelToThrustRatio;

            //trkSensorEnergyDraw.Value = _itemOptions.GravitySensorAmountToDraw;
            //trkBrainEnergyDraw.Value = _itemOptions.BrainAmountToDraw;

            //trkLifespan.Value = _options.MaxAgeSeconds;
            //trkAngularVelocity.Value = _options.AngularVelocityDeath;
            //trkGroundCollisions.Value = _options.MaxGroundCollisions;

            //trkGravSensorNeuronDensity.Value = _itemOptions.GravitySensorNeuronDensity;
            //trkBrainNeuronDensity.Value = _itemOptions.BrainNeuronDensity;
            //trkBrainChemicalDensity.Value = _itemOptions.BrainChemicalDensity;
            //trkBrainInternalLinks.Value = _itemOptions.BrainLinksPerNeuron_Internal;
            //trkBrainExternalLinkSensor.Value = _itemOptions.BrainLinksPerNeuron_External_FromSensor;
            //trkBrainExternalLinkBrain.Value = _itemOptions.BrainLinksPerNeuron_External_FromBrain;
            //trkThrusterExternalLinkSensor.Value = _itemOptions.ThrusterLinksPerNeuron_Sensor;
            //trkThrusterExternalLinkBrain.Value = _itemOptions.ThrusterLinksPerNeuron_Brain;

            //trkBrainDensity.Value = _itemOptions.BrainDensity;
            //trkGravSensorDensity.Value = _itemOptions.SensorDensity;
            //trkEnergyTankDensity.Value = _itemOptions.EnergyTankDensity;
            //trkFuelTankDensity.Value = _itemOptions.FuelTankWallDensity;
            //trkFuelDensity.Value = _itemOptions.FuelDensity;
            //trkThrusterDensity.Value = _itemOptions.ThrusterDensity;
            //trkMomentOfInertia.Value = _itemOptions.MomentOfInertiaMultiplier;

            _isInitialized = true;
        }
        private static Neuron_SensorPosition[] CreateNeurons(ShipPartDNA dna, ItemOptions itemOptions, LifeEventToVector lifeEvents)
        {
            //TODO: Instead of just having a single output neuron for each life event type, report the type at location?
            //For example: the camera's input is a square, so have a grid of blocks.  The output grid doesn't need to be very high
            //resolution, maybe 3x3 up to 5x5.  Each block would be a line of neurons perpendicular to the square

            double radius = (dna.Scale.X + dna.Scale.Y + dna.Scale.Z) / (3d * 2d);		// xyz should all be the same anyway

            Vector3D[] positions = Brain.GetNeuronPositions_Line2D(null, lifeEvents.Types.Length, radius);

            return positions.
                Select(o => new Neuron_SensorPosition(o.ToPoint(), true)).
                ToArray();
        }
        public SensorVelocity(EditorOptions options, ItemOptions itemOptions, ShipPartDNA dna, IContainer energyTanks)
            : base(options, dna, itemOptions.Sensor_Damage.HitpointMin, itemOptions.Sensor_Damage.HitpointSlope, itemOptions.Sensor_Damage.Damage)
        {
            _itemOptions = itemOptions;
            _energyTanks = energyTanks;

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

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

            this.Radius = radius;

            _neurons = SensorGravity.CreateNeurons(dna, itemOptions, itemOptions.VelocitySensor_NeuronDensity);
            _neuronMaxRadius = _neurons.Max(o => o.PositionLength);
        }
        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;
        }
Exemple #30
0
        public FuelTank(EditorOptions options, ItemOptions itemOptions, ShipPartDNA dna)
            : base(options, dna, itemOptions.FuelTank_Damage.HitpointMin, itemOptions.FuelTank_Damage.HitpointSlope, itemOptions.FuelTank_Damage.Damage)
        {
            _itemOptions = itemOptions;

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

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

            _dryMass = surfaceArea * itemOptions.FuelTank_WallDensity;
            this.Radius = radius;

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

            this.Destroyed += FuelTank_Destroyed;
        }
        private static void GetMass(out double mass, out double volume, out double radius, out Vector3D actualScale, ShipPartDNA dna, ItemOptions itemOptions)
        {
            // Just assume it's a cylinder
            double radX = dna.Scale.X * .5 * TractorBeamDesign.RADIUSPERCENTOFSCALE;
            double radY = dna.Scale.Y * .5 * TractorBeamDesign.RADIUSPERCENTOFSCALE;
            double height = dna.Scale.Z * TractorBeamDesign.HEIGHTPERCENTOFSCALE;

            radius = (radX + radY + (height * .5d)) / 3d;		// this is just an approximation for the neural container

            actualScale = new Vector3D(radX * 2d, radY * 2d, height);

            volume = Math.PI * radX * radY * height;

            mass = volume * itemOptions.TractorBeam_Density;
        }
Exemple #32
0
        /// <remarks>
        /// Got ellipse circumference equation here:
        /// http://paulbourke.net/geometry/ellipsecirc/
        /// </remarks>
        internal static Container GetContainer(out double surfaceArea, out Vector3D actualScale, out double radius, ItemOptions itemOptions, ShipPartDNA dna)
        {
            Container retVal = new Container();

            retVal.OnlyRemoveMultiples = false;

            // The fuel tank is a cylinder with two half spheres on each end (height along z.  x and y are supposed to be the same)
            // But when it gets squeezed/stretched along z, the caps don't keep their aspect ratio.  Their height always makes up half of the total height

            #region XYZ H

            double radX = dna.Scale.X * FuelTankDesign.RADIUSPERCENTOFSCALE;
            double radY = dna.Scale.Y * FuelTankDesign.RADIUSPERCENTOFSCALE;
            double radZ = dna.Scale.Z * FuelTankDesign.RADIUSPERCENTOFSCALE;
            double height = dna.Scale.Z - (radZ * 2);
            if (height < 0)
            {
                throw new ApplicationException(string.Format("height should never be zero.  ScaleZ={0}, RAD%SCALE={1}, heigth={2}", dna.Scale.Z.ToString(), FuelTankDesign.RADIUSPERCENTOFSCALE.ToString(), height.ToString()));
            }

            #endregion

            #region Volume

            double sphereVolume = 4d / 3d * Math.PI * radX * radY * radZ;

            double cylinderVolume = Math.PI * radX * radY * height;

            retVal.QuantityMax = sphereVolume + cylinderVolume;

            #endregion

            #region Surface Area

            // While I have the various radius, calculate the dry mass

            double cylinderSA = 0d;

            if (height > 0d)
            {
                // Ellipse circumference = pi (a + b) [ 1 + 3 h / (10 + (4 - 3 h)1/2 ) ]
                // (a=xrad, b=yrad, h = (a - b)^2 / (a + b)^2)  (Ramanujan, second approximation)
                double h = Math.Pow((radX - radY), 2d) / Math.Pow((radX + radY), 2d);
                double circumference = Math.PI * (radX + radY) * (1d + (3d * h) / Math.Pow(10d + (4d - (3d * h)), .5d));

                // Cylinder side surface area = ellipse circ * height
                cylinderSA = circumference * height;
            }

            // Sphere surface area = 4 pi ((a^p * b^p) + (a^p * c^p) + (b^p * c^p) / 3) ^ (1/p)
            // p=1.6075
            double p = 1.6075d;
            double a = Math.Pow(radX, p);
            double b = Math.Pow(radY, p);
            double c = Math.Pow(radZ, p);
            double sphereSA = 4 * Math.PI * Math.Pow(((a * b) + (a * c) + (b * c) / 3d), (1d / p));

            // Combine them
            surfaceArea = cylinderSA + sphereSA;

            #endregion

            actualScale = new Vector3D(radX * 2d, radY * 2d, dna.Scale.Z);

            // Exit Function
            radius = (radX + radY + height) / 3d;       // this is just approximate, and is used by INeuronContainer
            return retVal;
        }
Exemple #33
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                _itemOptions = new ItemOptions();

                #region Init World

                _boundryMin = new Point3D(-BOUNDRYSIZEHALF, -BOUNDRYSIZEHALF, -BOUNDRYSIZEHALF);
                _boundryMax = new Point3D(BOUNDRYSIZEHALF, BOUNDRYSIZEHALF, BOUNDRYSIZEHALF);

                _world           = new World();
                _world.Updating += new EventHandler <WorldUpdatingArgs>(World_Updating);

                _world.SetCollisionBoundry(_boundryMin, _boundryMax);

                //TODO: Only draw the boundry lines if options say to

                #endregion
                #region Materials

                _materialManager = new MaterialManager(_world);

                // Wall
                Game.Newt.v2.NewtonDynamics.Material material = new Game.Newt.v2.NewtonDynamics.Material();
                material.Elasticity = .1d;
                _material_Wall      = _materialManager.AddMaterial(material);

                // Bot
                material      = new Game.Newt.v2.NewtonDynamics.Material();
                _material_Bot = _materialManager.AddMaterial(material);

                // Exploding Bot
                material = new Game.Newt.v2.NewtonDynamics.Material();
                material.IsCollidable  = false;
                _material_ExplodingBot = _materialManager.AddMaterial(material);

                // Food
                material            = new Game.Newt.v2.NewtonDynamics.Material();
                material.Elasticity = .1d;
                _material_Food      = _materialManager.AddMaterial(material);

                // Egg
                material            = new Game.Newt.v2.NewtonDynamics.Material();
                material.Elasticity = .5d;
                _material_Egg       = _materialManager.AddMaterial(material);

                // Projectile
                material             = new Game.Newt.v2.NewtonDynamics.Material();
                _material_Projectile = _materialManager.AddMaterial(material);

                // Collisions
                _materialManager.RegisterCollisionEvent(_material_Bot, _material_Bot, Collision_BotBot);
                _materialManager.RegisterCollisionEvent(_material_Bot, _material_Food, Collision_BotFood);
                //TODO: May want to listen to projectile collisions

                #endregion
                #region Trackball

                // Trackball
                _trackball                       = new TrackBallRoam(_camera);
                _trackball.KeyPanScale           = 15d;
                _trackball.EventSource           = grdViewPort; //NOTE:  If this control doesn't have a background color set, the trackball won't see events (I think transparent is ok, just not null)
                _trackball.AllowZoomOnMouseWheel = true;
                _trackball.Mappings.AddRange(TrackBallMapping.GetPrebuilt(TrackBallMapping.PrebuiltMapping.MouseComplete_NoLeft));
                _trackball.Mappings.AddRange(TrackBallMapping.GetPrebuilt(TrackBallMapping.PrebuiltMapping.Keyboard_ASDW_In));
                _trackball.ShouldHitTestOnOrbit = true;
                //_trackball.UserMovedCamera += new EventHandler<UserMovedCameraArgs>(Trackball_UserMovedCamera);
                //_trackball.GetOrbitRadius += new EventHandler<GetOrbitRadiusArgs>(Trackball_GetOrbitRadius);

                #endregion
                #region Camera Pool

                //TODO: Make the number of threads more configurable, look at how many processors there are
                //_cameraPool = new CameraPool(2, Colors.Black);
                _cameraPool = new CameraPool(1, Colors.Black);

                #endregion
                #region Map

                _map = new Map(_viewport, _cameraPool, _world)
                {
                    SnapshotFequency_Milliseconds = 250,        // 125
                    SnapshotMaxItemsPerNode       = 10,
                    ShouldBuildSnapshots          = true,
                    ShouldShowSnapshotLines       = false,
                    ShouldSnapshotCentersDrift    = true,
                };

                _updateManager = new UpdateManager(
                    new Type[] { typeof(Swimbot) },
                    new Type[] { typeof(Swimbot) },
                    _map);

                #endregion
                #region Fields

                _radiation = new RadiationField()
                {
                    AmbientRadiation = 0d,
                };

                //_gravity = new GravityFieldUniform()
                //{
                //    Gravity = new Vector3D(0, 0, 0),
                //};

                //TODO: Support a uniform fluid
                //FluidField

                #endregion
                #region ItemSelectDragLogic

                _selectionLogic = new ItemSelectDragLogic(_map, _camera, _viewport, grdViewPort)
                {
                    ShouldMoveItemWithSpring = true,
                    ShouldSpringCauseTorque  = false,
                    SpringColor      = null,  // Colors.Chartreuse
                    ShowDebugVisuals = false, // true
                };

                _selectionLogic.SelectableTypes.Add(typeof(Bot));
                _selectionLogic.SelectableTypes.Add(typeof(Mineral));
                _selectionLogic.SelectableTypes.Add(typeof(Egg <ShipDNA>));

                _selectionLogic.ItemSelected += new EventHandler <ItemSelectedArgs>(SelectionLogic_ItemSelected);

                #endregion

                _world.UnPause();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #34
0
        private static void GetMass(out double mass, out double volume, out double radius, out Vector3D actualScale, ShipPartDNA dna, ItemOptions itemOptions)
        {
            radius  = (dna.Scale.X + dna.Scale.Y + dna.Scale.Z) / (3d * 2d); // they should be identical anyway
            radius *= SwarmBayDesign.SCALE;                                  // scale it

            volume = 4d / 3d * Math.PI * radius * radius * radius;
            mass   = volume * itemOptions.SwarmBay_Density;

            actualScale = new Vector3D(radius * 2d, radius * 2d, radius * 2d);
        }
Exemple #35
0
 public Item Add(Item item)
 {
     return(ItemOptions.agregar(item));
 }
Exemple #36
0
        internal static void GetMass(out double mass, out double volume, out double radius, out Vector3D actualScale, ShipPartDNA dna, ItemOptions itemOptions)
        {
            double radiusLocal     = ((dna.Scale.X * MotionController2Design.SIZEPERCENTOFSCALE_XY) + (dna.Scale.Y * MotionController2Design.SIZEPERCENTOFSCALE_XY)) / (2d * 2d); // scale is diameter, so divide an extra two to get radius
            double heightLocal     = dna.Scale.Z * MotionController2Design.SIZEPERCENTOFSCALE_Z;
            double halfHeightLocal = heightLocal / 2d;

            volume = Math.PI * radiusLocal * radiusLocal * heightLocal;         // get volume of the cylinder

            // This isn't the radius of the cylinder, it is the radius of the bounding sphere
            radius = Math.Sqrt((radiusLocal * radiusLocal) + (halfHeightLocal * halfHeightLocal));

            mass = volume * itemOptions.Sensor_Density;

            actualScale = new Vector3D(dna.Scale.X * MotionController2Design.SIZEPERCENTOFSCALE_XY, dna.Scale.Y * MotionController2Design.SIZEPERCENTOFSCALE_XY, dna.Scale.Z * MotionController2Design.SIZEPERCENTOFSCALE_Z);
        }
Exemple #37
0
 public Boolean Update(Item item)
 {
     return(ItemOptions.actualizar(item));
 }
        private readonly double _volume;		// this is used to calculate energy draw

        #endregion

        #region Constructor

        public CameraColorRGB(EditorOptions options, ItemOptions itemOptions, ShipPartDNA dna, IContainer energyTanks, CameraPool cameraPool)
            : base(options, dna, itemOptions.CameraColorRGB_Damage.HitpointMin, itemOptions.CameraColorRGB_Damage.HitpointSlope, itemOptions.CameraColorRGB_Damage.Damage)
        {
            _itemOptions = itemOptions;
            _energyTanks = energyTanks;
            _cameraPool = cameraPool;

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

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

            this.Radius = radius;
            _scaleActual = new Vector3D(radius * 2d, radius * 2d, radius * 2d);

            //TODO: Rework this method to take in the number of cone types (plates of neurons), instead of hardcoding to 3 and having all these out params
            CreateNeurons(out _neuronsR, out _neuronsG, out _neuronsB, out _overlayR, out _overlayG, out _overlayB, out _pixelWidthHeight, dna, itemOptions, itemOptions.CameraColorRGB_NeuronDensity);

            if (_cameraPool != null)
            {
                _cameraPool.Add(this);
            }
        }
Exemple #39
0
        private static void GetMass(out double mass, out double volume, out double radius, out Vector3D actualScale, ShipPartDNA dna, ItemOptions itemOptions)
        {
            // Just assume it's a cylinder
            double radX   = dna.Scale.X * .5 * TractorBeamDesign.RADIUSPERCENTOFSCALE;
            double radY   = dna.Scale.Y * .5 * TractorBeamDesign.RADIUSPERCENTOFSCALE;
            double height = dna.Scale.Z * TractorBeamDesign.HEIGHTPERCENTOFSCALE;

            radius = (radX + radY + (height * .5d)) / 3d;               // this is just an approximation for the neural container

            actualScale = new Vector3D(radX * 2d, radY * 2d, height);

            volume = Math.PI * radX * radY * height;

            mass = volume * itemOptions.TractorBeam_Density;
        }
        internal static void CreateNeurons(out Neuron_SensorPosition[] neuronsR, out Neuron_SensorPosition[] neuronsG, out Neuron_SensorPosition[] neuronsB, out OverlayResult[][] overlayR, out OverlayResult[][] overlayG, out OverlayResult[][] overlayB, out int pixelWidthHeight, ShipPartDNA dna, ItemOptions itemOptions, double neuronDensity)
        {
            const int MINPIXELWIDTH = 16;

            #region Calculate counts

            // Figure out how many neurons to make
            //NOTE: This radius isn't taking SCALE into account.  The other neural parts do this as well, so the neural density properties can be more consistent
            double radius = (dna.Scale.X + dna.Scale.Y + dna.Scale.Z) / (3d * 2d);		// xyz should all be the same anyway
            double area = Math.Pow(radius, itemOptions.Sensor_NeuronGrowthExponent);

            int neuronCount = Convert.ToInt32(Math.Ceiling(neuronDensity * area));
            if (neuronCount == 0)
            {
                neuronCount = 1;
            }

            // Figure out how many pixels to make
            pixelWidthHeight = neuronCount / 9;     // dividing by 3 to get the number of neurons in a single plate.  divide that by 3, because that's a good ratio of neuron cells to pixels
            if (pixelWidthHeight < MINPIXELWIDTH)
            {
                pixelWidthHeight = MINPIXELWIDTH;
            }

            #endregion

            #region Neurons

            // Place them evenly in a sphere
            //NOTE: An interesting side effect of calling this for each generation is that the parent may not have been perfectly evenly spaced, but calling this
            //again will slightly refine the positions
            Vector3D[][] positions = GetNeuronPositions(dna.Neurons, neuronCount, 3, radius);

            // Create neurons
            neuronsR = positions[0].Select(o => new Neuron_SensorPosition(o.ToPoint(), true)).ToArray();
            neuronsG = positions[1].Select(o => new Neuron_SensorPosition(o.ToPoint(), true)).ToArray();
            neuronsB = positions[2].Select(o => new Neuron_SensorPosition(o.ToPoint(), true)).ToArray();

            #endregion

            #region Polygons around neurons

            // Figure out which pixels each neuron intersects with
            VoronoiResult2D[] voronoi = new VoronoiResult2D[3];
            voronoi[0] = Math2D.CapVoronoiCircle(Math2D.GetVoronoi(positions[0].Select(o => new Point(o.X, o.Y)).ToArray(), true));
            voronoi[1] = Math2D.CapVoronoiCircle(Math2D.GetVoronoi(positions[1].Select(o => new Point(o.X, o.Y)).ToArray(), true));
            voronoi[2] = Math2D.CapVoronoiCircle(Math2D.GetVoronoi(positions[2].Select(o => new Point(o.X, o.Y)).ToArray(), true));

            #region Figure out the extremes

            Point[] allEdgePoints = voronoi.SelectMany(o => o.EdgePoints).ToArray();

            Point min = new Point(allEdgePoints.Min(o => o.X), allEdgePoints.Min(o => o.Y));
            Point max = new Point(allEdgePoints.Max(o => o.X), allEdgePoints.Max(o => o.Y));

            double width = max.X - min.X;
            double height = max.Y - min.Y;

            // Enlarge a bit
            min.X -= width * .05d;
            min.Y -= height * .05d;
            max.X += width * .05d;
            max.Y += height * .05d;

            width = max.X - min.X;
            height = max.Y - min.Y;

            Vector offset = new Vector(-min.X, -min.Y);

            #endregion

            //  Figure out which pixels each polygon overlaps
            overlayR = GetIntersections(new Size(width, height), pixelWidthHeight, pixelWidthHeight, GetPolygons(voronoi[0], offset));
            overlayG = GetIntersections(new Size(width, height), pixelWidthHeight, pixelWidthHeight, GetPolygons(voronoi[1], offset));
            overlayB = GetIntersections(new Size(width, height), pixelWidthHeight, pixelWidthHeight, GetPolygons(voronoi[2], offset));

            #endregion
        }
Exemple #41
0
 private static void GetNeuronVolume(out double radius, out double volume, ShipPartDNA dna, ItemOptions itemOptions)
 {
     //NOTE: This radius isn't taking SCALE into account.  The other neural parts do this as well, so the neural density properties can be more consistent
     radius = (dna.Scale.X + dna.Scale.Y + dna.Scale.Z) / (3d * 2d);             // xyz should all be the same anyway
     volume = Math.Pow(radius, itemOptions.Brain_NeuronGrowthExponent);
 }
Exemple #42
0
        private void FinishLoad(FlyingBeanSession session, FlyingBeanOptions options, ItemOptions itemOptions, ShipDNA[] winningBeans, string saveFolder, bool startEmpty)
        {
            // Manually instantiate some of the properties that didn't get serialized
            options.DefaultBeanList = _defaultBeanList;

            if (options.NewBeanList == null)            // if this was called by new, it will still be null
            {
                options.NewBeanList = new SortedList <string, ShipDNA>();

                if (!startEmpty)
                {
                    string[] beanKeys = options.DefaultBeanList.Keys.ToArray();

                    foreach (int keyIndex in UtilityCore.RandomRange(0, beanKeys.Length, Math.Min(3, beanKeys.Length)))         // only do 3 of the defaults
                    {
                        string key = beanKeys[keyIndex];
                        options.NewBeanList.Add(key, options.DefaultBeanList[key]);
                    }
                }
            }

            options.MutateArgs = PanelMutation.BuildMutateArgs(options);

            options.GravityField = new GravityFieldUniform();
            options.Gravity      = options.Gravity;     // the property set modifies the gravity field

            options.WinnersLive = new WinnerList(true, options.TrackingMaxLineagesLive, options.TrackingMaxPerLineageLive);

            if (options.WinnersFinal == null)           // if a previous save had winning ships, this will already be loaded with them
            {
                options.WinnersFinal = new WinnerList(false, options.TrackingMaxLineagesFinal, options.TrackingMaxPerLineageFinal);
            }

            options.WinnerCandidates = new CandidateWinners();
            // These are already in the final list, there's no point in putting them in the candidate list as well
            //if (winningBeans != null)
            //{
            //    foreach (ShipDNA dna in winningBeans)
            //    {
            //        options.WinnerCandidates.Add(dna);
            //    }
            //}

            // Make sure the session folder is up to date
            if (saveFolder == null)
            {
                this.SessionFolder = null;
            }
            else
            {
                string dirChar = Regex.Escape(System.IO.Path.DirectorySeparatorChar.ToString());

                string pattern = dirChar + Regex.Escape(FlyingBeansWindow.SESSIONFOLDERPREFIX) + "[^" + dirChar + "]+(?<upto>" + dirChar + ")" + Regex.Escape(FlyingBeansWindow.SAVEFOLDERPREFIX);
                Match  match   = Regex.Match(saveFolder, pattern, RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    this.SessionFolder = saveFolder.Substring(0, match.Groups["upto"].Index);           // the session folder is everything before the save subfolder
                }
                else
                {
                    // They may have chosen a folder that they unziped onto their desktop, or wherever.  Leaving this null so that if they hit save, it will be saved
                    // in the appropriate location
                    this.SessionFolder = null;
                }
            }

            // Swap out the settings
            this.Session     = session;
            this.Options     = options;
            this.ItemOptions = itemOptions;

            // Inform the world
            if (this.SessionChanged != null)
            {
                this.SessionChanged(this, new EventArgs());
            }
        }
 public LoginController(IAccountService accountService, IConfiguration configuration, ItemOptions itemOptions) : base(accountService, configuration, itemOptions)
 {
 }
Exemple #44
0
        public PanelFile(string sessionFolder, FlyingBeanSession session, FlyingBeanOptions options, ItemOptions itemOptions, SortedList <string, ShipDNA> defaultBeanList)
        {
            InitializeComponent();

            _defaultBeanList = defaultBeanList;

            this.SessionFolder = sessionFolder;
            this.Session       = session;
            this.Options       = options;
            this.ItemOptions   = itemOptions;

            _isInitialized = true;
        }
Exemple #45
0
        public Bot(BotConstruction_Result construction)
        {
            _options     = construction.ArgsExtra.Options;
            _itemOptions = construction.ArgsExtra.ItemOptions;

            _radiation  = construction.ArgsExtra.Radiation;
            _gravity    = construction.ArgsExtra.Gravity;
            _cameraPool = construction.ArgsExtra.CameraPool;

            _parts                     = construction.PartConstruction;
            _thrusters                 = construction.PartConstruction.GetStandardParts <Thruster>(Thruster.PARTTYPE).ToArray();
            _impulseEngines            = construction.PartConstruction.GetStandardParts <ImpulseEngine>(ImpulseEngine.PARTTYPE).ToArray();
            _projectileGuns            = construction.PartConstruction.GetStandardParts <ProjectileGun>(ProjectileGun.PARTTYPE).ToArray();
            _updatableParts_MainThread = construction.UpdatableParts_MainThread;
            _updatableParts_AnyThread  = construction.UpdatableParts_AnyThread;
            _dna      = construction.DNA;
            _dnaParts = construction.DNAParts;

            this.Model     = construction.Model;
            _visualEffects = construction.VisualEffects;

            _isPhysicsStatic = construction.ArgsExtra.IsPhysicsStatic;
            this.PhysicsBody = construction.PhysicsBody;

            this.Radius = construction.Radius;

            _partTransformToModel = _parts.AllPartsArray.
                                    Select(o =>
            {
                Transform3DGroup transform = new Transform3DGroup();
                transform.Children.Add(new TranslateTransform3D(-o.Position.ToVector()));
                transform.Children.Add(new RotateTransform3D(new QuaternionRotation3D(o.Orientation.ToReverse())));
                return(transform);
            }).
                                    ToArray();

            // Hook up events
            if (!_isPhysicsStatic)
            {
                this.PhysicsBody.ApplyForceAndTorque += new EventHandler <BodyApplyForceAndTorqueArgs>(PhysicsBody_ApplyForceAndTorque);
            }

            foreach (var part in _parts.AllPartsArray)
            {
                part.RequestWorldLocation += new EventHandler <PartRequestWorldLocationArgs>(Part_RequestWorldLocation);
                part.RequestWorldSpeed    += new EventHandler <PartRequestWorldSpeedArgs>(Part_RequestWorldSpeed);
                part.RequestParent        += new EventHandler <PartRequestParentArgs>(Part_RequestParent);

                part.Resurrected += Part_Resurrected;
                part.Destroyed   += Part_Destroyed;
            }

            // See if there are parts that can gradually change the ship's mass
            if ((_parts.Containers.Fuels.Count > 0 && _parts.StandardParts.ContainsKey(Thruster.PARTTYPE)) ||
                (_parts.Containers.CargoBays.Count > 0 && (_parts.StandardParts.ContainsKey(ConverterMatterToEnergy.PARTTYPE) || _parts.StandardParts.ContainsKey(ConverterMatterToFuel.PARTTYPE))) ||
                (_parts.Containers.Energies.Count > 0 && _parts.Containers.Fuels.Count > 0 && (_parts.StandardParts.ContainsKey(ConverterEnergyToFuel.PARTTYPE) || _parts.StandardParts.ContainsKey(ConverterFuelToEnergy.PARTTYPE)))
                )
            {
                _hasMassChangingUpdatables_Small = true;
            }
            else
            {
                _hasMassChangingUpdatables_Small = false;
            }

            if (_parts.Containers.Ammos.Count > 0 && _parts.StandardParts.ContainsKey(ProjectileGun.PARTTYPE))
            {
                _hasMassChangingUpdatables_Medium = true;
            }
            else
            {
                _hasMassChangingUpdatables_Medium = false;
            }

            // Set up a neural processor on its own thread/task
            _neuronLinks = construction.Links;
            if (_neuronLinks != null)
            {
                var result = AddToNeuralPool(_neuronLinks, construction.ArgsExtra.NeuralPoolManual);
                _linkBucket           = result.bucket;
                _neuralPoolAddTask    = result.addTask;
                _neuralPoolManualTick = result.manualPool;
            }

            _lifeEvents = construction.PartConstruction.LifeEventWatcher;

            this.ShouldRecalcMass_Large = false;
            this.ShouldRecalcMass_Small = false;

            this.CreationTime = DateTime.UtcNow;
        }
        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);
        }
Exemple #47
0
        private static void GetMass(out double mass, out double volume, out double radius, ShipPartDNA dna, ItemOptions itemOptions)
        {
            radius = (dna.Scale.X + dna.Scale.Y + dna.Scale.Z) / (3d * 2d);		// they should be identical anyway
            radius *= BrainDesign.SCALE;		// scale it

            volume = 4d / 3d * Math.PI * radius * radius * radius;
            mass = volume * itemOptions.Brain_Density;
        }
Exemple #48
0
        internal static void GetMass(out double mass, out double volume, out double radius, out Vector3D scaleActual, ShipPartDNA dna, ItemOptions itemOptions)
        {
            radius  = (dna.Scale.X + dna.Scale.Y + dna.Scale.Z) / (3d * 2d); // they should be identical anyway
            radius *= BrainDesign.SCALE;                                     // scale it

            volume = 4d / 3d * Math.PI * radius * radius * radius;
            mass   = volume * itemOptions.Brain_Density;

            scaleActual = new Vector3D(radius * 2d, radius * 2d, radius * 2d);
        }
Exemple #49
0
        private static Neuron_NegPos[] CreateNeurons(ShipPartDNA dna, ItemOptions itemOptions, Point3D[] brainChemicalPositions)
        {
            // Figure out how many to make
            double radius, volume;
            GetNeuronVolume(out radius, out volume, dna, itemOptions);

            int count = Convert.ToInt32(Math.Round(itemOptions.Brain_NeuronDensity * volume));
            if (count == 0)
            {
                count = 1;
            }

            // Figure out the positions
            Vector3D[] positions = GetNeuronPositions_Cluster(dna.Neurons, brainChemicalPositions, 3d, count, radius, itemOptions.Brain_NeuronMinClusterDistPercent);

            // Exit Function
            return positions.Select(o => new Neuron_NegPos(o.ToPoint())).ToArray();
        }
Exemple #50
0
        private static List <Stat> GetRandomOptions(ItemOptions list, int rolls)
        {
            Random random = new Random();

            return(list.Stats.OrderBy(x => random.Next()).Take(rolls).ToList());
        }
Exemple #51
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;
        }
Exemple #52
0
        protected override List <ItemStatsMetadata> Parse()
        {
            List <ItemStatsMetadata> items = new List <ItemStatsMetadata>();

            foreach (PackFileEntry entry in Resources.XmlFiles)
            {
                if (!entry.Name.StartsWith("itemoption/constant") && !entry.Name.StartsWith("itemoption/option/random") && !entry.Name.StartsWith("itemoption/option/static"))
                {
                    continue;
                }
                if (entry.Name.Contains("petequipment.xml") || entry.Name.Contains("weaponmanual.xml") || entry.Name.Contains("armormanual.xml") || entry.Name.Contains("accmanual.xml") || entry.Name.Contains("etc.xml") || entry.Name.Contains("gemstone.xml") || entry.Name.Contains("mergematerial.xml") || entry.Name.Contains("skin.xml"))
                {
                    continue;
                }

                XmlDocument innerDocument = Resources.XmlMemFile.GetDocument(entry.FileHeader);
                XmlNodeList nodeList      = innerDocument.SelectNodes("/ms2/option");
                string      filename      = Path.GetFileNameWithoutExtension(entry.Name);

                foreach (XmlNode node in nodeList)
                {
                    ItemStatsMetadata metadata        = new ItemStatsMetadata();
                    ItemOptions       optionsMetadata = new ItemOptions();
                    List <Stat>       statMetadata    = new List <Stat>();
                    int itemId = string.IsNullOrEmpty(node.Attributes["code"]?.Value) ? 0 : int.Parse(node.Attributes["code"].Value);
                    metadata.ItemId = itemId;

                    byte grade = string.IsNullOrEmpty(node.Attributes["grade"]?.Value) ? 0 : byte.Parse(node.Attributes["grade"].Value);
                    optionsMetadata.Rarity = grade;

                    if (!string.IsNullOrEmpty(node.Attributes["optionNumPick"]?.Value))
                    {
                        List <string> list = new List <string>(node.Attributes["optionNumPick"].Value.Split(","));
                        optionsMetadata.Slots = byte.Parse(list[0]);
                    }
                    if ((entry.Name.Contains("random") || entry.Name.Contains("static")) && optionsMetadata.Slots == 0)
                    {
                        continue;
                    }

                    float abp = string.IsNullOrEmpty(node.Attributes["abp_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["abp_rate_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.PerfectGuard, abp));

                    int asp = string.IsNullOrEmpty(node.Attributes["asp_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["asp_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.AttackSpeed, asp));

                    int atp = string.IsNullOrEmpty(node.Attributes["atp_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["atp_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.Accuracy, atp));

                    int bappet = string.IsNullOrEmpty(node.Attributes["bap_pet_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["bap_pet_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.PetBonusAtk, bappet));

                    int bap = string.IsNullOrEmpty(node.Attributes["bap_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["bap_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.BonusAtk, bap));

                    int cad = string.IsNullOrEmpty(node.Attributes["cad_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["cad_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.CriticalDamage, cad));

                    int cap = string.IsNullOrEmpty(node.Attributes["cap_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["cap_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.CriticalRate, cap));

                    int car = string.IsNullOrEmpty(node.Attributes["car_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["car_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.CriticalEvasion, car));

                    // float conditionreduce = string.IsNullOrEmpty(node.Attributes["conditionreduce_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["conditionreduce_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float darkdamage = string.IsNullOrEmpty(node.Attributes["darkdamage_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["darkdamage_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float darkdamagereduce = string.IsNullOrEmpty(node.Attributes["darkdamagereduce_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["darkdamagereduce_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    int dex = string.IsNullOrEmpty(node.Attributes["dex_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["dex_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.Dexterity, dex));

                    int evp = string.IsNullOrEmpty(node.Attributes["evp_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["evp_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.Evasion, evp));

                    // float finaladditionaldamage = string.IsNullOrEmpty(node.Attributes["finaladditionaldamage_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["finaladditionaldamage_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float firedamage = string.IsNullOrEmpty(node.Attributes["firedamage_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["firedamage_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float firedamagereduce = string.IsNullOrEmpty(node.Attributes["firedamagereduce_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["firedamagereduce_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float heal = string.IsNullOrEmpty(node.Attributes["heal_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["heal_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // int hiddennddadd = string.IsNullOrEmpty(node.Attributes["hiddennddadd_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["hiddennddadd_value_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // int hiddenwapadd = string.IsNullOrEmpty(node.Attributes["hiddenwapadd_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["hiddenwapadd_value_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    int hprgp = string.IsNullOrEmpty(node.Attributes["hp_rgp_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["hp_rgp_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.HpRegen, hprgp));

                    int hp = string.IsNullOrEmpty(node.Attributes["hp_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["hp_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.Health, hp));

                    // float icedamage = string.IsNullOrEmpty(node.Attributes["icedamage_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["icedamage_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float icedamagereduce = string.IsNullOrEmpty(node.Attributes["icedamagereduce_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["icedamagereduce_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    int int_ = string.IsNullOrEmpty(node.Attributes["int_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["int_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.Intelligence, int_));

                    int killhprestore = string.IsNullOrEmpty(node.Attributes["killhprestore_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["killhprestore_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.HpRegen, killhprestore));

                    // int knockbackreduce = string.IsNullOrEmpty(node.Attributes["knockbackreduce_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["knockbackreduce_value_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float lddincrease = string.IsNullOrEmpty(node.Attributes["lddincrease_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["lddincrease_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float longdistancedamagereduce = string.IsNullOrEmpty(node.Attributes["longdistancedamagereduce_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["longdistancedamagereduce_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float lightdamage = string.IsNullOrEmpty(node.Attributes["lightdamage_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["lightdamage_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float lightdamagereduce = string.IsNullOrEmpty(node.Attributes["lightdamagereduce_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["lightdamagereduce_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    int luk = string.IsNullOrEmpty(node.Attributes["luk_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["luk_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.Luck, luk));

                    int map = string.IsNullOrEmpty(node.Attributes["map_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["map_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.MagicalAtk, map));

                    int mar = string.IsNullOrEmpty(node.Attributes["mar_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["mar_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.MagicalRes, mar));

                    // float marpen = string.IsNullOrEmpty(node.Attributes["marpen_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["marpen_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    int msp = string.IsNullOrEmpty(node.Attributes["msp_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["msp_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.MovementSpeed, msp));

                    float multiplyfactor = string.IsNullOrEmpty(node.Attributes["multiply_factor"]?.Value) ? 0 : float.Parse(node.Attributes["multiply_factor"].Value);
                    optionsMetadata.MultiplyFactor = multiplyfactor;

                    int ndd = string.IsNullOrEmpty(node.Attributes["ndd_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["ndd_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.Defense, ndd));

                    // float nddcalibrationfactor = string.IsNullOrEmpty(node.Attributes["nddcalibrationfactor_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["nddcalibrationfactor_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float nddincrease = string.IsNullOrEmpty(node.Attributes["nddincrease_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["nddincrease_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float neardistancedamagereduce = string.IsNullOrEmpty(node.Attributes["neardistancedamagereduce_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["neardistancedamagereduce_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    int pap = string.IsNullOrEmpty(node.Attributes["pap_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["pap_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.PhysicalAtk, pap));

                    int par = string.IsNullOrEmpty(node.Attributes["par_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["par_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.PhysicalRes, par));

                    // float parpen = string.IsNullOrEmpty(node.Attributes["parpen_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["parpen_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    float pen = string.IsNullOrEmpty(node.Attributes["pen_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["pen_rate_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.Piercing, pen));

                    // float poisondamage = string.IsNullOrEmpty(node.Attributes["poisondamage_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["poisondamage_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float poisondamagereduce = string.IsNullOrEmpty(node.Attributes["poisondamagereduce_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["poisondamagereduce_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float receivedhealincrease = string.IsNullOrEmpty(node.Attributes["receivedhealincrease_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["receivedhealincrease_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // int reducedarkstreamrecivedamage = string.IsNullOrEmpty(node.Attributes["reduce_darkstream_recive_damage_rate_base"]?.Value) ? 0 : int.Parse(node.Attributes["reduce_darkstream_recive_damage_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float sgi = string.IsNullOrEmpty(node.Attributes["sgi_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["sgi_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // int sgitarget = string.IsNullOrEmpty(node.Attributes["sgi_target"]?.Value) ? 0 : int.Parse(node.Attributes["sgi_target"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float skillcooldown = string.IsNullOrEmpty(node.Attributes["skillcooldown_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["skillcooldown_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float smd = string.IsNullOrEmpty(node.Attributes["smd_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["smd_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float sss = string.IsNullOrEmpty(node.Attributes["sss_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["sss_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    int str = string.IsNullOrEmpty(node.Attributes["str_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["str_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.Strength, str));

                    // float stunreduce = string.IsNullOrEmpty(node.Attributes["stunreduce_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["stunreduce_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float thunderdamage = string.IsNullOrEmpty(node.Attributes["thunderdamage_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["thunderdamage_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float thunderdamagereduce = string.IsNullOrEmpty(node.Attributes["thunderdamagereduce_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["thunderdamagereduce_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    // float wapcalibrationfactor = string.IsNullOrEmpty(node.Attributes["wapcalibrationfactor_rate_base"]?.Value) ? 0 : float.Parse(node.Attributes["wapcalibrationfactor_rate_base"].Value);
                    // statMetadata.Add(new Stat(ItemAttribute.?, ?));

                    int wapmax = string.IsNullOrEmpty(node.Attributes["wapmax_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["wapmax_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.MaxWeaponAtk, wapmax));

                    int wapmin = string.IsNullOrEmpty(node.Attributes["wapmin_value_base"]?.Value) ? 0 : int.Parse(node.Attributes["wapmin_value_base"].Value);
                    statMetadata.Add(new Stat(ItemAttribute.MinWeaponAtk, wapmin));

                    foreach (Stat x in statMetadata)
                    {
                        if (x.Value != 0 || x.Percentage != 0)
                        {
                            optionsMetadata.Stats.Add(x);
                        }
                    }

                    int index = 0;
                    if (items.Exists(x => itemId == x.ItemId))
                    {
                        index = items.FindIndex(x => itemId == x.ItemId);
                    }
                    else
                    {
                        items.Add(metadata);
                        index = items.Count - 1;
                    }

                    if (filename.Contains("constant"))
                    {
                        items[index].Basic.Add(optionsMetadata);
                    }
                    else if (filename.Contains("static"))
                    {
                        items[index].StaticBonus.Add(optionsMetadata);
                    }
                    else if (filename.Contains("random"))
                    {
                        items[index].RandomBonus.Add(optionsMetadata);
                    }
                }
            }
            return(items);
        }
        private static void GetMass(out double mass, out double volume, out double radius, out Vector3D actualScale, ShipPartDNA dna, ItemOptions itemOptions)
        {
            // Technically, this is a trapazoid cone, but the collision hull and mass breakdown are cylinders, so just treat it like a cylinder

            // If that changes, take the mass of the full cone minus the top cone.  Would need to calculate the height of the full cone based
            // on the slope of wide radius to small radius:
            //  slope=((wide/2 - narrow/2) / height)
            //  fullheight = (-wide/2) / slope   ----   y=mx+b

            double rad = Math1D.Avg(BrainRGBRecognizerDesign.RADIUSPERCENTOFSCALE_WIDE, BrainRGBRecognizerDesign.RADIUSPERCENTOFSCALE_NARROW) * Math1D.Avg(dna.Scale.X, dna.Scale.Y);
            double height = BrainRGBRecognizerDesign.HEIGHT * dna.Scale.Z;

            volume = Math.PI * rad * rad * height;

            mass = volume * itemOptions.Brain_Density;

            radius = Math1D.Avg(rad, height);       // this is just approximate, and is used by INeuronContainer
            actualScale = new Vector3D(rad * 2d, rad * 2d, height);     // I think this is just used to get a bounding box
        }
Exemple #54
0
        public Cargo_ShipPart(ShipPartDNA dna, ItemOptions options, EditorOptions editorOptions)
            : base(CargoType.ShipPart)
        {
            PartDesignBase part = BotConstructor.GetPartDesign(dna, editorOptions, true);

            //TODO: This is really ineficient, let design calculate it for real
            //TODO: Volume and Mass should be calculated by the design class (add to PartBase interface)
            var aabb = Math3D.GetAABB(UtilityWPF.GetPointsFromMesh(part.Model));
            this.Volume = (aabb.Item2.X - aabb.Item1.X) * (aabb.Item2.Y - aabb.Item1.Y) * (aabb.Item2.Y - aabb.Item1.Y);

            //TODO: Let the design class return this (expose a property called DryDensity)
            this.Density = Math1D.Avg(options.Thruster_Density, options.Sensor_Density);

            this.PartDNA = dna;
        }
        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);
        }
Exemple #56
0
        public CargoBay(EditorOptions options, ItemOptions itemOptions, ShipPartDNA dna)
            : base(options, dna, itemOptions.CargoBay_Damage.HitpointMin, itemOptions.CargoBay_Damage.HitpointSlope, itemOptions.CargoBay_Damage.Damage)
        {
            _itemOptions = itemOptions;

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

            double volume, radius;
            GetMass(out _dryMass, out volume, out radius, _itemOptions, dna);

            _scaleActual = new Vector3D(dna.Scale.X, dna.Scale.Y, dna.Scale.Z);

            this.MaxVolume = volume;
            this.Radius = radius;

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

            this.Destroyed += CargoBay_Destroyed;
        }
        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;

        }
Exemple #58
0
        private static void GetMass(out double dryMass, out double volume, out double radius, ItemOptions itemOptions, ShipPartDNA dna)
        {
            // The cargo bay is 1:1 with scale (a lot of the other parts are smaller than scale, but cargo bay is full sized)

            double surfaceArea = (2d * dna.Scale.X * dna.Scale.Y) + (2d * dna.Scale.X * dna.Scale.Z) + (2d * dna.Scale.Y * dna.Scale.Z);
            dryMass = surfaceArea * itemOptions.CargoBay_WallDensity;

            volume = dna.Scale.X * dna.Scale.Y * dna.Scale.Z;

            radius = (dna.Scale.X + dna.Scale.Y + dna.Scale.Z) / 3d;       // this is just approximate, and is used by INeuronContainer
        }
        private static Container GetContainer(out Vector3D actualScale, out double radius, ItemOptions itemOptions, ShipPartDNA dna)
        {
            Container retVal = new Container();

            retVal.OnlyRemoveMultiples = false;

            // Even though it has slightly rounded endcaps, I'll assume it's just a cylinder

            double radX = dna.Scale.X * EnergyTankDesign.RADIUSPERCENTOFSCALE;
            double radY = dna.Scale.Y * EnergyTankDesign.RADIUSPERCENTOFSCALE;
            double height = dna.Scale.Z;

            double cylinderVolume = Math.PI * radX * radY * height;

            retVal.QuantityMax = cylinderVolume;

            actualScale = new Vector3D(radX * 2d, radY * 2d, height);

            // Exit Function
            radius = (radX + radY + height) / 3d;       // this is just approximate, and is used by INeuronContainer
            return retVal;
        }
Exemple #60
0
        private static Container GetContainer(out Vector3D actualScale, out double radius, ItemOptions itemOptions, ShipPartDNA dna)
        {
            Container retVal = new Container();

            retVal.OnlyRemoveMultiples = false;

            // Even though it has slightly rounded endcaps, I'll assume it's just a cylinder

            double radX   = dna.Scale.X * EnergyTankDesign.RADIUSPERCENTOFSCALE;
            double radY   = dna.Scale.Y * EnergyTankDesign.RADIUSPERCENTOFSCALE;
            double height = dna.Scale.Z;

            double cylinderVolume = Math.PI * radX * radY * height;

            retVal.QuantityMax = cylinderVolume;

            actualScale = new Vector3D(radX * 2d, radY * 2d, height);

            // Exit Function
            radius = (radX + radY + height) / 3d;       // this is just approximate, and is used by INeuronContainer
            return(retVal);
        }