Update() public method

public Update ( ) : void
return void
示例#1
0
 public override void Update(GameTime gameTime)
 {
     timeAlive += gameTime.getSeconds();
     float rampUpFactor = (timeAlive / COLLECTABLE_SCORE_MAXIMUM_RAMP_UP_TIME);
     if (rampUpFactor > 1f)
         rampUpFactor = 1;
     rampUpScoreBonus = rampUpFactor * (baseScore / 4f);
     if (dying)
     {
         emitter.position = position;
         emitter.Update(gameTime);
         if (emitter.isFinished())
         {
             if (ActionAfterCollected == CollectedAction.Delete)
                 RetroGame.EscapeScreen.levelManager.collectablesToRemove.Add(this);
             else if (ActionAfterCollected == CollectedAction.Regenerate)
             {
                 dying = false;
                 timeAlive = 0;
                 ableToBeCollected = true;
                 collectedByEntity = null;
                 emitter.Reset();
                 emitter.active = true;
                 rampUpScoreBonus = 0;
             }
         }
     }
     updateCurrentLevelAndTile();
     base.Update(gameTime);
 }
示例#2
0
 public void ParticleUpdate(GameTime gameTime)
 {
     fireEmitter.position    = Position + new Vector2(22, 18);
     fireEmitter.minVelocity = new Vector2(2, 2);
     fireEmitter.maxVelocity = new Vector2(8, 8);
     fireEmitter.Update(gameTime);
 }
示例#3
0
 private void UpdateEmitter(float elapsedSeconds)
 {
     if (toBeRemoved <= 0 && Emitter != null && Emitter.Update(this, elapsedSeconds))
     {
         Interlocked.Exchange(ref toBeRemoved, 1);
     }
 }
        public void BasicBalTest()
        {
            Emitter  emit;
            DX11Game game = new DX11Game();

            game.InitDirectX();


            var texPool                 = new TexturePool(game);
            var testTexture             = GetTestTexture();
            BallParticleCreater creater = new BallParticleCreater();
            //SimpleParticleCreater creater = new SimpleParticleCreater();
            EmitterParameters param = new EmitterParameters();

            param.texture         = testTexture;
            param.particleCreater = creater;
            emit = new Emitter(texPool, game, param, 800, 600);//note: again screen size
            //game.Wpf.CreateClassForm(param);
            Seeder seed  = new Seeder(54);
            var    curve = Curve3D.CreateTestCurve();



            emit.Initialize();
            emit.InitializeRender();


            emit.CreateRenderData();
            emit.SetRenderData();
            emit.SetPosition(Vector3.Zero);
            float dist = 0;

            game.GameLoopEvent += delegate
            {
                // emit.setShader();
                emit.Update();
                if (dist > 100)
                {
                    dist = 0;
                }
                else
                {
                    dist += game.Elapsed * 1;
                }
                //emit.SetPosition(new Vector3(dist, 0, 0));
                Temp(dist, emit, curve);

                //Draw part

                //game.GraphicsDevice.Clear(Color.Black);
                game.Device.ImmediateContext.Rasterizer.State = game.HelperStates.RasterizerShowAll;
                emit.Render(game.SpectaterCamera.ViewProjection, game.SpectaterCamera.ViewInverse);
            };



            game.Run();
        }
示例#5
0
 public override void Update(float elapsed)
 {
     base.Update(elapsed);
     if (emitter.Parent != this)
     {
         emitter.Parent = this;
     }
     emitter.Update(elapsed);
     UpdateBoundingRect();
 }
示例#6
0
        public void Update(float deltaTime)
        {
            playerSprite.Update(deltaTime);
            UpdateInput(deltaTime);

            KeyboardState state      = Keyboard.GetState();
            MouseState    mouseState = Mouse.GetState();

            crosshair.position = game.MousePos;

            Vector2 direction = game.MousePos - playerSprite.position;

            rotation = (float)Math.Atan2(direction.X, direction.Y);
            playerAnimation.Rotation = -rotation;

            timerDelay -= deltaTime;

            footstepSoundInstance.Volume = 0.15f;
            fireballSoundInstance.Volume = 0.3f;

            if ((mouseState.LeftButton == ButtonState.Pressed) && timerDelay <= 0)
            {
                Cast();
                timerDelay = 0.5f;
            }

            UpdateFireballs(deltaTime);

            #region Running Effects
            if (state.IsKeyDown(Keys.A) || (state.IsKeyDown(Keys.D) || (state.IsKeyDown(Keys.W) || (state.IsKeyDown(Keys.S) == true))))
            {
                dustEmitter.position     = playerSprite.position + offset;
                dustEmitter.emissionRate = 15;
                dustEmitter.transparency = 1f;
                dustEmitter.minSize      = 2;
                dustEmitter.maxSize      = 5;
                dustEmitter.maxLife      = 1.0f;
            }
            else
            {
                dustEmitter.position = new Vector2(-200, -200);
            }

            dustEmitter.Update(deltaTime);

            if (state.IsKeyDown(Keys.A) || (state.IsKeyDown(Keys.D) || (state.IsKeyDown(Keys.W) || (state.IsKeyDown(Keys.S) == true))))
            {
                footstepSoundInstance.Play();
            }

            #endregion
        }
        public void FlameTest()
        {
            Emitter  emit;
            DX11Game game = new DX11Game();

            game.InitDirectX();
            FlameParticleCreater creater;
            //game.DrawFps = true;

            //var pool = new VertexDeclarationPool();
            //pool.SetVertexElements<Emitter.ParticleVertex>(Emitter.ParticleVertex.VertexElements);
            var texPool     = new TexturePool(game);
            var testTexture = GetTestTexture();

            creater = new FlameParticleCreater();
            EmitterParameters param = new EmitterParameters();

            param.EffectName      = "calculateFlame";
            param.texture         = testTexture;
            param.particleCreater = creater;
            emit = new Emitter(texPool, game, param, 800, 600);
            Seeder seed = new Seeder(54);

            var curve = Curve3D.CreateTestCurve();


            //texPool.Initialize(game);
            //pool.Initialize(game);

            emit.Initialize();
            emit.InitializeRender();


            emit.CreateRenderData();
            emit.SetRenderData();
            //emit.AddParticles(creater,1);

            float dist = 0;

            game.GameLoopEvent += delegate
            {
                dist += game.Elapsed;
                // emit.setShader();
                //Temp(dist, emit, curve);

                //setColors(emit);
                emit.Update();
                emit.Render(game.SpectaterCamera.ViewProjection, game.SpectaterCamera.ViewInverse);
            };

            game.Run();
        }
示例#8
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // TODO: Add your update logic here

            particleEmitter.Update(gameTime.ElapsedGameTime.Milliseconds * 0.001f);

            base.Update(gameTime);
        }
示例#9
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // TODO: Add your update logic here
            _particleEmitter1.Location = new SneakyParticleSystem.Vector2(Mouse.GetState().Position.X, Mouse.GetState().Position.Y);

            _particleEmitter1.Emit((float)gameTime.ElapsedGameTime.TotalSeconds);
            _particleEmitter1.Update((float)gameTime.ElapsedGameTime.TotalSeconds);

            _particleEmitter2.Emit((float)gameTime.ElapsedGameTime.TotalSeconds);
            _particleEmitter2.Update((float)gameTime.ElapsedGameTime.TotalSeconds);

            base.Update(gameTime);
        }
示例#10
0
        public override void Update(GameTime gameTime)
        {
            KeyboardState kState = Keyboard.GetState();
            MouseState    mState = Mouse.GetState();

            #region [Emitters Update]

            if (mState.LeftButton == ButtonState.Pressed)
            {
                Vector2 cursorScreenToWorldPosition = Camera.GetScreenToWorldPosition(new Vector2(mState.X, mState.Y));

                Emitters[5].EmitterBox.X = cursorScreenToWorldPosition.X;
                Emitters[5].EmitterBox.Y = cursorScreenToWorldPosition.Y;

                Emitters[5].Activated = true;
            }
            else
            {
                Emitters[5].Activated = false;
            }

            if (mState.RightButton == ButtonState.Pressed)
            {
                Vector2 cursorScreenToWorldPosition = Camera.GetScreenToWorldPosition(new Vector2(mState.X, mState.Y));

                Emitters[6].EmitterBox.X = cursorScreenToWorldPosition.X;
                Emitters[6].EmitterBox.Y = cursorScreenToWorldPosition.Y;

                Emitters[6].Activated = true;
            }
            else
            {
                Emitters[6].Activated = false;
            }

            foreach (ParticleEmitter Emitter in Emitters)
            {
                Emitter.Update(gameTime);
            }

            #endregion

            #region [Camera Update]

            if (kState.IsKeyDown(Keys.Q))
            {
                Camera.Zoom += 0.1f;
            }
            else if (kState.IsKeyDown(Keys.E))
            {
                Camera.Zoom -= 0.1f;
            }

            float ammount = 4f;
            if (kState.IsKeyDown(Keys.W))
            {
                Camera.Position.Y -= ammount;
            }
            else if (kState.IsKeyDown(Keys.S))
            {
                Camera.Position.Y += ammount;
            }
            if (kState.IsKeyDown(Keys.A))
            {
                Camera.Position.X -= ammount;
            }
            else if (kState.IsKeyDown(Keys.D))
            {
                Camera.Position.X += ammount;
            }

            Camera.GetTransform(Graphics.GraphicsDevice);

            #endregion
        }
示例#11
0
        public void Update(float deltaTime)
        {
            fireballSprite.position = position;

            fireEmitter.position     = position;
            fireEmitter.emissionRate = 15;
            fireEmitter.transparency = 1f;
            fireEmitter.minSize      = 2;
            fireEmitter.maxSize      = 5;
            fireEmitter.maxLife      = 1.0f;

            fireEmitter.Update(deltaTime);


            int tx = game.PixelToTile(fireballSprite.position.X - 8);
            int ty = game.PixelToTile(fireballSprite.position.Y - 8);

            bool nx = (fireballSprite.position.X) % Game1.tile != 0;

            bool ny = (fireballSprite.position.Y) % Game1.tile != 0;

            bool cell      = game.CellAtTileCoord(tx, ty) != 0;
            bool cellright = game.CellAtTileCoord(tx + 1, ty) != 0;
            bool celldown  = game.CellAtTileCoord(tx, ty + 1) != 0;
            bool celldiag  = game.CellAtTileCoord(tx + 1, ty + 1) != 0;

            if (this.velocity.Y > 0)
            {
                if ((celldown && !cell) || (celldiag && !cellright && nx))
                {
                    fireballSprite.position.Y = game.TileToPixel(ty);
                    isAlive = false;
                    ny      = false;
                }
            }

            else if (this.velocity.Y < 0)
            {
                if ((cell && !celldown) || (cellright && !celldiag && nx))
                {
                    fireballSprite.position.Y = game.TileToPixel(ty + 1);
                    cell      = celldown;
                    cellright = celldiag;
                    ny        = false;
                    isAlive   = false;
                }
            }

            if (this.velocity.X > 0)
            {
                if ((cellright && !cell) || (celldiag && !celldown && ny))
                {
                    fireballSprite.position.X = game.TileToPixel(tx);
                    isAlive = false;
                    fireballSprite.Pause();
                }
            }
            else if (this.velocity.X < 0)
            {
                if ((cell && !cellright) || (celldown && !celldiag && ny))
                {
                    fireballSprite.position.X = game.TileToPixel(tx + 1);
                    isAlive = false;
                    fireballSprite.Pause();
                }
            }
        }
示例#12
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            var gamepad1 = GamePadEx.GetState(PlayerIndex.One);

            if (gamepad1.Buttons.Back == ButtonState.Pressed)
            {
                ScreenUtil.Show(new TitleScreen(Parent));
            }

            // === TouchPanel or Mouse ===
            var touchState = TouchPanelEx.GetState();

            if (touchState.Count > 0)
            {
                emitter.Active =
                    touchState [0].State == TouchLocationState.Pressed ||
                    touchState [0].State == TouchLocationState.Moved;
                emitter.EmitterRect = new Rectangle(
                    (int)Math.Round(touchState [0].Position.X),
                    (int)Math.Round(touchState [0].Position.Y),
                    emitter.EmitterRect.Width,
                    emitter.EmitterRect.Height
                    );
            }
            else
            {
                emitter.Active = false;
            }
            // ===

            // === Controller or Keyboard ===
            if (gamepad1.IsButtonDown(Buttons.A))
            {
                emitter.Active = true;
            }

            if (gamepad1.DPad.Up == ButtonState.Pressed)
            {
                emitter.EmitterRect = new Rectangle(
                    emitter.EmitterRect.X,
                    emitter.EmitterRect.Y - 5,
                    emitter.EmitterRect.Width,
                    emitter.EmitterRect.Height);
            }
            else if (gamepad1.DPad.Down == ButtonState.Pressed)
            {
                emitter.EmitterRect = new Rectangle(
                    emitter.EmitterRect.X,
                    emitter.EmitterRect.Y + 5,
                    emitter.EmitterRect.Width,
                    emitter.EmitterRect.Height);
            }

            if (gamepad1.DPad.Left == ButtonState.Pressed)
            {
                emitter.EmitterRect = new Rectangle(
                    emitter.EmitterRect.X - 5,
                    emitter.EmitterRect.Y,
                    emitter.EmitterRect.Width,
                    emitter.EmitterRect.Height);
            }
            else if (gamepad1.DPad.Right == ButtonState.Pressed)
            {
                emitter.EmitterRect = new Rectangle(
                    emitter.EmitterRect.X + 5,
                    emitter.EmitterRect.Y,
                    emitter.EmitterRect.Width,
                    emitter.EmitterRect.Height);
            }
            // ===

            emitter.Update(gameTime.ElapsedGameTime.TotalSeconds);
        }
示例#13
0
        private void UpdateEmitter(GameTime gameTime)
        {
            fireEmitter.position = new Vector2((player.Position.X + (player.Bounds.Width / 2)), (player.Position.Y + player.Bounds.Height + 1));

            fireEmitter.Update(gameTime);
        }
示例#14
0
 public void FireEmitterUpdateCall()
 {
     _emitter.Update(1f / 60);
 }