示例#1
0
        public void TestOozinozSkyocket()
        {
            double burnArea   = .0030;
            double burnDepth  = .06;
            double burnVolume = burnArea * burnDepth;
            double fuelMass   = burnVolume * FUEL_DENSITY;
            double totalMass  = fuelMass * 1.1;
            double burnRate   = .020;

            PhysicalRocket pr = new PhysicalRocket(burnArea, burnRate, fuelMass, totalMass);

            OozinozSkyrocket or = new OozinozSkyrocket(pr);

            double tol = 0.01;

            or.SetSimTime(0);
            Assert.AreEqual(totalMass, or.GetMass(), tol, "initial mass");
            Assert.AreEqual(SPECIFIC_IMPULSE * FUEL_DENSITY * burnArea * burnRate, or.GetThrust(), tol, "thrust");

            double bt = burnDepth / burnRate;

            or.SetSimTime(bt * 1.01);
            Assert.AreEqual(totalMass - fuelMass, or.GetMass(), tol, "end mass");
            Assert.AreEqual(0, or.GetThrust(), tol, "thrust");
        }
        public void TestOozinozSkyocket()
        {
            double burnArea   = .0030;
            double burnDepth  = .06;
            double burnVolume = burnArea * burnDepth;
            double fuelMass   = burnVolume * FUEL_DENSITY;
            double totalMass  = fuelMass * 1.1;
            double burnRate   = .020;

            PhysicalRocket pr = new PhysicalRocket(burnArea, burnRate, fuelMass, totalMass);

            OozinozSkyrocket or = new OozinozSkyrocket(pr);

            double tol = 0.01;

            or.SetSimTime(0);
            Assertion.AssertEquals("masa pocz¹tkowa", totalMass, or.GetMass(), tol);
            Assertion.AssertEquals("ci¹g", SPECIFIC_IMPULSE * FUEL_DENSITY * burnArea * burnRate, or.GetThrust(), tol);

            double bt = burnDepth / burnRate;

            or.SetSimTime(bt * 1.01);
            Assertion.AssertEquals("masa koñcowa", totalMass - fuelMass, or.GetMass(), tol);
            Assertion.AssertEquals("ci¹g", 0, or.GetThrust(), tol);
        }
示例#3
0
        public void TestPhysicalRocket()
        {
            double burnArea   = .0030;
            double burnDepth  = .06;
            double burnVolume = burnArea * burnDepth;
            double fuelMass   = burnVolume * FUEL_DENSITY;
            double totalMass  = fuelMass * 1.1;
            double burnRate   = .020;

            PhysicalRocket r = new PhysicalRocket(burnArea, burnRate, fuelMass, totalMass);

            double bt  = burnDepth / burnRate;
            double tol = 0.01;

            Assert.AreEqual(bt, r.GetBurnTime(), tol, "check burn time");

            Assert.AreEqual(totalMass, r.GetMass(0), tol, "initial mass");
            Assert.AreEqual(totalMass - fuelMass, r.GetMass(bt), tol, "burnt out mass");
            Assert.AreEqual(totalMass - fuelMass * .5, r.GetMass(bt / 2), tol, "half mass");
            Assert.AreEqual(SPECIFIC_IMPULSE * FUEL_DENSITY * burnArea * burnRate, r.GetThrust(bt / 2), tol, "thrust");
        }
        public void TestPhysicalRocket()
        {
            double burnArea   = .0030;
            double burnDepth  = .06;
            double burnVolume = burnArea * burnDepth;
            double fuelMass   = burnVolume * FUEL_DENSITY;
            double totalMass  = fuelMass * 1.1;
            double burnRate   = .020;

            PhysicalRocket r = new PhysicalRocket(burnArea, burnRate, fuelMass, totalMass);

            double bt  = burnDepth / burnRate;
            double tol = 0.01;

            Assertion.AssertEquals("sprawdzenie czasu spalania", bt, r.GetBurnTime(), tol);

            Assertion.AssertEquals("masa pocz¹tkowa", totalMass, r.GetMass(0), tol);
            Assertion.AssertEquals("masa wypalona", totalMass - fuelMass, r.GetMass(bt), tol);
            Assertion.AssertEquals("po³owa masy", totalMass - fuelMass * .5, r.GetMass(bt / 2), tol);
            Assertion.AssertEquals("ci¹g", SPECIFIC_IMPULSE * FUEL_DENSITY * burnArea * burnRate, r.GetThrust(bt / 2), tol);
        }
        public PhysicalHindWeaponized(
            StarlingGameSpriteWithHindTextures textures_hind,
            StarlingGameSpriteWithRocketTextures textures_rocket,
            StarlingGameSpriteWithPhysics __Context,


            Image Explosion1 = null
            )
            : base(textures_hind, __Context)
        {
            var RocketsMax = 12;
            var Rockets    = new Queue <PhysicalRocket>();

            var Context = __Context;
            var rocket0 = new PhysicalRocket(textures_rocket, Context, Explosion1: Explosion1);

            rocket0.body.SetActive(false);
            rocket0.SetPositionAndAngle(-0.5, 2);


            var rocket1 = new PhysicalRocket(textures_rocket, Context, Explosion1: Explosion1);

            rocket1.body.SetActive(false);
            rocket1.SetPositionAndAngle(-0.5, -2);

            #region z fixup
            rocket0.visual.parent.setChildIndex(
                rocket0.visual,

                this.visual.visualnowings.parent.getChildIndex(
                    this.visual.visualnowings
                    )
                );
            #endregion

            #region z fixup
            rocket1.visual.parent.setChildIndex(
                rocket1.visual,

                this.visual.visualnowings.parent.getChildIndex(
                    this.visual.visualnowings
                    )
                );
            #endregion

            var hind0 = this;

            #region ShowPositionAndAngleForSlaves
            hind0.ShowPositionAndAngleForSlaves = delegate
            {
                // we are faking 3d here!
                var sc = 1 + hind0.visual.airzoom * hind0.visual.Altitude;


                if (rocket0 != null)
                {
                    rocket0.body.SetActive(false);
                    rocket0.Altitude = hind0.visual.Altitude;
                    rocket0.SetPositionAndAngle(


                        hind0.body.GetPosition().x + Math.Cos(hind0.body.GetAngle() - Math.PI * 0.5 - hind0.CameraRotation) * 2.2 * sc,
                        hind0.body.GetPosition().y + Math.Sin(hind0.body.GetAngle() - Math.PI * 0.5 - hind0.CameraRotation) * 2.2 * sc,

                        hind0.body.GetAngle() - hind0.CameraRotation
                        );
                    rocket0.ShowPositionAndAngle();
                }

                if (rocket1 != null)
                {
                    rocket1.body.SetActive(false);
                    rocket1.Altitude = hind0.visual.Altitude;
                    rocket1.SetPositionAndAngle(


                        hind0.body.GetPosition().x + Math.Cos(hind0.body.GetAngle() + Math.PI * 0.5 - hind0.CameraRotation) * 2.2 * sc,
                        hind0.body.GetPosition().y + Math.Sin(hind0.body.GetAngle() + Math.PI * 0.5 - hind0.CameraRotation) * 2.2 * sc,

                        hind0.body.GetAngle() - hind0.CameraRotation
                        );
                    rocket1.ShowPositionAndAngle();
                }
            };
            #endregion

            #region FireRocket
            FireRocket = delegate
            {
                if (rocket0 != null)
                {
                    var sc = 1 + hind0.visual.airzoom * hind0.visual.Altitude;

                    rocket0.SetPositionAndAngle(


                        hind0.body.GetPosition().x + Math.Cos(hind0.body.GetAngle() - Math.PI * 0.5 - hind0.CameraRotation) * 3.5 * sc,
                        hind0.body.GetPosition().y + Math.Sin(hind0.body.GetAngle() - Math.PI * 0.5 - hind0.CameraRotation) * 3.5 * sc,

                        hind0.body.GetAngle() - hind0.CameraRotation
                        );
                    rocket0.ShowPositionAndAngle();
                    rocket0.body.SetActive(true);

                    rocket0.CreateSmoke();
                    {
                        var up = new KeySample();
                        up[Keys.Up]   = true;
                        rocket0.speed = 60 + this.body.GetLinearVelocity().Length();
                        rocket0.SetVelocityFromInput(up);
                    }
                    Rockets.Enqueue(rocket0);
                    rocket0 = null;


                    if (rocket1 == null)
                    {
                        if (Rockets.Count > RocketsMax)
                        {
                            rocket1 = Rockets.Dequeue();
                            rocket1.SetVelocityFromInput(new KeySample());
                            rocket1.visual.visible = true;
                        }
                        else
                        {
                            rocket1 = new PhysicalRocket(textures_rocket, Context, Explosion1: Explosion1);
                            rocket1.body.SetActive(false);

                            #region z fixup
                            rocket1.visual.parent.setChildIndex(
                                rocket1.visual,

                                this.visual.visualnowings.parent.getChildIndex(
                                    this.visual.visualnowings
                                    )
                                );
                            #endregion
                        }
                    }
                }
                else if (rocket1 != null)
                {
                    var sc = 1 + hind0.visual.airzoom * hind0.visual.Altitude;

                    rocket1.SetPositionAndAngle(


                        hind0.body.GetPosition().x + Math.Cos(hind0.body.GetAngle() + Math.PI * 0.5 - hind0.CameraRotation) * 3.5 * sc,
                        hind0.body.GetPosition().y + Math.Sin(hind0.body.GetAngle() + Math.PI * 0.5 - hind0.CameraRotation) * 3.5 * sc,

                        hind0.body.GetAngle() - hind0.CameraRotation
                        );
                    rocket1.ShowPositionAndAngle();
                    rocket1.body.SetActive(true);

                    rocket1.CreateSmoke();
                    {
                        var up = new KeySample();
                        up[Keys.Up]   = true;
                        rocket1.speed = 60 + this.body.GetLinearVelocity().Length();
                        rocket1.SetVelocityFromInput(up);
                    }
                    Rockets.Enqueue(rocket1);
                    rocket1 = null;

                    if (rocket0 == null)
                    {
                        if (Rockets.Count > RocketsMax)
                        {
                            rocket0 = Rockets.Dequeue();
                            rocket0.SetVelocityFromInput(new KeySample());
                            rocket0.visual.visible = true;
                        }
                        else
                        {
                            rocket0 = new PhysicalRocket(textures_rocket, Context, Explosion1: Explosion1);
                            rocket0.body.SetActive(false);

                            #region z fixup
                            rocket0.visual.parent.setChildIndex(
                                rocket0.visual,

                                this.visual.visualnowings.parent.getChildIndex(
                                    this.visual.visualnowings
                                    )
                                );
                            #endregion
                        }
                    }
                }
            };
            #endregion
        }