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


C# Space.Add方法代码示例

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


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

示例1: OnAdditionToSpace

 /// <summary>
 /// Adds the motors to the space.  Called automatically.
 /// </summary>
 public override void OnAdditionToSpace(Space newSpace)
 {
     newSpace.Add(LinearMotor);
 }
开发者ID:EugenyN,项目名称:BEPUphysicsMG,代码行数:7,代码来源:EntityMover.cs

示例2: OnAdditionToSpace

        public override void OnAdditionToSpace(Space newSpace)
        {
            //Add any supplements to the space too.
            newSpace.Add(Body);
            newSpace.Add(HorizontalMotionConstraint);
            newSpace.Add(VerticalMotionConstraint);
            //This character controller requires the standard implementation of Space.
            newSpace.BoundingBoxUpdater.Finishing += ExpandBoundingBox;

            Body.AngularVelocity = new Vector3();
            Body.LinearVelocity = new Vector3();
        }
开发者ID:EugenyN,项目名称:BEPUphysicsMG,代码行数:12,代码来源:CharacterController.cs

示例3: MachineLayer

        public MachineLayer()
        {
            space = new Space () {
                Gravity = new PointF (0, -10),
            };

            Add ( new CCSprite ("bg.jpg") {
                Position = UIDevice.CurrentDevice.IsIPad() ? new PointF(512, 384) : new PointF(240, 160),
            });

            //motorblock, no body, no shape
            var motorblock = new CCSprite ("motor_block.png") {
                Position = UIDevice.CurrentDevice.IsIPad() ? new PointF (160, 460) : new PointF (80, 230),
            };
            Add (motorblock);

            //motorwheel
            var motorwheel = new CCPhysicsSprite ("motor_wheel.png") {
                Body = new Body (1, Helper.MomentForCircle (1, 20, 20, PointF.Empty)),
                Position = UIDevice.CurrentDevice.IsIPad() ? new PointF (160, 460) : new PointF (80, 230),
            };
            Add (motorwheel);

            space.Add (motorwheel.Body);
            space.Add (new CircleShape (motorwheel.Body, UIDevice.CurrentDevice.IsIPad() ? 20 : 10, PointF.Empty) {Group = 1});
            space.Add ((Constraint)new PivotJoint (space.StaticBody, motorwheel.Body, UIDevice.CurrentDevice.IsIPad() ? new PointF (160,460) : new PointF (80, 230)));
            space.Add ((Constraint)new SimpleMotor (space.StaticBody, motorwheel.Body, 10f));

            //wheel
            var wheel = new CCPhysicsSprite ("wheel.png") {
                Body = new Body (25, Helper.MomentForCircle (25, 140, 140, PointF.Empty)),
                Position = UIDevice.CurrentDevice.IsIPad() ? new PointF (160, 300) : new PointF (80, 150),
            };
            space.Add (wheel.Body);
            space.Add (new CircleShape (wheel.Body, UIDevice.CurrentDevice.IsIPad() ? 140 : 70, PointF.Empty){Group = 1});
            Add (wheel);
            space.Add ((Constraint)new PivotJoint (space.StaticBody, wheel.Body, UIDevice.CurrentDevice.IsIPad() ? new PointF (160, 300) : new PointF (80, 150)));
            space.Add ((Constraint)new GearJoint (motorwheel.Body, wheel.Body, 0f, -7f));

            //cylinder. no physics body. only a shape
            Add (new CCSprite ("cylinder.png") {
                Position = UIDevice.CurrentDevice.IsIPad() ? new PointF (570, 300) : new PointF (285, 150),
            });

            //space.Add (new PolygonShape (space.StaticBody, new [] {
            //	new PointF (350, 160),
            //	new PointF (350, 200),
            //	new PointF (750, 200),
            //	new PointF (750, 160),
            //}, PointF.Empty));
            //
            //space.Add (new PolygonShape (space.StaticBody, new [] {
            //	new PointF (350, 400),
            //	new PointF (350, 440),
            //	new PointF (750, 440),
            //	new PointF (750, 400),
            //}, PointF.Empty));

            //piston
            var piston = new CCPhysicsSprite ("piston.png") {
                Body = new Body (8, float.PositiveInfinity), //never rotates
                Position = UIDevice.CurrentDevice.IsIPad() ? new PointF (370, 300) : new PointF (185, 150),
            };
            space.Add (piston.Body);
            space.Add (new PolygonShape (piston.Body, UIDevice.CurrentDevice.IsIPad() ? 100 : 50, UIDevice.CurrentDevice.IsIPad() ? 200 : 50) {Group = 1});
            Add (piston);

            //conrod
            var conrod = new CCPhysicsSprite ("conrod.png") {
                Body = new Body (4, Helper.MomentForPolygon (4, new[] {
                    new PointF (-160,-20),
                    new PointF (-160, 20),
                    new PointF (160, 20),
                    new PointF (160, -20),
                }, PointF.Empty)),
                Position = UIDevice.CurrentDevice.IsIPad() ? new PointF (190, 300) : new PointF (95, 150)
            };
            space.Add (conrod.Body);
            space.Add (new PolygonShape (conrod.Body, UIDevice.CurrentDevice.IsIPad() ? 320 : 160, UIDevice.CurrentDevice.IsIPad() ? 40 : 20) {Group = 1});
            Add (conrod);
            space.Add ((Constraint)new PivotJoint (wheel.Body, conrod.Body, UIDevice.CurrentDevice.IsIPad() ? new PointF (40, 300) : new PointF (20, 150)));

            space.Add ((Constraint)new PivotJoint (conrod.Body, piston.Body, UIDevice.CurrentDevice.IsIPad() ? new PointF (340, 300) : new PointF (170, 150)));
            space.Add ((Constraint)new GrooveJoint (space.StaticBody,
                                        piston.Body,
                                        UIDevice.CurrentDevice.IsIPad() ? new PointF (0, 300) : new PointF (0, 150),
                                        UIDevice.CurrentDevice.IsIPad() ? new PointF (1024, 300) : new PointF (480, 150),
                                        UIDevice.CurrentDevice.IsIPad() ? new PointF (0, 0): new PointF (0, 0)));
        }
开发者ID:DennisWelu,项目名称:monotouch-bindings,代码行数:89,代码来源:MachineLayer.cs

示例4: RandomWalk


//.........这里部分代码省略.........
                        case 2:
                            { //black
                                //pn.Width = randomW.Next(0, 5);

                                //ptEnd = GetNextPoint(ptStart, random, bpData.Stride, bpData.Height);

                                break;
                            }
                        case 3:
                            { //all colors, random line width between 0 and 5 px

                                endColor = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));

                                //ptEnd = GetNextPoint(ptStart, random, bpData.Stride, bpData.Height);
                                break;
                            }
                        case 4:
                            { //all colors, thinnest line width

								ptEnd = GetNextPoint(new Point(ptStart.x, ptStart.y), random, Width, Height);

								endColor = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));

                                //endColor = Blend(startColor, GetPixelColor(ptEnd, tBm), random);

								if(createBitmap)
									numberDrawn += DrawToBitmap(ref _tBitmap, ptEnd, endColor);

								ptStart.x = ptEnd.x; ptStart.y = ptEnd.y;

                                break;
                            }
                        case 5:
                            { //greyscale
                                c = randomC.Next(0, 255);
                                //pn.Color = System.Drawing.Color.FromArgb(c, c, c);

                                //ptEnd = GetNextPoint(ptStart, random, bpData.Stride, bpData.Height);
                                break;
                            }
                        case 6:
                            { //white
                                //pn.Color = System.Drawing.Color.White;

                                //ptEnd.X = ptStart.X;

                                //ptEnd.Y = ptStart.Y;

                                //ptEnd = GetNextPoint(ptStart, random, bpData.Stride, bpData.Height);
                                break;
                            }
                        case 7:
                            { //black thinnest line width
                                //pn.Width = 1;

                                //ptEnd.X = ptStart.X;

                                //ptEnd.Y = ptStart.Y;

                                //ptEnd = GetNextPoint(ptStart, random, bpData.Stride, bpData.Height);
                                break;
                            }
                        case 8: //all colors, wider line width
                            {
                                //pn.Color = System.Drawing.Color.FromArgb( rr.Next(redBottom, redTop), rr.Next(greenBottom, greenCenter), rr.Next(blueBottom, blueTop) );
                                //pn.Width = randomW.Next(0, 50);

                                //ptEnd.X = ptStart.X;

                                //ptEnd.Y = ptStart.Y;

                                //ptEnd = GetNextPoint(ptStart, random, bpData.Stride, bpData.Height);
                                break;
                            }
                        default:
                            {

                                //ptEnd.X = ptStart.X;

                                //ptEnd.Y = ptStart.Y;

                                //ptEnd = GetNextPoint(ptStart, random, bpData.Stride, bpData.Height);

                                break;
                            }

                    } //end switch

					if (populateSpace)
					{
						_space.Add(new BitmapPoint(ptEnd.x, ptEnd.y));
						_size++;
					}
                }
            //}

            if(createBitmap)
				WriteDataToStandardBitmap(ref _tBitmap);

        }
开发者ID:KyKoPho,项目名称:random-art,代码行数:101,代码来源:RandomWalk.cs

示例5: OnAdditionToSpace

 internal void OnAdditionToSpace(Space space)
 {
     detector.CollisionInformation.collisionRules.Specific.Add(wheel.vehicle.Body.CollisionInformation.collisionRules, CollisionRule.NoBroadPhase);
     detector.CollisionInformation.collisionRules.Personal = CollisionRule.NoNarrowPhaseUpdate;
     detector.CollisionInformation.collisionRules.group = CollisionRules.DefaultDynamicCollisionGroup;
     //Need to put the detectors in appropriate locations before adding, or else the broad phase would see objects at (0,0,0) and make things gross.
     UpdateDetectorPosition();
     space.Add(detector);
 }
开发者ID:EugenyN,项目名称:BEPUphysicsMG,代码行数:9,代码来源:WheelShape.cs

示例6: InitInGame

 private void InitInGame(Space space)
 {
     space.Clear();
     space.Add(new HUD());
     space.Add(new Player());
     space.Add(new Cursor());
     space.Add(new EnemySpawner());
 }
开发者ID:Wezthal,项目名称:GameProject,代码行数:8,代码来源:Game.cs

示例7: Init

        private void Init()
        {
            Music = new MusicPlayer();
            Sounds = new SoundManager();
            Assets = new Assets();
            Assets.Load();

            var vm = new SFML.Window.VideoMode(1000, 750, 32);
            var style = Styles.Close;
            var settings = new ContextSettings(0, 0, 8);

            Window = new SFML.Graphics.RenderWindow(vm, "", style, settings);
            Window.SetView(View);
            Window.SetVerticalSyncEnabled(true);
            Window.Closed += (sender, e) => { IsAppExited = true; };
            Window.LostFocus += (sender, e) => { IsPaused = true; };
            Window.GainedFocus += (sender, e) => { IsPaused = false; };
            Window.SetMouseCursorVisible(true);

            var splash = new Space("Splash", true);
            var menu = new Space("Menu");
            var inGame = new Space("InGame");
            var gameOver = new Space("GameOver");

            //  ----- ----- ----- Splash ----- ----- -----

            var images = new SplashImage[]
            {
                new SplashImage(Assets.Textures["sfml"], 3, 1, 1),
                new SplashImage(Assets.Textures["rsas"], 5, 1, 1)
            };

            SplashImage.Prepare(images, e =>
            {
                splash.IsActive = false;
                menu.IsActive = true;
            });

            foreach(var image in images)
                splash.Add(image);

            //  ----- ----- ----- Menu ----- ----- -----
            var btnStart = new MenuButton("Play", 40, new Vector(100, 100));
            var btnQuit = new MenuButton("Quit", 40, new Vector(100, 200));

            var btnDiffEasy = new MenuButton("Easy", 30, new Vector(250, 100));
            var btnDiffMedium = new MenuButton("Medium", 30, new Vector(250, 150));
            var btnDiffHard = new MenuButton("Hard", 30, new Vector(250, 200));

            var infoText =
                "- Instructions -\n" +
                "- Run, shoot and survive as long as possible.\n" +
                "- Collect white powersups to recover health.\n" +
                "- New weapons are unlocked after each 1000 kills.\n" +
                "\n" +
                "- Use WASD keys to move, and mouse to aim and shoot.\n" +
                "- Use the numbers keys to change weapons.\n" +
                "- During gameplay, press ESC to pause or F1 to give up.";
            var btnInfoText = new MenuButton(infoText, 20, new Vector(450, 125));

            var highscoreList = new HighscoreList(new Vector2f(50, 300));

            Difficulty = RSaS.Difficulty.Medium;
            btnDiffMedium.Text.Color = Color.Red;

            btnStart.Click += e =>
            {
                if (IsGameOver)
                {
                    IsGameOver = false;
                    InitInGame(inGame);
                }

                Music.Play("music");
                menu.IsActive = false;
                inGame.IsActive = true;
                IsOSCursorVisible = false;
            };

            btnQuit.Click += e =>
            {
                IsAppExited = true;
            };

            btnDiffEasy.Click += e =>
            {
                if (!IsGameOver)
                    return;

                Difficulty = RSaS.Difficulty.Easy;
                btnDiffEasy.Text.Color = Color.Red;
                btnDiffMedium.Text.Color = Color.White;
                btnDiffHard.Text.Color = Color.White;
            };

            btnDiffMedium.Click += e =>
            {
                if (!IsGameOver)
                    return;

//.........这里部分代码省略.........
开发者ID:Wezthal,项目名称:GameProject,代码行数:101,代码来源:Game.cs

示例8: RunTests

		public static void RunTests()
		{
			//test IsSubSpace
			Space FirstSpace = new Space();
			Space SecondSpace = new Space();

			for (int i = 0; i < 100; i++)
			{
					FirstSpace.Add(new System.Drawing.Point(i, i));
				if (i >= 25 && i <= 50)
					SecondSpace.Add(new System.Drawing.Point(i, i));
			}

			if (SecondSpace.IsSubsetOf(FirstSpace))
				Console.WriteLine("Test IsSubSpace passed!");
			else Console.WriteLine("Test IsSubSpace failed!");

			//test !IsSubSpace
			FirstSpace = new Space();
			SecondSpace = new Space();

			for (int i = 0; i < 100; i++)
			{
				if (i >= 50)
					FirstSpace.Add(new System.Drawing.Point(i, i));
				if (i <= 25)
					SecondSpace.Add(new System.Drawing.Point(i, i));
			}

			if (!SecondSpace.IsSubsetOf(FirstSpace))
				Console.WriteLine("Test !IsSubSpace passed!");
			else Console.WriteLine("Test !IsSubSpace failed!");

			//test Contains
			FirstSpace = new Space();
			SecondSpace = new Space();

			for (int i = 0; i < 100; i++)
			{
				FirstSpace.Add(new System.Drawing.Point(i, i));
				if (i >= 25 && i <= 50)
					SecondSpace.Add(new System.Drawing.Point(i, i));
			}

			if (FirstSpace.Contains(SecondSpace))
				Console.WriteLine("Test Contains passed!");
			else Console.WriteLine("Test Contains failed!");

			//test !Contains
			FirstSpace = new Space();
			SecondSpace = new Space();

			for (int i = 0; i < 100; i++)
			{
				if( i <= 50)
				FirstSpace.Add(new System.Drawing.Point(i, i));
				if (i >= 75)
					SecondSpace.Add(new System.Drawing.Point(i, i));
			}

			if (!FirstSpace.Contains(SecondSpace))
				Console.WriteLine("Test !Contains passed!");
			else Console.WriteLine("Test !Contains failed!");

			//test IsSupersetOf
			FirstSpace = new Space();
			SecondSpace = new Space();

			for (int i = 0; i < 100; i++)
			{
				FirstSpace.Add(new System.Drawing.Point(i, i));
				if (i >= 75)
					SecondSpace.Add(new System.Drawing.Point(i, i));
			}

			if (FirstSpace.IsSupersetOf(SecondSpace))
				Console.WriteLine("Test IsSupersetOf passed!");
			else Console.WriteLine("Test IsSupersetOf failed!");

			//test !IsSupersetOf
			FirstSpace = new Space();
			SecondSpace = new Space();

			for (int i = 0; i < 100; i++)
			{
				if( i <= 25)
					FirstSpace.Add(new System.Drawing.Point(i, i));
				if (i >= 75)
					SecondSpace.Add(new System.Drawing.Point(i, i));
			}

			if (!FirstSpace.IsSupersetOf(SecondSpace))
				Console.WriteLine("Test !IsSupersetOf passed!");
			else Console.WriteLine("Test !IsSupersetOf failed!");

			//test GetUnion(Space s1, Space s2)_1
			FirstSpace = new Space();
			SecondSpace = new Space();

			for (int i = 0; i < 100; i++)
//.........这里部分代码省略.........
开发者ID:KyKoPho,项目名称:random-art,代码行数:101,代码来源:Program.cs

示例9: OnAdditionToSpace

 /// <summary>
 /// Sets up the vehicle's information when being added to the space.
 /// Called automatically when the space adds the vehicle.
 /// </summary>
 /// <param name="newSpace">New owning space.</param>
 public override void OnAdditionToSpace(Space newSpace)
 {
     newSpace.Add(body);
     foreach (Wheel wheel in Wheels)
     {
         wheel.OnAdditionToSpace(newSpace);
     }
 }
开发者ID:Anomalous-Software,项目名称:BEPUPhysics,代码行数:13,代码来源:Vehicle.cs


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