当前位置: 首页>>代码示例>>C#>>正文


C# Vertices.ForEach方法代码示例

本文整理汇总了C#中Vertices.ForEach方法的典型用法代码示例。如果您正苦于以下问题:C# Vertices.ForEach方法的具体用法?C# Vertices.ForEach怎么用?C# Vertices.ForEach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vertices的用法示例。


在下文中一共展示了Vertices.ForEach方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitPhysics

        protected override void InitPhysics()
        {
            float pixel = (float)(1.0 / Configuration.MeterInPixels);

            float fixture_scale_y = 0.75f;

            float corner_clip_x = 7.0f * pixel;
            float corner_clip_y = 2.0f * pixel;
            float y_shift = 2.0f * pixel;

            float w, h, half_h, qtr_h, scl_h;
            if (Texture.Regions != null && Texture.Regions.Length > 0)
            {
                var size = Texture.DefaultRegion.Size;
                w = (float)(_Scale.X * size.X) * pixel;
                h = (float)(_Scale.Y * size.Y) * pixel;
            }
            else
            {
                w = (float)(_Scale.X * Texture.Width) * pixel;
                h = (float)(_Scale.Y * Texture.Height) * pixel;
            }
            scl_h = fixture_scale_y * h;
            half_h = 0.5f * h;
            var half_w_h = new Microsoft.Xna.Framework.Vector2(w * 0.5f, half_h);
            var msv2 = new Microsoft.Xna.Framework.Vector2(
                (float)(_Position.X) * pixel,
                (float)(_Position.Y) * pixel);
            _SpriteBody = BodyFactory.CreateBody(_RenderSet.Scene.World, Microsoft.Xna.Framework.Vector2.Zero, this);

            Microsoft.Xna.Framework.Vector2 a, b, c, d, e00, e01, e10, e11;

            var verts = new Vertices(new Microsoft.Xna.Framework.Vector2[] {
                e00 = new Microsoft.Xna.Framework.Vector2(corner_clip_x, 0.0f),
                e10 = new Microsoft.Xna.Framework.Vector2(w - corner_clip_x, 0.0f),
                b = new Microsoft.Xna.Framework.Vector2(w, corner_clip_y),
                c = new Microsoft.Xna.Framework.Vector2(w, scl_h - corner_clip_y),
                e11 = new Microsoft.Xna.Framework.Vector2(w - corner_clip_x, scl_h),
                e01 = new Microsoft.Xna.Framework.Vector2(corner_clip_x, scl_h),
                d = new Microsoft.Xna.Framework.Vector2(0.0f, scl_h - corner_clip_y),
                a = new Microsoft.Xna.Framework.Vector2(0.0f, corner_clip_y),
            });

            var verts_upper = new Vertices();
            verts.ForEach(v => {
                v.X -= half_w_h.X;
                v.Y = y_shift + v.Y * fixture_scale_y + half_h * (0.5f - fixture_scale_y);
                verts_upper.Add(v);
                //Console.Write("{0}, ", v.ToString());
            });
            var verts_lower = new Vertices();
            verts.ForEach(v => {
                v.X -= half_w_h.X;
                v.Y = y_shift + v.Y * fixture_scale_y - half_h;
                verts_lower.Add(v);
                //Console.Write("{0}, ", v.ToString());
            });

            FixtureUpper = FixtureFactory.AttachPolygon(verts_upper, 100.0f, _SpriteBody);
            FixtureLower = FixtureFactory.AttachPolygon(verts_lower, 100.0f, _SpriteBody);

            _SpriteBody.BodyType = BodyType.Dynamic;
            _SpriteBody.FixedRotation = true;
            //_SpriteFixture = FarseerPhysics.Factories.FixtureFactory.AttachEdge
            _SpriteBody.Mass = 100.0f;
            Body.OnCollision += HandleOnCollision;
            Body.OnSeparation += HandleOnSeparation;
            Preserve = true;

            Body.SleepingAllowed = false; // Avoid dumb shit

            // HACK: Only enable bodies for which the object is in the current scene
            Body.Enabled = this.RenderSet.Scene == Program.MainGame.CurrentScene;

            InitBlueprints();
        }
开发者ID:Apelsin,项目名称:positron,代码行数:76,代码来源:Player.cs


注:本文中的Vertices.ForEach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。