/// <summary> /// Handles input for the gamestate and the HUD. /// Updates the ControlState (NOTE: all input will be handled by this in future). /// </summary> /// <param name="gameTime"></param> /// <param name="input"></param> public void HandleInput(GameTime gameTime, InputState input) { // ScreenManager.GetInstance().Game.IsMouseVisible = true; GameWorldControlState.GetInstance().HandleInput(input); if (input.CurrentKeyboardState.IsKeyDown(Keys.Escape) && input.PreviousKeyboardState.IsKeyUp(Keys.Escape)) { // Pause(this, new EventArgs()); if (!isOptionsMenuOpen) { OpenOptionsMenu(); } else { PlayGame(null); } } if (!isOptionsMenuOpen) { if (input.CurrentKeyboardState.IsKeyDown(Keys.P) && input.PreviousKeyboardState.IsKeyUp(Keys.P)) { if (!isPaused) { PauseGame(this, new EventArgs()); isPaused = true; } else { PlayGame(null); isPaused = false; } } } //Handle Input for its screens //NOTE: Will need to determine which element has focus if (hasFocus) { _gameState.HandleInput(gameTime, input); if (_hudScreen.HasFocus) { _hudScreen.HandleInput(gameTime, input, _gameState); } //NOTE: Currently, handling input for UI and world is mutually exclusive. This is incorrect. i.e. can be clicking on UI while moving in 3D //Mouse input can only be applied to one at a time, but both should be able to handle input overall /* if (useRenderer&&worldScreen.HasFocus) * { * worldScreen.HandleInput(gameTime, input, _gameState); * }*/ } }
public EquippedItemsInventory(CharacterInventory owner) { _owner = owner; _primaryHandSlot = new EquippedToolInventory(this); _primaryHandSlot.ToolAddedEvent += OnPrimaryToolAdded; _primaryHandSlot.ToolRemovedEvent += _owner.SaveToolAbilitiesPrimary; _secondaryHandSlot = new EquippedToolInventory(this); _secondaryHandSlot.ToolAddedEvent += OnSecondaryToolAdded; _secondaryHandSlot.ToolRemovedEvent += _owner.SaveToolAbilitiesSecondary; GameWorldControlState.GetInstance().SelectAbilityEvent += SelectAbility; GameWorldControlState.GetInstance().PrimaryHandAbilityOnClickEvent += _primaryHandSlot.ActiveAbilityOnClick; GameWorldControlState.GetInstance().SecondaryHandAbilityOnClickEvent += _secondaryHandSlot.ActiveAbilityOnClick; }
public Renderer(GraphicsDevice GraphicsDevice) { TEMPlights = new List <PointLight>(); TEMPlights.Add(new PointLight { DiffuseColour = new Vector3(1, 1, 1), Position = new Vector3(50, 10, 30), SpecularColour = new Vector3(0, 0, 1), Attenuation = 50, Falloff = 2 } ); TEMPlights.Add(new PointLight { DiffuseColour = new Vector3(1, 0, 0), Position = new Vector3(-10, 10, -10), SpecularColour = new Vector3(1, 0, 0), Attenuation = 20, Falloff = 20 } ); TEMPlights.Add(new PointLight { DiffuseColour = new Vector3(1, 1, 1), Position = new Vector3(0, 10, 30), SpecularColour = new Vector3(0, 1, 0), Attenuation = 50, Falloff = 2 } ); sphereModel = ScreenManager.GetInstance().ContentManager.Load <Model>("Models\\sphere"); GameWorldControlState.GetInstance().ToggleShadersEvent += ToggleActiveRenderTarget; viewWidth = GraphicsDevice.Viewport.Width; viewHeight = GraphicsDevice.Viewport.Height; // Create the three render targets _depthTarget = new RenderTarget2D(GraphicsDevice, viewWidth, viewHeight, false, SurfaceFormat.Single, DepthFormat.Depth24); _normalTarget = new RenderTarget2D(GraphicsDevice, viewWidth, viewHeight, false, SurfaceFormat.Color, DepthFormat.Depth24); _lightTarget = new RenderTarget2D(GraphicsDevice, viewWidth, viewHeight, false, SurfaceFormat.Color, DepthFormat.Depth24); _outputTarget = new RenderTarget2D(GraphicsDevice, viewWidth, viewHeight, false, SurfaceFormat.Color, DepthFormat.Depth24); // Load effects /* depthNormalEffect = Content.Load<Effect>("PPDepthNormal"); * lightingEffect = Content.Load<Effect>("PPLight"); * */ this.graphicsDevice = GraphicsDevice; }
protected void BuildTooltip(float width, float height) { _mousePosition = new Vector2(GameWorldControlState.GetInstance().InputState.CurrentMouseState.X, GameWorldControlState.GetInstance().InputState.CurrentMouseState.Y); /* float height = 0; * float width = 0;//Use the width of the longest string * _namePositionOffset = new Vector2(_padding.X, _padding.Y); * Vector2 nameMeasurement = ScreenManager.GetInstance().DefaultMenuFont.MeasureString("" + _inventoryItem.Name); * width = nameMeasurement.X; * height += nameMeasurement.Y;*/ _boundingBox = new Rectangle(0, 0, (int)(width + _padding.X * 5), (int)(height + _padding.Y * 5)); _background = new Texture2D(ScreenManager.GetInstance().GraphicsDevice, _boundingBox.Width, _boundingBox.Height); Color[] data = new Color[_boundingBox.Width * _boundingBox.Height]; for (int i = 0; i < data.Length; ++i) { data[i] = Color.Black; } _background.SetData(data); //Set desired position and see if it will run offscreen switch (_leftRightAlignment) { case LeftRightAlignment.Left: { _boundingBox.X = (int)((_mousePosition.X - 5) - _boundingBox.Width); if (_boundingBox.X < ScreenManager.GetInstance().GraphicsDevice.Viewport.X) //If tool tip starts off left of screen { _boundingBox.X = (int)(_mousePosition.X + 5); } break; } case LeftRightAlignment.Right: { _boundingBox.X = (int)(_mousePosition.X + 5); if (_boundingBox.X + _boundingBox.Width > ScreenManager.GetInstance().GraphicsDevice.Viewport.Width) //If tool tip ends off right of screen { _boundingBox.X = (int)((_mousePosition.X - 5) - _boundingBox.Width); } break; } } switch (_upDownAlignment) { case UpDownAlignment.Up: { _boundingBox.Y = (int)((_mousePosition.Y - 5) - _boundingBox.Height); if (_boundingBox.Y < ScreenManager.GetInstance().GraphicsDevice.Viewport.Y) //If tool tip starts off top of screen { _boundingBox.Y = (int)(_mousePosition.Y + 5); } break; } case UpDownAlignment.Down: { _boundingBox.Y = (int)(_mousePosition.Y + 5); if (_boundingBox.Y + _boundingBox.Height > ScreenManager.GetInstance().GraphicsDevice.Viewport.Height) //If tool tip ends off bottom of screen { _boundingBox.Y = (int)((_mousePosition.Y - 5) - _boundingBox.Height); } break; } } }