Update() public method

public Update ( ) : void
return void
Example #1
0
        /// <summary>
        /// Berechnung von allen notwendingen Werten
        /// </summary>
        public void OnTick()
        {
            animationHandler.Update();
            inputManager.Update();//Updaten des InputManages für Key-Events
            for (int i = 0; i < Entities.Count; i++)
            {
                Entities[i].OnTick();
                if (((EntityLivingBase)Entities[i]).IsDead)
                {
                    Entities.RemoveAt(i);
                }
            }

            if (isIngame)
            {
                path = new Path(thePlayer.GridPosition, d.StartRoom.CenterPos / 15f, d);
            }
            //Wenn Spiel zu ende ist, wird der Spieler wird in ein Menü geworfen
            //if (entities.Count == 1)
            //{
            //    isIngame = false;
            //    SetScreen(new GuiWinScreen());
            //    entities.Clear();
            //    ingameGui = null;
            //}
            //else if (isIngame && thePlayer.IsDead)
            //{
            //    isIngame = false;
            //    SetScreen(new GuiDeathScreen());
            //    entities.Clear();
            //    ingameGui = null;
            //}
        }
Example #2
0
        public override void Update(GameTime gameTime)
        {
            KeyboardState keyboard = Keyboard.GetState();

            if (keyboard.IsKeyDown(controls.LeftKey) && position.X > 0)
            {
                position.X -= 10;
            }
            else if (keyboard.IsKeyDown(controls.RightKey) && position.X < 636)
            {
                position.X += 10;
            }
            if (isHit == true && currentBufferIndex <= TIMES_TO_BUFFER)
            {
                if (invulnerableBuffer < BUFFER_INTERVAL)
                {
                    invulnerableBuffer += gameTime.ElapsedGameTime.Milliseconds;
                }
                else if (invulnerableBuffer > BUFFER_INTERVAL)
                {
                    invulnerableBuffer  = 0;
                    currentBufferIndex += 1;
                }
            }
            else if (currentBufferIndex > TIMES_TO_BUFFER)
            {
                isHit = false;
                invulnerableBuffer = 0;
                currentBufferIndex = 1;
            }
            playerArea = new Rectangle((int)position.X, (int)position.Y, 37, 47);
            hitTimer  += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            animHandler.Update(gameTime);
        }
Example #3
0
 public virtual void Update(GameTime gameTime)
 {
     animationHandler.Update(gameTime);
     if (loc.Y > Game1.HEIGHT)
     {
         IsDead = true;
     }
     hitTimer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
 }
Example #4
0
        public override void Update()
        {
            anim.Update();
            spriteIndex    = anim.index;
            spritePosition = position;

            if ((int)position.X == (int)Game.player.position.X && (int)position.Y == (int)Game.player.position.Y)
            {
                OnTouchPlayer();
            }
        }
Example #5
0
        public override void Update(GameTime gameTime)
        {
            KeyboardState keyboard = Keyboard.GetState();

            if (keyboard.IsKeyDown(controls.LeftKey) && !prevKeyboard.IsKeyDown(controls.LeftKey))
            {
                if (keyTapped == controls.LeftKey)
                {
                    keyTapped = Keys.F24;
                    if (doubleTapTimer <= DOUBLE_TAP_TIME)
                    {
                        boostDir = -1;
                        if (boostTimer > BOOST_COOLDOWN)
                        {
                            boostTimer = 0;
                        }
                    }
                }
                else
                {
                    doubleTapTimer = 0;
                    keyTapped      = controls.LeftKey;
                }
            }
            if (keyboard.IsKeyDown(controls.RightKey) && !prevKeyboard.IsKeyDown(controls.RightKey))
            {
                if (keyTapped == controls.RightKey)
                {
                    keyTapped = Keys.F24;
                    if (doubleTapTimer <= DOUBLE_TAP_TIME)
                    {
                        boostDir = 1;
                        if (boostTimer > BOOST_COOLDOWN)
                        {
                            boostTimer = 0;
                        }
                    }
                }
                else
                {
                    doubleTapTimer = 0;
                    keyTapped      = controls.RightKey;
                }
            }
            Vector2 dir = Vector2.Zero;

            if (keyboard.IsKeyDown(controls.LeftKey) && keyboard.IsKeyDown(controls.RightKey))
            {
                dir.X = 0;
            }
            else if (keyboard.IsKeyDown(controls.LeftKey))
            {
                dir.X = -1;
            }
            else if (keyboard.IsKeyDown(controls.RightKey))
            {
                dir.X = 1;
            }

            if (keyboard.IsKeyDown(controls.UpKey) && keyboard.IsKeyDown(controls.DownKey))
            {
                dir.Y = 0;
            }
            else if (keyboard.IsKeyDown(controls.UpKey))
            {
                dir.Y = -1;
            }
            else if (keyboard.IsKeyDown(controls.DownKey))
            {
                dir.Y = 1;
            }
            if (keyboard.IsKeyDown(controls.FireKey))
            {
                weapon.Fire((int)loc.X + WIDTH / 2 + -weapon.ProjectileWidth / 2, (int)loc.Y + weapon.ProjectileHeight);
            }
            if (loc.X + dir.X * SPEED + WIDTH > Game1.WIDTH / 2)
            {
                loc.X = Game1.WIDTH / 2 - WIDTH;
            }
            else if (loc.X + dir.X * SPEED < 0)
            {
                loc.X = 0;
            }
            else
            {
                loc.X += dir.X * SPEED;
            }
            if (loc.Y + dir.Y * SPEED + HEIGHT > Game1.HEIGHT)
            {
                loc.Y = Game1.HEIGHT - HEIGHT;
            }
            else if (loc.Y + dir.Y * SPEED < RightGame.MaxHeight)
            {
                loc.Y = RightGame.MaxHeight;
            }
            else
            {
                loc.Y += dir.Y * SPEED;
            }

            animHandler.Update(gameTime);
            weapon.Update(gameTime);
            doubleTapTimer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            boostTimer     += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            hitTimer       += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            if (boostTimer <= BOOST_DURATION)
            {
                loc.X += boostDir * BOOST_SPEED;
            }


            prevKeyboard = keyboard;
        }
Example #6
0
 /// <summary>
 /// Updates this object.
 /// </summary>
 /// <param name="updateState">The current state of the update process.</param>
 public void Update(UpdateState updateState)
 {
     m_animHandler.Update(updateState);
 }