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


C# Entity.FindComponent方法代码示例

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


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

示例1: PlayerAIBehavior

 public PlayerAIBehavior(Entity ball)
     : base("PlayerIABehavior")
 {
     this.trans2D = null;
     this.ball = ball;
     this.transBall2D = ball.FindComponent<Transform2D>();
     this.ballBehavior = ball.FindComponent<BallBehavior>();
     this.direction = ballBehavior.HorizontalDirection;
 }
开发者ID:123asd123A,项目名称:Samples,代码行数:9,代码来源:PlayerAIBehavior.cs

示例2: CreateJoystickButton

 private void CreateJoystickButton(string name, float x, float y, float rotation, EventHandler<GestureEventArgs> pressed, EventHandler<GestureEventArgs> released)
 {
     var upButton = new Entity(name)
         .AddComponent(new Sprite("Content/JoystickButton.wpk"))
         .AddComponent(new SpriteRenderer(DefaultLayers.Alpha))
         .AddComponent(new Transform2D() { Origin = Vector2.One / 2, X = x, Y = y, Rotation = rotation })
         .AddComponent(new TouchGestures())
         .AddComponent(new RectangleCollider());
     upButton.FindComponent<TouchGestures>().TouchPressed += pressed;
     upButton.FindComponent<TouchGestures>().TouchReleased += released;
     EntityManager.Add(upButton);
 }
开发者ID:noatom,项目名称:Samples,代码行数:12,代码来源:MyScene.cs

示例3: Fire

        public void Fire()
        {
            var bullet = new Entity()
                    .AddComponent(new Transform2D())
                    .AddComponent(new Sprite(WaveContent.Assets.Bullet_png))
                    .AddComponent(new SpriteRenderer());

            bullet.FindComponent<Transform2D>().Position = this.Transform.Position;
            bullet.FindComponent<Transform2D>().Origin = Vector2.One / 2;
            bullet.FindComponent<Transform2D>().DrawOrder = 10;

            bullet.AddComponent(new BulletBehavior());

            EntityManager.Add(bullet);
        }
开发者ID:julietsvq,项目名称:Samples,代码行数:15,代码来源:ShipBehavior.cs

示例4: Update

        protected override void Update(TimeSpan gameTime)
        {
            var touches = WaveServices.Input.TouchPanelState;

            if (touches.Count > 0)
            {
                if (!pressed)
                {
                    pressed = true;

                    var sphere = new Entity()
                          .AddComponent(new Transform3D() { Scale = new Vector3(1) })
                          .AddComponent(new MaterialsMap())
                          .AddComponent(Model.CreateSphere())
                          .AddComponent(new SphereCollider3D())
                          .AddComponent(new RigidBody3D() { Mass = 2, EnableContinuousContact = true })
                          .AddComponent(new TimeAliveBehavior())
                          .AddComponent(new ModelRenderer());

                    this.EntityManager.Add(sphere);

                    RigidBody3D rigidBody = sphere.FindComponent<RigidBody3D>();
                    rigidBody.ResetPosition(Camera.Position);
                    var direction = Camera.Transform.WorldTransform.Forward;
                    direction.Normalize();
                    rigidBody.ApplyLinearImpulse(100 * direction);
                }
            }
            else
            {
                pressed = false;
            }
        }
开发者ID:nagyistoce,项目名称:WaveEngine-Samples,代码行数:33,代码来源:ShootBehavior.cs

示例5: CreateScene

        protected override void CreateScene()
        {            
            // Main Camera
            ViewCamera camera = new ViewCamera("MainCamera", new Vector3(0, 400, 1200), new Vector3(0, 400, 0));
            camera.BackgroundColor = Color.Black;
            EntityManager.Add(camera.Entity);            

            // Initialize particle system

            Entity entitySystem = new Entity("Particles")
                .AddComponent(new Transform3D())
                .AddComponent(new ParticleBehavior())
                .AddComponent(new ParticleSystemRenderer3D());

            var behavior = entitySystem.FindComponent<ParticleBehavior>();
            behavior.ApplyChanges();
            behavior.ApplyMaterial();

            EntityManager.Add(entitySystem);

            textBlock1 = new TextBlock()
            {
                Margin = new Thickness(10),
                Text = "Fire",
                TextWrapping = true,
            };
            EntityManager.Add(textBlock1.Entity);
        }
开发者ID:123asd123A,项目名称:Samples,代码行数:28,代码来源:MyScene.cs

示例6: LinkedRopeBehavior

 public LinkedRopeBehavior(Entity from, Vector2 fromOrigin, Entity to, Vector2 toOrigin)
 {
     this.fromTransform = from.FindComponent<Transform2D>();
     this.toTransform = to.FindComponent<Transform2D>();
     this.fromOrigin = fromOrigin;
     this.toOrigin = toOrigin;
 }
开发者ID:dezol,项目名称:QuickStarters,代码行数:7,代码来源:LinkedRopeBehavior.cs

示例7: CreateScene

        protected override void CreateScene()
        {
            RenderManager.BackgroundColor = Color.Black;

            var startButtonEntity = new Entity("StartButton")
            .AddComponent(new Transform2D())
            .AddComponent(new TextControl("Content/SegoeBlack20.wpk")
            {
                Text = "Press here",
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Foreground = Color.White,
            })
            .AddComponent(new TextControlRenderer())
            .AddComponent(new RectangleCollider())
            .AddComponent( new TouchGestures());

            startButtonEntity.FindComponent<TouchGestures>().TouchPressed += new EventHandler<GestureEventArgs>(MyScene_TouchPressed);

            EntityManager.Add(startButtonEntity);

            var screenLayerStateEntity = new Entity("ScreenLayerStateButton")
            .AddComponent(new Transform2D())
            .AddComponent(new TextControl("Content/SegoeBlack20.wpk")
            {
                Text = string.Format("Screen state: {0}", WaveServices.ScreenLayers.Tag),
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment = VerticalAlignment.Bottom,
                Foreground = Color.White,
            })
            .AddComponent(new TextControlRenderer());

            EntityManager.Add(screenLayerStateEntity);
        }
开发者ID:noatom,项目名称:Samples,代码行数:34,代码来源:MainScene.cs

示例8: GetTotalRectangle

        private RectangleF GetTotalRectangle(Entity entity, Transform2D parentTransform2D)
        {
            RectangleF result = RectangleF.Empty;
            var entityTransform = entity.FindComponent<Transform2D>();

            if (entityTransform != null)
            {
                result = entityTransform.Rectangle;

                if (parentTransform2D != null)
                {
                    result.Offset(
                        entityTransform.X - (entityTransform.Rectangle.Width * entityTransform.Origin.X),
                        entityTransform.Y - (entityTransform.Rectangle.Height * entityTransform.Origin.Y));

                    result.Offset(
                        -1 * (parentTransform2D.X - (parentTransform2D.Rectangle.Width * parentTransform2D.Origin.X)),
                        -1 * (parentTransform2D.Y - (parentTransform2D.Rectangle.Height * parentTransform2D.Origin.Y)));
                }

                foreach (var child in entity.ChildEntities)
                {
                    var childTotalRectangle = this.GetTotalRectangle(child, entityTransform);

                    RectangleF.Union(ref result, ref childTotalRectangle, out result);
                }
            }

            return result;
        }
开发者ID:dezol,项目名称:QuickStarters,代码行数:30,代码来源:ChildrenRectangle.cs

示例9: CreateScene

        protected override void CreateScene()
        {
            var camera2D = new FixedCamera2D("Camera2D") { BackgroundColor = Color.Black };
            EntityManager.Add(camera2D);

            int offset = 100;

            //var title = new Entity("Title")
            //                   .AddComponent(new Sprite("Content/Texture/TitlePong.wpk"))
            //                   .AddComponent(new SpriteRenderer(DefaultLayers.Alpha))
            //                   .AddComponent(new Transform2D()
            //                   {
            //                       Y = WaveServices.Platform.ScreenHeight / 2 - offset,
            //                       X = WaveServices.Platform.ScreenWidth / 2 - 150
            //                   });

            //EntityManager.Add(title);

            var multiplayerButtonEntity = new Entity("MultiplayerButton")
                                .AddComponent(new Transform2D()
                                {
                                    Y = WaveServices.Platform.ScreenHeight / 2 + 50,
                                    X = WaveServices.Platform.ScreenWidth / 2 - offset,
                                    XScale = 2f,
                                    YScale = 2f
                                })
                                .AddComponent(new TextControl()
                                {
                                    Text = "Multiplayer",
                                    Foreground = Color.White,
                                })
                                .AddComponent(new TextControlRenderer())
                                .AddComponent(new RectangleCollider())
                                .AddComponent(new TouchGestures());

            multiplayerButtonEntity.FindComponent<TouchGestures>().TouchPressed += new EventHandler<GestureEventArgs>(Multiplayer_TouchPressed);

            EntityManager.Add(multiplayerButtonEntity);

            var singleplayerButtonEntity = new Entity("SingleplayerButton")
                                .AddComponent(new Transform2D()
                                {
                                    Y = WaveServices.Platform.ScreenHeight / 2,
                                    X = WaveServices.Platform.ScreenWidth / 2 - offset,
                                    XScale = 2f,
                                    YScale = 2f
                                })
                                .AddComponent(new TextControl()
                                {
                                    Text = "Single Player",
                                    Foreground = Color.White,
                                })
                                .AddComponent(new TextControlRenderer())
                                .AddComponent(new RectangleCollider())
                                .AddComponent(new TouchGestures());

            singleplayerButtonEntity.FindComponent<TouchGestures>().TouchPressed += new EventHandler<GestureEventArgs>(Singleplayer_TouchPressed);

            EntityManager.Add(singleplayerButtonEntity);
        }
开发者ID:itcthienkhiem,项目名称:VietFGame,代码行数:60,代码来源:MenuScene.cs

示例10: CreateScene

        protected override void CreateScene()
        {
            FixedCamera2D camera2d = new FixedCamera2D("camera");
            EntityManager.Add(camera2d);

            var credits = new TextBlock()
            {
                Text = "Braid's art copyright from their original owners\n" +
                       "Sprites from Cyrus Annihilator, background from David Hellman's web\n" +
                       "We just love this game and wanted to make a small tribute within this sample :-)",
                Margin = new Thickness(10, 10, 0, 0),
                Foreground = Color.Black
            };

            var sky = new Entity("Sky")
                .AddComponent(new Sprite("Content/Sky.wpk"))
                .AddComponent(new SpriteRenderer(DefaultLayers.Alpha))
                .AddComponent(new Transform2D()
                {
                    Origin = new Vector2(0.5f, 1),
                    X = WaveServices.Platform.ScreenWidth / 2,
                    Y = WaveServices.Platform.ScreenHeight
                });
            var floor = new Entity("Floor")
                .AddComponent(new Sprite("Content/Floor.wpk"))
                .AddComponent(new SpriteRenderer(DefaultLayers.Alpha))
                .AddComponent(new Transform2D()
                {
                    Origin = new Vector2(0.5f, 1),
                    X = WaveServices.Platform.ScreenWidth / 2,
                    Y = WaveServices.Platform.ScreenHeight
                });

            // Tim
            var tim = new Entity("Tim")
                .AddComponent(new Transform2D()
                {
                    X = WaveServices.Platform.ScreenWidth / 2,
                    Y = WaveServices.Platform.ScreenHeight - 46,
                    Origin = new Vector2(0.5f, 1)
                })
                .AddComponent(new Sprite("Content/TimSpriteSheet.wpk"))
                .AddComponent(Animation2D.Create<TexturePackerGenericXml>("Content/TimSpriteSheet.xml")
                    .Add("Idle", new SpriteSheetAnimationSequence() { First = 1, Length = 22, FramesPerSecond = 11 })
                    .Add("Running", new SpriteSheetAnimationSequence() { First = 23, Length = 27, FramesPerSecond = 27 }))
                .AddComponent(new AnimatedSpriteRenderer())
                .AddComponent(new TimBehavior());

            // We add the floor the first so the rocks are on top of Tim
            EntityManager.Add(credits.Entity);
            EntityManager.Add(floor);
            EntityManager.Add(tim);
            EntityManager.Add(sky);

            var anim2D = tim.FindComponent<Animation2D>();
            anim2D.Play(true);
        }
开发者ID:123asd123A,项目名称:Samples,代码行数:57,代码来源:MyScene.cs

示例11: CreateScene

        protected override void CreateScene()
        {
            this.Load(WaveContent.Scenes.MyScene);

            this.teapot = this.EntityManager.Find("teapot");
            this.disappearMaterial = new DisappearMaterial(WaveContent.Assets.Textures.tile1_png,
                                                                        WaveContent.Assets.Textures.Noise_png,
                                                                        WaveContent.Assets.Textures.Burn_png);
            teapot.FindComponent<MaterialsMap>().DefaultMaterial = disappearMaterial;
        }
开发者ID:WaveEngine,项目名称:Samples,代码行数:10,代码来源:MyScene.cs

示例12: CreateUI

        /// <summary>
        /// Create User Interface (UI)
        /// </summary>
        private void CreateUI()
        {
            var isisBehavior = EntityManager.Find("isis").FindComponent<IsisBehavior>();
            CreateJoystickButton("UpButton", 200, WaveServices.Platform.ScreenHeight - 300, 0,
                (o, e) => { isisBehavior.GoUp = true; },
                (o, e) => { isisBehavior.GoUp = false; });
            CreateJoystickButton("DownButton", 200, WaveServices.Platform.ScreenHeight - 100, MathHelper.Pi,
                (o, e) => { isisBehavior.GoDown = true; },
                (o, e) => { isisBehavior.GoDown = false; });
            CreateJoystickButton("LeftButton", 100, WaveServices.Platform.ScreenHeight - 200, -MathHelper.PiOver2,
                (o, e) => { isisBehavior.GoLeft = true; },
                (o, e) => { isisBehavior.GoLeft = false; });
            CreateJoystickButton("RightButton", 300, WaveServices.Platform.ScreenHeight - 200, MathHelper.PiOver2,
                (o, e) => { isisBehavior.GoRight = true; },
                (o, e) => { isisBehavior.GoRight = false; });

            var shiftButton = new Entity("ShiftButton")
                .AddComponent(new Sprite("Content/ShiftButton.wpk"))
                .AddComponent(new SpriteRenderer(DefaultLayers.Alpha))
                .AddComponent(new Transform2D() { X = WaveServices.Platform.ScreenWidth - 250, Y = WaveServices.Platform.ScreenHeight - 250 })
                .AddComponent(new TouchGestures())
                .AddComponent(new RectangleCollider());
            shiftButton.FindComponent<TouchGestures>().TouchPressed += (o, e) => { isisBehavior.Run = true; };
            shiftButton.FindComponent<TouchGestures>().TouchReleased += (o, e) => { isisBehavior.Run = false; };
            EntityManager.Add(shiftButton);

            var wireframeModeToggle = new ToggleSwitch()
            {
                IsOn = false,
                OnText = "Wireframe?",
                OffText = "Wireframe?",
                Width = 175,
                Margin = new Thickness(50, 50, 0, 0)
            };

            wireframeModeToggle.Toggled += (o, e) =>
            {
                ((OpaqueLayer)RenderManager.FindLayer(DefaultLayers.Opaque)).FillMode = wireframeModeToggle.IsOn ? FillMode.Wireframe : FillMode.Solid;
            };

            EntityManager.Add(wireframeModeToggle.Entity);
        }
开发者ID:123asd123A,项目名称:Samples,代码行数:45,代码来源:MyScene.cs

示例13: BallBehavior

        public BallBehavior(Entity player, Entity barBot, Entity barTop, Entity barLeft, Entity barRight, Entity brick)
            : base("BallBehavior")
        {
            this.trans2D = null;
            //			this.player = player;
            //			this.rectPlayer = player.FindComponent<RectangleCollider>();
            this.barBot = barBot;
            this.rectBarBot = barBot.FindComponent<RectangleCollider>();
            playerTrans = barBot.FindComponent<Transform2D>();
            this.barTop = barTop;
            this.rectBarTop = barTop.FindComponent<RectangleCollider>();
            this.barLeft = barLeft;
            this.rectBarLeft = barLeft.FindComponent<RectangleCollider>();
            this.barRight = barRight;
            this.rectBarRight = barRight.FindComponent<RectangleCollider>();

            this.brick = brick;
            this.rectBrick = brick.FindComponent<RectangleCollider>();

            //this.circleBall = this.Owner.FindComponent<CircleCollider>();
        }
开发者ID:jaumefc,项目名称:arkanoid,代码行数:21,代码来源:BallBehavior.cs

示例14: Follower2DBehavior

        public Follower2DBehavior(Entity entity, FollowTypes followType)
        {
            this.followedTranform = entity.FindComponent<Transform2D>();
            this.followType = followType;

            this.lastFollowPosition = Vector2.Zero;

            if (this.lastFollowPosition == null)
            {
                throw new NotImplementedException("The Transform2D component must be used by the entity to follow");
            }
        }
开发者ID:dezol,项目名称:QuickStarters,代码行数:12,代码来源:Follower2DBehavior.cs

示例15: BallBehavior

 public BallBehavior(Entity player, Entity barBot, Entity barTop, Entity playerIA)
     : base("BallBehavior")
 {
     this.trans2D = null;
     this.player = player;
     this.rectPlayer = player.FindComponent<RectangleCollider>();
     this.player2 = playerIA;
     this.rectPlayer2 = playerIA.FindComponent<RectangleCollider>();
     this.barBot = barBot;
     this.rectBarBot = barBot.FindComponent<RectangleCollider>();
     this.barTop = barTop;
     this.rectBarTop = barTop.FindComponent<RectangleCollider>();
 }
开发者ID:123asd123A,项目名称:Samples,代码行数:13,代码来源:BallBehavior.cs


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