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


C# EntityCollection.EnqueueSpawn方法代码示例

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


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

示例1: ExecuteImpl

        protected override void ExecuteImpl(EntityCollection entities)
        {
            var bulletP = new Entity("bullet") {
                Textured.Instance,
                Order2Update.Instance,

                new CustomOnEscape(new BoundingBox2(
                    new Vector2(0, 0),
                    new Vector2(640, 480)
                ), (e) => {
                    entities.EnqueueDestroy(e);
                }),

                { Textured.Texture, this.bulletTexture },
                { Properties.DestroysEnemies, true },
                { Properties.Damage, 10.0f },

                {
                    Collidable.Body,
                    new Body(new ShapePrimitive[] {
                        new CircleShape(Vector2.Zero, 8)
                    })
                },
            };

            var basicWeapon = new Entity {
                new CustomBulletEmitter((e, weaponOwner) => {
                    var bullet = bulletP.Create();
                    bullet.Set(Located.Position, e.Get(Located.Position) + weaponOwner.Get(Located.Position));
                    bullet.Set(Located.Velocity, e.Get(Located.Velocity));
                    bullet.Set(Properties.Owner, weaponOwner);
                    entities.EnqueueSpawn(bullet);
                })
            };

            var weapons = new[] {
                basicWeapon.Create("top").Configure((e) => {
                    e.Set(Located.Position, new Vector2(0, 0));
                    e.Set(Located.Velocity, new Vector2(7, 0));
                }),

                basicWeapon.Create("bottom").Configure((e) => {
                    e.Set(Located.Position, new Vector2(0, 30));
                    e.Set(Located.Velocity, new Vector2(7, 0));
                }),

                basicWeapon.Create("center").Configure((e) => {
                    e.Set(Located.Position, new Vector2(0, 15));
                    e.Set(Located.Velocity, new Vector2(7, 0));
                }),
            };

            this.weaponConfigs = new[] {
                new[] { weapons[2], },
                new[] { weapons[0], weapons[1], },
                new[] { weapons[0], weapons[1], weapons[2], },
            };
        }
开发者ID:strager,项目名称:SpermGame,代码行数:58,代码来源:ShipBulletScript.cs

示例2: ExecuteImpl

        protected override void ExecuteImpl(EntityCollection entities)
        {
            var shipScript = ShipScript.Instance;

            var player = shipScript.Ship.Create("player")
                .Configure(new IComponent[] {
                    new CustomKeyboardInputable((e, s) => {
                        e.Set(TimedEmitter.IsEmitting, s.IsKeyDown(Keys.X));
                    }),

                    new CustomKiller((e, killed) => {
                        uint earnedPoints = killed.Get(Properties.Points);
                        e.Update(Properties.Score, (x) => earnedPoints + x);
                    }),
                })
                .Configure(
                    Collidable.Body,
                    new Body(new ShapePrimitive[] {
                        new CircleShape(Vector2.Zero, 32)
                    })
                )
                .Configure(Located.Position, new Vector2(50, 50));

            entities.EnqueueSpawn(player);

            entities.EnqueueSpawn(new Entity("ship score display") {
                Texted.Instance,

                new CustomUpdated((e, gt) => {
                    // I have a bad feeling about the UI being updated like
                    // other entities.  =\
                    e.Set(Texted.Text, player.Get(Properties.Score).ToString());
                }),

                { Texted.Font, font },
                { Texted.Text, "hello world" },
            });
        }
开发者ID:strager,项目名称:SpermGame,代码行数:38,代码来源:PlayerScript.cs

示例3: ExecuteImpl

        protected override void ExecuteImpl(EntityCollection entities)
        {
            var powerupP = new Entity("powerup") {
                Textured.Instance,

                { Textured.Texture, this.powerupTexture },
                { Properties.IsPowerup, true },

                {
                    Collidable.Body,
                    new Body(new ShapePrimitive[] {
                        new CircleShape(Vector2.Zero, 12)
                    })
                },
            };

            entities.EnqueueSpawn(powerupP.Create().Configure((e) => {
                e.Set(Located.Position, new Vector2(200, 100));
            }));

            entities.EnqueueSpawn(powerupP.Create().Configure((e) => {
                e.Set(Located.Position, new Vector2(300, 300));
            }));
        }
开发者ID:strager,项目名称:SpermGame,代码行数:24,代码来源:PowerupsScript.cs

示例4: ExecuteImpl

        protected override void ExecuteImpl(EntityCollection entities)
        {
            entities.EnqueueSpawn(new Entity("enemy") {
                Textured.Instance,

                new CustomUpdated((e, gt) => {
                    e.Update(Properties.Milliseconds, (t) => t + (uint) gt.ElapsedGameTime.TotalMilliseconds);

                    float d = (float) Math.Sin(e.Get(Properties.Milliseconds) / 1000.0f) * 50;
                    e.Set(Located.Position, new Vector2(0, d) + new Vector2(500, 100));
                }),

                new CustomCollidable((e, other) => {
                    if (other.Get(Properties.DestroysEnemies)) {
                        entities.EnqueueDestroy(other);

                        var ownerE = other.Get(Properties.Owner);
                        Healthed.Damage(e, other.Get(Properties.Damage), ownerE);
                    }
                }),

                new CustomKillable((e, killer) => {
                    entities.EnqueueDestroy(e);
                }),

                { Textured.Texture, this.enemyTexture },
                { Located.Position, new Vector2(500, 100) },
                { Healthed.Health, 30.0f },
                { Properties.Points, 50U },

                {
                    Collidable.Body,
                    new Body(new ShapePrimitive[] {
                        new CircleShape(Vector2.Zero, 16)
                    })
                },
            });
        }
开发者ID:strager,项目名称:SpermGame,代码行数:38,代码来源:EnemiesScript.cs


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