public virtual void Update(GameTime gameTime, KeyboardState currentKeyState, KeyboardState lastKeyState, bool resetMovement = true) { position.Y = MathHelper.Clamp(position.Y, Tile.Width + Tile.Width + localBounds.Height, (level.Height * Tile.Width) - Tile.Width - Tile.Width); UpdateDirection(); ApplyPhysics(gameTime); position.Y = MathHelper.Clamp(position.Y, Tile.Width + Tile.Width + localBounds.Height, (level.Height * Tile.Width) - Tile.Width - Tile.Width); RegenHealth(gameTime); //Reset our variables every frame if (resetMovement) { movement = Vector2.Zero; } wasClimbing = isClimbing; isClimbing = false; // Clear input. isJumping = false; health = MathHelper.Clamp(Health, 0, 100); energy = MathHelper.Clamp(Energy, 0, 100); if (this is PlayerCharacter) { if (lastPosition.X != Position.X && Level.Gamemode != GameMode.Sandbox) { level.backgroundPosition.X -= lastPosition.X - Position.X; } position = level.tiles.SetPositionRepeat(position, true); } else { position = level.tiles.SetPositionRepeat(position, false); } if (Level.tiles[(int)(position.X / Tile.Width), (int)(position.Y / Tile.Width) - 1].Foreground.ID == Item.PressurePlate.ID) { ElectronicTile t = (Level.tiles[(int)(position.X / Tile.Width), (int)(position.Y / Tile.Width) - 1] as ElectronicTile); if (t.State == 0) { t.State = 1; UpdatePressurePlateState(t); } } }
private void UpdatePressurePlateState(ElectronicTile t) { level.Actions.Enqueue(new QueueItem( () => { if (t.Foreground.ID == Item.PressurePlate.ID && Level.tiles[(int)(position.X / Tile.Width), (int)(position.Y / Tile.Width) - 1] != t) { if ((t is ElectronicTile) && t.State == 1) { t.State = 0; foreach (Wire w in t.Outputs[0]) { w.Powered = false; } } } else { UpdatePressurePlateState(t); } }, 500, false) ); }