Пример #1
0
        private void LoadSnowParticleEmitter()
        {
            // Lets find the render camera and attach a particle emitter to it.
            var msgGetRender = ObjectPool.Aquire <MsgGetRenderEntity>();

            this.game.SendInterfaceMessage(msgGetRender, InterfaceType.Camera);

            if (msgGetRender.EntityID == QSGame.UniqueIDEmpty)
            {
                return;
            }

            var msgGetEntity = ObjectPool.Aquire <MsgGetEntityByID>();

            msgGetEntity.EntityID = msgGetRender.EntityID;
            this.game.SendInterfaceMessage(msgGetEntity, InterfaceType.SceneManager);

            if (msgGetEntity.Entity == null)
            {
                return;
            }

            ParticleEmitterComponent snowEmitter = EntityLoader.LoadComponent(msgGetEntity.Entity,
                                                                              ComponentType.ParticleEmitterComponent,
                                                                              this.game.Content,
                                                                              "Entities/ComponentDefinitions/ParticleEmitter/SnowWeatherEmitter")
                                                   as ParticleEmitterComponent;

            // Give the emitter some settings.
            snowEmitter.InitializeEmitterSettings(new Vector3(0.0f, 100.0f, 0.0f), 500, new Vector3(300.0f, 10.0f, 300.0f));
        }
Пример #2
0
        public void BoxStack(int totalRows, Vector3 offset)
        {
            int currentColumnMax = totalRows;

            float        boxScale = 9.0f;
            StaticModel  mesh     = this.game.ModelLoader.LoadStaticModel("Models/WoodCrate/Crate1");
            BoxShapeDesc boxShape = PhysicsComponent.CreateBoxShapeFromMesh(mesh, boxScale);

            for (int rows = 0; rows < totalRows; ++rows, --currentColumnMax)
            {
                for (int columns = 0; columns < currentColumnMax; ++columns)
                {
                    Vector3 boxPos = offset + new Vector3(columns * boxShape.Extents.X,
                                                          rows * boxShape.Extents.Y + (boxShape.Extents.Y * 0.5f),
                                                          0.0f);

                    boxPos.X -= currentColumnMax * boxShape.Extents.X * 0.5f;

                    int boxTemplate = 2;
                    if (rows == (totalRows - 1))
                    {
                        // Use a smoking box if we're on the top row
                        boxTemplate = 3;
                    }

                    var boxEntity = new BaseEntity(this.game, boxPos, Matrix.Identity, 9.0f);
                    this.game.SceneManager.AddEntityByTemplateID(boxEntity, boxTemplate);

                    if (boxTemplate == 3)
                    {
                        ParticleEmitterComponent emitter = boxEntity.GetComponentByType(ComponentType.ParticleEmitterComponent) as ParticleEmitterComponent;
                        // These give offsets for the emitter and how many particles per second to emit.
                        emitter.InitializeEmitterSettings(Vector3.Zero, 7, Vector3.Zero);
                    }
                }
            }
        }