/// <summary> /// remove from composite /// </summary> /// <param name="c">adding component</param> public override void Remove(Component c) { if (ChildComponents.Count < Capacity) { ChildComponents.Remove(c); } }
public override void Update(GameTime gameTime) { if (InputHandler.KeyReleased(Keys.Escape)) { stateManager.PopState(); } player.Update(gameTime); sprite.Update(gameTime); UpdateMouse(); Vector2 motion = new Vector2(); if (InputHandler.KeyDown(Keys.W)) { sprite.CurrentAnimation = AnimationKey.Up; motion.Y = -1; } else if (InputHandler.KeyDown(Keys.S)) { sprite.CurrentAnimation = AnimationKey.Down; motion.Y = 1; } if (InputHandler.KeyDown(Keys.A)) { sprite.CurrentAnimation = AnimationKey.Left; motion.X = -1; } else if (InputHandler.KeyDown(Keys.D)) { sprite.CurrentAnimation = AnimationKey.Right; motion.X = 1; } if (InputHandler.KeyDown(Keys.NumPad7)) { sprite.CurrentAnimation = AnimationKey.UpLeft; motion.X = -1; motion.Y = -1; } if (InputHandler.KeyDown(Keys.NumPad9)) { sprite.CurrentAnimation = AnimationKey.UpRight; motion.X = 1; motion.Y = -1; } if (InputHandler.KeyDown(Keys.NumPad1)) { sprite.CurrentAnimation = AnimationKey.DownLeft; motion.X = -1; motion.Y = 1; } if (InputHandler.KeyDown(Keys.NumPad3)) { sprite.CurrentAnimation = AnimationKey.DownRight; motion.X = 1; motion.Y = 1; } if (motion != Vector2.Zero) { sprite.IsAnimating = true; motion.Normalize(); sprite.Position += motion * sprite.Speed; sprite.LockToMap(); if (player.Camera.CameraMode == CameraMode.Follow) { player.Camera.LockToSprite(sprite); } } else { sprite.IsAnimating = false; } if (InputHandler.KeyReleased(Keys.C)) { player.Camera.ToggleCameraMode(); if (player.Camera.CameraMode == CameraMode.Follow) { player.Camera.LockToSprite(sprite); } } base.Update(gameTime); if (InputHandler.KeyReleased(Keys.I)) { if (ChildComponents.Contains(gameRef.InventoryScreen)) { ChildComponents.Remove(gameRef.InventoryScreen); //gameRef.IsMouseVisible = false; } else { ChildComponents.Add(gameRef.InventoryScreen); //gameRef.IsMouseVisible = true; } } }