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


C# Engine.AddComponent方法代码示例

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


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

示例1: RollingCircleEnemy

        public RollingCircleEnemy(Engine engine, Vector2 position)
            : base(engine, position)
        {
            animation = new Animation(engine, @"Characters\FlickeringCircle", 64, 64, 1, 2, 2, 15, Global.Animations.Repeat);
            animation.Play();

            enemyPhysicsComponent = new EnemyPhysicsComponent(Engine, position, Global.Shapes.Circle);
            enemyPhysicsComponent.MainFixture.Body.LinearDamping = 2.0f;
            enemyPhysicsComponent.MainFixture.CollisionFilter.CollisionCategories = (Category)Global.CollisionCategories.Enemy;
            enemyPhysicsComponent.MainFixture.OnCollision += EnemyOnCollision;

            deathAnimation = new Animation(engine, @"Miscellaneous\Explosion", 512, 512, 3, 4, 9, 20, Global.Animations.PlayOnce);
            deathAnimation.Scale = 0.3f;
            deathAnimation.DrawOrder = int.MaxValue - 1;

            enemySound = Engine.Audio.GetCue("EnterTheVoid");

            light = new Light(engine);
            light.Color = Color.White;
            light.Fov = MathHelper.TwoPi;
            light.Position = position;
            light.Range = 100;

            engine.AddComponent(this);
        }
开发者ID:PhoenixWright,项目名称:NePlus,代码行数:25,代码来源:RollingCircleEnemy.cs

示例2: Animation

        /// <summary>
        /// Constructs an animation from information about the spritesheet.
        /// </summary>
        /// <param name="engine">The game engine reference.</param>
        /// <param name="spriteSheetFilePath">The spritesheet filepath.</param>
        /// <param name="frameWidth">The width of a frame in the spritesheet.</param>
        /// <param name="frameHeight">The height of a frame in the spritesheet.</param>
        /// <param name="rows">The number of rows in the spritesheet.</param>
        /// <param name="cols">The number of columns in the spritesheet.</param>
        /// <param name="frameCount">The number of frames to play in the spritesheet.</param>
        /// <param name="framesPerSecond">The number of frames to display per second.</param>
        /// <param name="type">The type of animation (repeat, play once, etc.).</param>
        public Animation(Engine engine, string spriteSheetFilePath, int frameWidth, int frameHeight,
                         int rows, int cols, int frameCount, int framesPerSecond, Global.Animations type)
            : base(engine)
        {
            this.filePath = spriteSheetFilePath;
            this.frameWidth = frameWidth;
            this.frameHeight = frameHeight;
            this.rows = rows;
            this.columns = cols;
            this.frameCount = frameCount;
            this.framesPerSecond = framesPerSecond;
            this.type = type;

            timePerFrame = 1.0f / framesPerSecond;
            spriteOrigin = new Vector2(frameWidth / 2, frameHeight / 2);

            frames = new List<Rectangle>();

            this.Scale = 1.0f;
            this.Speed = 1.0f;
            SpriteEffect = SpriteEffects.None;

            // defaults to not playing
            Playing = false;

            engine.AddComponent(this);
        }
开发者ID:PhoenixWright,项目名称:NePlus,代码行数:39,代码来源:Animation.cs

示例3: Sprite

        public Sprite(Engine engine, string spriteFilepath)
            : base(engine)
        {
            sprite = engine.Content.Load<Texture2D>(spriteFilepath);
            spriteOrigin = new Vector2(sprite.Width / 2, sprite.Height / 2);

            Angle = 0.0f;
            Position = new Vector2();
            SpriteEffect = SpriteEffects.None;
            Visible = true;

            engine.AddComponent(this);
        }
开发者ID:PhoenixWright,项目名称:NePlus,代码行数:13,代码来源:Sprite.cs

示例4: Bullet

        public Bullet(Engine engine, Vector2 position, Vector2 direction, float angle, Global.CollisionCategories category)
            : base(engine)
        {
            DrawOrder = (int)Global.Layers.Projectiles;

            bulletPhysicsComponent = new BulletPhysicsComponent(engine, position, direction, angle, category);
            bulletPhysicsComponent.MainFixture.OnCollision += BulletOnCollision;

            bulletSprite = new Sprite(engine, @"Miscellaneous\RedBullet");
            bulletSprite.DrawOrder = DrawOrder;
            bulletSprite.Angle = angle;

            light = new Light(engine);
            light.Color = Color.Red;
            light.Fov = MathHelper.TwoPi;
            light.Intensity = 0.8f;
            light.Position = bulletPhysicsComponent.Position;
            light.Range = 200;
            light.ShadowType = Krypton.Lights.ShadowType.Illuminated;

            switch (category)
            {
                case Global.CollisionCategories.PlayerBullet:
                    bulletPhysicsComponent.MainFixture.CollisionFilter.CollidesWith = (Category)(Global.CollisionCategories.Enemy | Global.CollisionCategories.EnemyBullet | Global.CollisionCategories.Light | Global.CollisionCategories.Structure);
                    break;
                case Global.CollisionCategories.EnemyBullet:
                    bulletPhysicsComponent.MainFixture.CollisionFilter.CollidesWith = (Category)(Global.CollisionCategories.Player | Global.CollisionCategories.PlayerBullet | Global.CollisionCategories.Light | Global.CollisionCategories.Structure);
                    break;
                default:
                    // do nothing
                    break;
            }

            collided = false;

            flashAnimation = new Animation(Engine, @"Miscellaneous\flash", 512, 512, 3, 3, 6, 20, Global.Animations.PlayOnce);
            flashAnimation.Scale = 0.4f;
            flashAnimation.Position = bulletPhysicsComponent.Position;
            flashAnimation.DrawOrder = (int)Global.Layers.Projectiles;

            flashLight = new Light(engine);
            flashLight.Color = Color.Yellow;
            flashLight.Fov = MathHelper.TwoPi;
            flashLight.Intensity = 0.8f;
            flashLight.Position = bulletPhysicsComponent.Position;
            flashLight.Range = 100;
            flashLight.ShadowType = Krypton.Lights.ShadowType.Illuminated;
            flashLight.IsOn = false;

            engine.AddComponent(this);
        }
开发者ID:PhoenixWright,项目名称:NePlus,代码行数:51,代码来源:Bullet.cs

示例5: Lighting

        public Lighting(Engine engine)
            : base(engine)
        {
            Krypton = new KryptonEngine(engine, @"Krypton\KryptonEffect");

              Krypton.Bluriness = 3;
              Krypton.CullMode = CullMode.None;
              Krypton.Matrix = Engine.Camera.CameraMatrix;
              Krypton.SpriteBatchCompatablityEnabled = true;

              PointLightTexture = LightTextureBuilder.CreatePointLight(Engine.Video.GraphicsDevice, 512);

              this.DrawOrder = (int)Global.Layers.Lighting;
              engine.AddComponent(this);
        }
开发者ID:PhoenixWright,项目名称:Mystery,代码行数:15,代码来源:Lighting.cs

示例6: Enemy

        public Enemy(Engine engine, Vector2 position)
            : base(engine)
        {
            audioEmitter = new AudioEmitter();

            deathLight = new Light(engine);
            deathLight.Color = Color.Orange;
            deathLight.Fov = MathHelper.TwoPi;
            deathLight.IsOn = false;
            deathLight.Range = 200;

            Health = 100;

            engine.AddComponent(this);
        }
开发者ID:PhoenixWright,项目名称:NePlus,代码行数:15,代码来源:Enemy.cs

示例7: FlyingBoxEnemy

        public FlyingBoxEnemy(Engine engine, Vector2 position)
            : base(engine, position)
        {
            animation = new Animation(engine, @"Characters\GrayRotatingBox", 128, 128, 4, 4, 16, 9, Global.Animations.Repeat);
            animation.DrawOrder = (int)Global.Layers.AboveLighting;
            animation.Play();

            enemyPhysicsComponent = new EnemyPhysicsComponent(Engine, position, Global.Shapes.Square);
            enemyPhysicsComponent.MainFixture.Body.LinearDamping = 2.0f;
            enemyPhysicsComponent.MainFixture.CollisionFilter.CollisionCategories = (Category)Global.CollisionCategories.Enemy;
            enemyPhysicsComponent.MainFixture.OnCollision += EnemyOnCollision;

            deathAnimation = new Animation(engine, @"Miscellaneous\Explosion", 512, 512, 3, 4, 9, 20, Global.Animations.PlayOnce);
            deathAnimation.DrawOrder = int.MaxValue - 1;
            deathAnimation.Scale = 0.3f;

            attacking = false;

            enemySound = Engine.Audio.GetCue("WeirdHoverSound");

            engine.AddComponent(this);
        }
开发者ID:PhoenixWright,项目名称:NePlus,代码行数:22,代码来源:FlyingBoxEnemy.cs

示例8: Initialize

 public void Initialize(Engine.IEngine engine)
 {
     engine.AddComponent("n2.trash", typeof(ITrashHandler), typeof(TrashHandler));
     engine.AddComponent("n2.deleteInterceptor", typeof(DeleteInterceptor));
 }
开发者ID:spmason,项目名称:n2cms,代码行数:5,代码来源:TrashcanInitializer.cs

示例9: Initialize

 public void Initialize(Engine.IEngine engine)
 {
     engine.AddComponent("n2.linkTracker", typeof(Tracker));
 }
开发者ID:cherylhanlon,项目名称:Tigers,代码行数:4,代码来源:LinkTrackerInitializer.cs


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