コード例 #1
0
        static void InitShape()
        {
            Coefficients        DefaultCoefficients = TimeWarp.Coefficients;
            List <IGeometry2D>  geometries          = new List <IGeometry2D>();
            List <Coefficients> coefficients        = new List <Coefficients>();

            float da        = MathHelper.PI * 2 / 5;
            float podlength = 50;

            for (float angle = 0; angle < MathHelper.PI * 2; angle += da)
            {
                Vector2D direction = Vector2D.Rotate(angle - MathHelper.PI, Vector2D.XAxis);
                if (angle == 0)
                {
                    geometries.Add(new Polygon2D(new ALVector2D(angle - MathHelper.PI, direction * .3f * podlength), Polygon2D.FromRectangle(9, podlength * .6f)));
                    geometries.Add(new Polygon2D(new ALVector2D(0, direction * podlength * .6f), Polygon2D.FromNumberofSidesAndRadius(8, 10)));
                }
                else
                {
                    geometries.Add(new Polygon2D(new ALVector2D(angle - MathHelper.PI, direction * .5f * podlength), Polygon2D.FromRectangle(9, podlength)));
                    geometries.Add(new Polygon2D(new ALVector2D(0, direction * podlength), Polygon2D.FromNumberofSidesAndRadius(8, 10)));
                }
                coefficients.Add(DefaultCoefficients);
                coefficients.Add(DefaultCoefficients);
            }
            geometries.Add(new Polygon2D(ALVector2D.Zero, Polygon2D.FromNumberofSidesAndRadius(10, 15)));
            coefficients.Add(DefaultCoefficients);
            DefaultShape = new RigidBodyTemplate(16, 1569.670392957858f, geometries.ToArray(), coefficients.ToArray());
            DefaultShape.BalanceBody();
            // ////DefaultShape.CalcInertiaMultiplier(.1f);
        }
コード例 #2
0
        static void InitShapes()
        {
            DefaultCoefficients = new Coefficients(1.1f, .2f, .2f);
            int length = 6;

            Templates = new RigidBodyTemplate[length];
            List <Vector2D> vertexes = new List <Vector2D>();

            for (int pos = 0; pos < length; ++pos)
            {
                int        numberofSides = rand.Next(5, 10);
                float      radius        = 20 + (float)rand.NextDouble() * 20;
                Vector2D[] poly          = Polygon2D.FromNumberofSidesAndRadius(numberofSides, radius);
                vertexes.AddRange(poly);
                for (int numbertoRemove = rand.Next(0, numberofSides - 4); numbertoRemove > 0; --numbertoRemove)
                {
                    vertexes.RemoveAt(rand.Next(0, vertexes.Count));
                }
                Polygon2D polly = new Polygon2D(ALVector2D.Zero, poly);
                poly = Polygon2D.MakeCentroidOrigin(vertexes.ToArray());
                MassInertia mi = MassInertia.FromSolidCylinder(1 + (float)rand.NextDouble() * 2, polly.BoundingRadius);
                Templates[pos] = new RigidBodyTemplate(mi, new IGeometry2D[] { polly }, new Coefficients[] { DefaultCoefficients });
                vertexes.Clear();
            }
        }
コード例 #3
0
        static void InitShape()
        {
            Coefficients        DefaultCoefficients = TimeWarp.Coefficients;
            List <IGeometry2D>  goes = new List <IGeometry2D>();
            List <Coefficients> coes = new List <Coefficients>();

            Vector2D[] engineconevertecies = new Vector2D[]
            {
                new Vector2D(-50, 10),
                new Vector2D(-100, 20),
                new Vector2D(-100, -20),
                new Vector2D(-50, -10)
            };
            Vector2D offset = Polygon2D.CalcCentroid(engineconevertecies);

            //engineconevertecies = Vector2D.Translate( -offset,engineconevertecies);

            OperationHelper.ArrayRefOp <Vector2D, Vector2D, Vector2D>(
                engineconevertecies,
                ref offset,
                engineconevertecies,
                Vector2D.Subtract);

            goes.Add(new Polygon2D(ALVector2D.Zero, Polygon2D.FromRectangle(20, 150)));
            coes.Add(DefaultCoefficients);

            goes.Add(new Polygon2D(new ALVector2D(0, new Vector2D(-100, 0)), Polygon2D.FromNumberofSidesAndRadius(10, 20)));
            coes.Add(DefaultCoefficients);

            goes.Add(new Polygon2D(new ALVector2D(0, offset), engineconevertecies));
            coes.Add(DefaultCoefficients);
            DefaultShape = new RigidBodyTemplate(18, 3383.9114375372737f, goes.ToArray(), coes.ToArray());
            DefaultShape.BalanceBody();
            ////DefaultShape.CalcInertiaMultiplier(.1f);
        }
コード例 #4
0
        static void InitShape()
        {
            Coefficients        DefaultCoefficients = TimeWarp.Coefficients;
            List <IGeometry2D>  goes = new List <IGeometry2D>();
            List <Coefficients> coes = new List <Coefficients>();

            Vector2D[] hullvertecies = new Vector2D[]
            {
                new Vector2D(30, 13),
                new Vector2D(0, 18),
                new Vector2D(-30, 20),
                new Vector2D(-30, -20),
                new Vector2D(0, -18),
                new Vector2D(30, -13)
            };
            goes.Add(new Polygon2D(new ALVector2D(0, hullvertecies[0]), Polygon2D.FromNumberofSidesAndRadius(8, 12)));
            coes.Add(DefaultCoefficients);
            goes.Add(new Polygon2D(new ALVector2D(0, hullvertecies[5]), Polygon2D.FromNumberofSidesAndRadius(8, 12)));
            coes.Add(DefaultCoefficients);
            goes.Add(new Polygon2D(new ALVector2D(0, hullvertecies[2]), Polygon2D.FromNumberofSidesAndRadius(8, 12)));
            coes.Add(DefaultCoefficients);
            goes.Add(new Polygon2D(new ALVector2D(0, hullvertecies[3]), Polygon2D.FromNumberofSidesAndRadius(8, 12)));
            coes.Add(DefaultCoefficients);
            goes.Add(new Polygon2D(ALVector2D.Zero, hullvertecies));
            coes.Add(DefaultCoefficients);
            DefaultShape = new RigidBodyTemplate(7, 771.453f, goes.ToArray(), coes.ToArray());
            DefaultShape.BalanceBody();
            //DefaultShape.CalcInertiaMultiplier(.1f);
        }
コード例 #5
0
        static void InitShape()
        {
            Coefficients coe = TimeWarp.Coefficients;

            List <IGeometry2D>  goes = new List <IGeometry2D>();
            List <Coefficients> coes = new List <Coefficients>();

            goes.Add(new Polygon2D(ALVector2D.Zero, Polygon2D.FromNumberofSidesAndRadius(6, 15)));
            coes.Add(coe);

            DefaultShape = new RigidBodyTemplate(MassInertia.FromSolidCylinder(.4f, 15), goes.ToArray(), coes.ToArray());
            //DefaultShape.BalanceBody();
            ////DefaultShape.CalcInertiaMultiplier(.1f);

            goes.Clear();
            coes.Clear();


            goes.Add(new Polygon2D(ALVector2D.Zero, Polygon2D.FromNumberofSidesAndRadius(6, 9)));
            coes.Add(coe);


            SubDefaultShape = new RigidBodyTemplate(MassInertia.FromSolidCylinder(.01f, 9), goes.ToArray(), coes.ToArray());
            //SubDefaultShape.BalanceBody();
            //Sub//DefaultShape.CalcInertiaMultiplier(.1f);
        }
コード例 #6
0
        static void InitShape()
        {
            Coefficients coe        = TimeWarp.Coefficients;
            IGeometry2D  enginecone = new Polygon2D(ALVector2D.Zero, Polygon2D.FromNumberofSidesAndRadius(10, 20));

            DefaultShape = new RigidBodyTemplate(MassInertia.FromSolidCylinder(.001f, 20), new IGeometry2D[] { enginecone }, new Coefficients[] { coe });
            DefaultShape.BalanceBody();
            //////DefaultShape.CalcInertiaMultiplier(.1f);
        }
コード例 #7
0
        static void InitShape()
        {
            Coefficients coe = TimeWarp.Coefficients;

            DefaultShape = new RigidBodyTemplate(MassInertia.FromSolidCylinder(.01f, 7),
                                                 new IGeometry2D[] { new Polygon2D(Polygon2D.FromNumberofSidesAndRadius(10, 7)) },
                                                 new Coefficients[] { coe });
            DefaultShape.BalanceBody();
        }
コード例 #8
0
        static void InitShape()
        {
            Coefficients coe        = TimeWarp.Coefficients;
            IGeometry2D  enginecone = new Polygon2D(ALVector2D.Zero, Polygon2D.FromNumberofSidesAndRadius(6, 6));

            DefaultShape = new RigidBodyTemplate(.001f, 9.012392754810497f, new IGeometry2D[] { enginecone }, new Coefficients[] { coe });
            DefaultShape.BalanceBody();
            //////DefaultShape.CalcInertiaMultiplier(.1f);
        }
コード例 #9
0
        static void InitShape()
        {
            Coefficients DefaultCoefficients = TimeWarp.Coefficients;
            IGeometry2D  mainhull            = new Polygon2D(new ALVector2D(0, new Vector2D(35, 0)), Polygon2D.FromRectangle(50, 20));
            IGeometry2D  engine = new Polygon2D(ALVector2D.Zero, Polygon2D.FromNumberofSidesAndRadius(10, 40));

            DefaultShape = new RigidBodyTemplate(18, 1239.4170508254688f, new IGeometry2D[] { mainhull, engine, }, new Coefficients[] { DefaultCoefficients, DefaultCoefficients });
            DefaultShape.BalanceBody();
            ////DefaultShape.CalcInertiaMultiplier(.1f);
        }
コード例 #10
0
        static void InitShape()
        {
            Coefficients coe = TimeWarp.Coefficients;

            List <IGeometry2D>  goes = new List <IGeometry2D>();
            List <Coefficients> coes = new List <Coefficients>();

            goes.Add(new Polygon2D(ALVector2D.Zero, Polygon2D.FromNumberofSidesAndRadius(6, 20)));
            coes.Add(coe);

            DefaultShape = new RigidBodyTemplate(MassInertia.FromSolidCylinder(1, 20), goes.ToArray(), coes.ToArray());
        }
コード例 #11
0
        /// <summary>
        /// Initializes the ships shape.
        /// </summary>
        static void InitShape()
        {
            //This method is complicated and i dont fell like commenting it.
            // this one is actaully very simple compared to the rest but still anoying.

            Coefficients DefaultCoefficients = TimeWarp.Coefficients;

            DefaultShape = new RigidBodyTemplate(
                MassInertia.FromSolidCylinder(4, 20),
                new IGeometry2D[] { new Polygon2D(ALVector2D.Zero, Polygon2D.FromNumberofSidesAndRadius(10, 20)) },
                new Coefficients[] { DefaultCoefficients });
            //DefaultShape.BalanceBody();
            //////DefaultShape.CalcInertiaMultiplier(.1f);
        }
コード例 #12
0
        static void InitShape()
        {
            Coefficients        DefaultCoefficients = TimeWarp.Coefficients;
            List <IGeometry2D>  goes = new List <IGeometry2D>();
            List <Coefficients> coes = new List <Coefficients>();

            Vector2D[] pods = Polygon2D.FromRectangle(10, 70);


            Vector2D[] leftWingvertecies = new Vector2D[]
            {
                new Vector2D(25, 20),
                new Vector2D(-30, 20),
                new Vector2D(-40, -50),
                new Vector2D(-5, -50)
            };
            Vector2D[] RightWingvertecies = new Vector2D[]
            {
                new Vector2D(-5, 50),
                new Vector2D(-40, 50),
                new Vector2D(-30, -20),
                new Vector2D(25, -20)
            };
            goes.Add(new Polygon2D(new ALVector2D(0, new Vector2D(-10, -30)), leftWingvertecies));
            coes.Add(DefaultCoefficients);
            goes.Add(new Polygon2D(new ALVector2D(0, new Vector2D(-10, 30)), RightWingvertecies));
            coes.Add(DefaultCoefficients);

            goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI, new Vector2D(-35, 75)), pods));
            coes.Add(DefaultCoefficients);
            goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI, new Vector2D(-35, -75)), pods));
            coes.Add(DefaultCoefficients);

            goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI, new Vector2D(20, 0)), Polygon2D.FromRectangle(20, 120)));
            coes.Add(DefaultCoefficients);

            goes.Add(new Polygon2D(new ALVector2D(0, new Vector2D(90, 0)), Polygon2D.FromNumberofSidesAndRadius(5, 25)));
            coes.Add(DefaultCoefficients);


            DefaultShape = new RigidBodyTemplate(18, 3923.7657051329197f, goes.ToArray(), coes.ToArray());
            DefaultShape.BalanceBody();

            //////DefaultShape.CalcInertiaMultiplier(.1f);
        }
コード例 #13
0
        static void InitShape()
        {
            Coefficients        DefaultCoefficients = TimeWarp.Coefficients;
            List <IGeometry2D>  goes = new List <IGeometry2D>();
            List <Coefficients> coes = new List <Coefficients>();

            Vector2D[] pods      = Polygon2D.FromRectangle(20, 70);
            Vector2D[] mainhullp = Polygon2D.FromRectangle(30, 140);
            Vector2D[] subhullp  = Polygon2D.FromRectangle(40, 20);

            goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI + .7f, new Vector2D(-35, 22)), subhullp));
            coes.Add(DefaultCoefficients);

            goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI - .7f, new Vector2D(-35, -22)), subhullp));
            coes.Add(DefaultCoefficients);



            goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI, new Vector2D(-50, 35)), pods));
            coes.Add(DefaultCoefficients);
            goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI, new Vector2D(-50, -35)), pods));
            coes.Add(DefaultCoefficients);



            goes.Add(new Polygon2D(new ALVector2D(0, new Vector2D(95, 0)), Polygon2D.FromNumberofSidesAndRadius(4, 25)));
            coes.Add(DefaultCoefficients);

            goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI, new Vector2D(15f, 0)), mainhullp));
            coes.Add(DefaultCoefficients);



            goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI, new Vector2D(30, 0)), Polygon2D.FromRectangle(80, 50)));
            coes.Add(DefaultCoefficients);

            goes.Add(new Polygon2D(new ALVector2D(0, new Vector2D(120, 0)), Polygon2D.FromRectangle(50, 50)));
            coes.Add(DefaultCoefficients);


            DefaultShape = new RigidBodyTemplate(18, 4077.711f, goes.ToArray(), coes.ToArray());
            DefaultShape.BalanceBody();

            //DefaultShape.CalcInertiaMultiplier(.1f);
        }
コード例 #14
0
        static void InitShape()
        {
            Coefficients        DefaultCoefficients = TimeWarp.Coefficients;
            List <IGeometry2D>  goes = new List <IGeometry2D>();
            List <Coefficients> coes = new List <Coefficients>();


            goes.Add(new Polygon2D(new ALVector2D(0, new Vector2D(0, 0)), Polygon2D.FromNumberofSidesAndRadius(8, 30)));
            coes.Add(DefaultCoefficients);

            goes.Add(new Polygon2D(new ALVector2D(0, new Vector2D(-30, 0)), Polygon2D.FromNumberofSidesAndRadius(8, 12)));
            coes.Add(DefaultCoefficients);
            goes.Add(new Polygon2D(new ALVector2D(0, new Vector2D(-15, 25)), Polygon2D.FromNumberofSidesAndRadius(8, 12)));
            coes.Add(DefaultCoefficients);
            goes.Add(new Polygon2D(new ALVector2D(0, new Vector2D(-15, -25)), Polygon2D.FromNumberofSidesAndRadius(8, 12)));
            coes.Add(DefaultCoefficients);
            DefaultShape = new RigidBodyTemplate(5, 3383.9114375372737f, goes.ToArray(), coes.ToArray());
            DefaultShape.BalanceBody();
            ////DefaultShape.CalcInertiaMultiplier(.1f);
        }
コード例 #15
0
        protected override RigidBodyTemplate GetShape()
        {
            Coefficients        DefaultCoefficients = TimeWarp.Coefficients;
            List <IGeometry2D>  goes = new List <IGeometry2D>();
            List <Coefficients> coes = new List <Coefficients>();

            Vector2D[] pods      = Polygon2D.FromRectangle(20, 70);
            Vector2D[] mainhullp = Polygon2D.FromRectangle(30, 150);
            Vector2D[] subhullp  = Polygon2D.FromRectangle(40, 20);

            goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI + .7f, new Vector2D(-35, 22)), subhullp));
            coes.Add(DefaultCoefficients);
            goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI + .7f, new Vector2D(35, 22)), subhullp));
            coes.Add(DefaultCoefficients);
            goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI - .7f, new Vector2D(-35, -22)), subhullp));
            coes.Add(DefaultCoefficients);
            goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI - .7f, new Vector2D(35, -22)), subhullp));
            coes.Add(DefaultCoefficients);

            goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI, new Vector2D(40, 40)), pods));
            coes.Add(DefaultCoefficients);
            goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI, new Vector2D(40, -40)), pods));
            coes.Add(DefaultCoefficients);
            goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI, new Vector2D(-40, 40)), pods));
            coes.Add(DefaultCoefficients);
            goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI, new Vector2D(-40, -40)), pods));
            coes.Add(DefaultCoefficients);

            goes.Add(new Polygon2D(new ALVector2D(MathHelper.PI, new Vector2D(20, 0)), mainhullp));
            coes.Add(DefaultCoefficients);

            goes.Add(new Polygon2D(new ALVector2D(0, new Vector2D(120, 0)), Polygon2D.FromNumberofSidesAndRadius(10, 35)));
            coes.Add(DefaultCoefficients);


            RigidBodyTemplate DefaultShape = new RigidBodyTemplate(18, 3923.7657051329197f, goes.ToArray(), coes.ToArray());

            DefaultShape.BalanceBody();
            return(DefaultShape);
        }
コード例 #16
0
        static void InitShape()
        {
            Coefficients DefaultCoefficients = TimeWarp.Coefficients;

            Vector2D[] engineconevertecies = new Vector2D[]
            {
                new Vector2D(30, 10),
                new Vector2D(-30, 40),
                new Vector2D(-30, -40),
                new Vector2D(30, -10)
            };
            Vector2D offset = Polygon2D.CalcCentroid(engineconevertecies);

            OperationHelper.ArrayRefOp <Vector2D, Vector2D, Vector2D>(
                engineconevertecies,
                ref offset,
                engineconevertecies,
                Vector2D.Subtract);

            //engineconevertecies = Vector2D.Translate(-offset, engineconevertecies);

            IGeometry2D mainhull   = new Polygon2D(ALVector2D.Zero, Polygon2D.FromRectangle(80, 10));
            IGeometry2D engine     = new Polygon2D(new ALVector2D(0, new Vector2D(-30, 0)), Polygon2D.FromNumberofSidesAndRadius(10, 40));
            IGeometry2D enginecone = new Polygon2D(new ALVector2D(0, offset), engineconevertecies);

            DefaultShape = new RigidBodyTemplate(12, 1231.9384791047398f, new IGeometry2D[] { engine, mainhull, enginecone }, new Coefficients[] { DefaultCoefficients, DefaultCoefficients, DefaultCoefficients });
            DefaultShape.BalanceBody();
            //////DefaultShape.CalcInertiaMultiplier(.1f);
        }
コード例 #17
0
        static ISolidWeapon CreateWeapon()
        {
            Coefficients coe    = TimeWarp.Coefficients;
            float        radius = 20;

            return(new Controlable(
                       DefaultLifeTime,
                       MassInertia.FromSolidCylinder(1, radius),
                       new PhysicsState(),
                       DefaultBodyFlags,
                       new ICollidableBodyPart[] { new RigidBodyPart(ALVector2D.Zero, (Polygon2D)Polygon2D.FromNumberofSidesAndRadius(8, radius), coe) },
                       new ShipMovementInfo(DefaultMovementInfo),
                       new ShipState(DefaultState),
                       new ControlableSounds(),
                       new WeaponsLogic(TargetingInfo.All,
                                        new EffectCollection(DefaultEffectCollection))));
        }
コード例 #18
0
        static ISolidWeapon[] CreateWeapons()
        {
            Coefficients coe   = TimeWarp.Coefficients;
            int          count = 4;

            ISolidWeapon[] weapons = new ISolidWeapon[count];
            for (int pos = 0; pos < count; ++pos)
            {
                float radius = 5 + 5 * pos;
                weapons[pos] = new Controlable(
                    DefaultLifeTimes[pos],
                    MassInertia.FromSolidCylinder(.1f, radius),
                    new PhysicsState(),
                    DefaultBodyFlags,
                    new ICollidableBodyPart[] { new RigidBodyPart(ALVector2D.Zero, (Polygon2D)Polygon2D.FromNumberofSidesAndRadius(8, radius), coe) },
                    new ShipMovementInfo(DefaultMovementInfo),
                    new ShipState(DefaultState[pos]),
                    new ControlableSounds("EnergyChargeUp", null),
                    new WeaponsLogic(TargetingInfo.All,
                                     new EffectCollection(DefaultEffectCollections[pos])));
            }
            return(weapons);
        }
コード例 #19
0
        static void InitShape()
        {
            Coefficients DefaultCoefficients = TimeWarp.Coefficients;

            IGeometry2D mainhull = new Polygon2D(ALVector2D.Zero, Polygon2D.FromRectangle(10, 120));

            IGeometry2D sphereone    = new Polygon2D(new ALVector2D(0, new Vector2D(-60, 0)), Polygon2D.FromNumberofSidesAndRadius(10, 25));
            IGeometry2D spheretwo    = new Polygon2D(new ALVector2D(0, new Vector2D(60, 0)), Polygon2D.FromNumberofSidesAndRadius(10, 25));
            IGeometry2D subsphereone = new Polygon2D(new ALVector2D(0, new Vector2D(0, 30)), Polygon2D.FromNumberofSidesAndRadius(10, 10));
            IGeometry2D subspheretwo = new Polygon2D(new ALVector2D(0, new Vector2D(0, -30)), Polygon2D.FromNumberofSidesAndRadius(10, 10));

            DefaultShape = new RigidBodyTemplate(
                8,
                2635.9963064342355f,
                new IGeometry2D[] { sphereone, spheretwo, subsphereone, subspheretwo, mainhull },
                new Coefficients[] { DefaultCoefficients, DefaultCoefficients, DefaultCoefficients, DefaultCoefficients, DefaultCoefficients });
            DefaultShape.BalanceBody();
            ////DefaultShape.CalcInertiaMultiplier(.1f);
        }
コード例 #20
0
            static void InitShape()
            {
                Coefficients coe = TimeWarp.Coefficients;

                IGeometry2D enginecone = new Polygon2D(new ALVector2D(0, new Vector2D(0, 0)), Polygon2D.FromNumberofSidesAndRadius(8, 8));

                DefaultShape = new RigidBodyTemplate(MassInertia.FromSolidCylinder(.1f, 8), new IGeometry2D[] { enginecone }, new Coefficients[] { coe });
                DefaultShape.BalanceBody();
            }