void IBlockState.Update(Sprite sprite, GameTime gameTime) { if (millisecondsElapsed < maxFallTime) { millisecondsElapsed += gameTime.ElapsedGameTime.Milliseconds; Vector2 position = sprite.Position; position.Y += (float)fallSpeed * ((float)gameTime.ElapsedGameTime.Milliseconds / 1000f); sprite.Position = position; } }
void IBlockState.Update(Sprite sprite, GameTime gameTime) { Vector2 position = sprite.Position; if (newCollision) { initialPosition.X = position.X; initialPosition.Y = position.Y; millisecondsElapsed = 0; newCollision = false; } millisecondsElapsed += gameTime.ElapsedGameTime.Milliseconds; // Simulate a bump from below if (millisecondsElapsed <= collisionDuration / 2) { position.Y -= bumpSpeed * ((float)millisecondsElapsed / 1000f); } else { position.Y += bumpSpeed * ((float)(millisecondsElapsed - collisionDuration / 2) / 1000f); position.Y = MathHelper.Clamp(position.Y, initialPosition.Y - 32, initialPosition.Y); } sprite.Position = position; if (millisecondsElapsed > collisionDuration) { sprite.Position = initialPosition; block.CurrentState = block.StateMachine.GetState(BlockState.Normal); if (block.CurrentType == BlockState.Brick || block.CurrentType == BlockState.Question) { if (block.ItemIndex < block.Items.Count) { block.Items[block.ItemIndex++].Reveal(megaman); } if (block.ItemIndex >= block.Items.Count) { block.CurrentType = BlockState.Used; } } block.StateChanged(); newCollision = true; } }
void IBlockState.Update(Sprite sprite, GameTime gameTime) { // empty method }