Esempio n. 1
0
        internal static void Update(InputHandler input, CursorView cursorView, WorldView worldView, float deltaTime)
        {
            // if (predicate is true) do something

            if (worldView.GameStatus == GameStatus.OverlandMap || worldView.GameStatus == GameStatus.CityView)
            {
                if (input.HasMouseMoved)
                {
                    var e = new MouseEventArgs(input.Mouse, null, deltaTime);
                    UpdateCursorPositionEvent.HandleEvent(cursorView, e);
                }
            }

            if (worldView.GameStatus == GameStatus.OverlandMap)
            {
                if (worldView.IsMouseHoveringOverAStack(input.Mouse.Location))
                {
                    // enabled tooltip
                }
                else
                {
                    // disable tooltip
                }

                if (input.IsKeyReleased(Keys.Enter))
                {
                    worldView.EndTurn();
                }

                IsKeyReleased(input, worldView, Keys.NumPad1);
                IsKeyReleased(input, worldView, Keys.NumPad2);
                IsKeyReleased(input, worldView, Keys.NumPad3);
                IsKeyReleased(input, worldView, Keys.NumPad4);
                IsKeyReleased(input, worldView, Keys.NumPad6);
                IsKeyReleased(input, worldView, Keys.NumPad7);
                IsKeyReleased(input, worldView, Keys.NumPad8);
                IsKeyReleased(input, worldView, Keys.NumPad9);

                if (input.IsKeyReleased(Keys.C))
                {
                    worldView.FocusCameraOnCurrentlySelectedStackView();
                }

                if (input.IsKeyReleased(Keys.OemTilde))
                {
                    ResetCameraZoomEvent.HandleEvent(worldView.Camera, null);
                }

                if (input.IsLeftMouseButtonReleased)
                {
                    var startUnitMovement = worldView.CheckForUnitMovementOfCurrentlySelectedStackView(input.Mouse.Location);
                    if (startUnitMovement.startMovement)
                    {
                        worldView.StartUnitMovementOfCurrentlySelectedStackView(startUnitMovement.hexToMoveTo);
                    }

                    // check for click of unit in hudview
                    var unitClicked = worldView.CheckForUnitSelectionInHudView(input.Mouse.Location);
                    if (unitClicked.unitClicked)
                    {
                        // select/unselect unit
                        worldView.AddToCurrentlySelectedStack(unitClicked.unitView.Unit);
                        // TODO: need to remove the unit from its pre-existing stack
                    }
                }

                if (input.IsRightMouseButtonPressed)
                {
                    worldView.SetPotentialMovementOfCurrentlySelectedStackView();
                }

                if (input.IsRightMouseButtonReleased)
                {
                    worldView.ResetPotentialMovementOfCurrentlySelectedStackView();

                    var selectStack = worldView.CheckForSelectionOfStack(input.Mouse.Location);
                    if (selectStack.selectStack)
                    {
                        worldView.SelectStack(selectStack.stackToSelect);
                    }
                    else
                    {
                        var e = new MouseEventArgs(input.Mouse, worldView, deltaTime);
                        OpenSettlementEvent.HandleEvent(null, e);
                    }
                }

                if (input.MouseWheelUp)
                {
                    IncreaseCameraZoomEvent.HandleEvent(worldView.Camera, null);
                }

                if (input.MouseWheelDown)
                {
                    DecreaseCameraZoomEvent.HandleEvent(worldView.Camera, null);
                }

                if (input.IsMouseAtTopOfScreen || input.IsMouseAtBottomOfScreen || input.IsMouseAtLeftOfScreen || input.IsMouseAtRightOfScreen)
                {
                    var e = new MouseEventArgs(input.Mouse, null, deltaTime);
                    MoveCameraEvent.HandleEvent(worldView.Camera, e);
                }

                if (input.IsRightMouseButtonDown && input.HasMouseMoved)
                {
                    var e = new MouseEventArgs(input.Mouse, null, deltaTime);
                    DragCameraEvent.HandleEvent(worldView.Camera, e);
                }
            }
        }