Ejemplo n.º 1
0
        public virtual void Update(GameTime gameTime)
        {
            float elapsedSeconds      = (float)gameTime.ElapsedGameTime.TotalSeconds;
            float elapsedMilliseconds = (float)gameTime.ElapsedGameTime.Milliseconds;

            position += elapsedMilliseconds * velocity;
            Vector2 p = new Vector2(MathHelper.Clamp(position.X, width / 2, Game1.WINDOW_WIDTH - width / 2), MathHelper.Clamp(position.Y, height / 2, Game1.WINDOW_HEIGHT - height / 2));

            position = p;

            List <Player> tile = GridManager.GridTile(position);

            if (gridTile != tile)
            {
                gridTile.Remove(this);
                tile.Add(this);
                gridTile = tile;
            }

            if (!moving)
            {
                playerAnimation.Stop();
            }
            else
            {
                playerAnimation.Play();
            }
            if (health <= 0)
            {
                isAlive = false;
                gridTile.Remove(this);
            }
            playerAnimation.UpdateFrame(elapsedSeconds);
        }
Ejemplo n.º 2
0
        public void Update(GameTime gameTime)
        {
            if (effectAnimation.Frame == effectAnimation.framecount - 1)
            {
                isAlive = false;
                return;
            }
            float elapsedSeconds = (float)gameTime.ElapsedGameTime.TotalSeconds;

            effectAnimation.UpdateFrame(elapsedSeconds);
        }