示例#1
0
        private void HandleLeftMousePressed(MoisManager input)
        {
            if (!StateManager.SupressGameControl)
            {
                if (!ContextMenu.HitTest(MousePosition(input)))
                {
                    ContextMenu.Visible = false;
                    if (canPlaceBuilding())
                    {
                        CityManager.NewBuilding(this.tempBuilding.PlotX, this.tempBuilding.PlotY, this.tempBuilding.Data.Configuration);
                        gConsole.WriteLine("Placing building...");

                        if (!input.IsKeyDown(KeyCode.KC_LSHIFT))
                        {
                            //Then dispose the cursor building as the game will be making a new one very shortly
                            CancelBuildingPlacement();
                            mouseMode = MouseMode.Selection;
                        }
                    }

                    if (canSelect())
                    {
                        Mogre.Pair <bool, Point> result = getPlotCoordsFromScreenPoint(MousePosition(input));
                        if (result.first)
                        {
                            CityManager.SetSelectionOrigin(result.second);
                        }
                    }

                    if (canZone() || canUnzone())
                    {
                        Mogre.Pair <bool, Point> result = getPlotCoordsFromScreenPoint(MousePosition(input));
                        if (result.first)
                        {
                            CityManager.SetScratchZoneOrigin(result.second);
                        }
                    }
                }
            }
        }
示例#2
0
        private void HandleKeyboard(MoisManager input)
        {
            if (!StateManager.SupressGameControl)
            {
                if (viewShouldUpdate())
                {
                    //WASD Control
                    int speed = 10;
                    if (input.IsKeyDown(KeyCode.KC_A))
                    {
                        CameraLeft(speed);
                    }
                    if (input.IsKeyDown(KeyCode.KC_W))
                    {
                        CameraForward(speed);
                    }
                    if (input.IsKeyDown(KeyCode.KC_D))
                    {
                        CameraRight(speed);
                    }
                    if (input.IsKeyDown(KeyCode.KC_S))
                    {
                        CameraBackward(speed);
                    }

                    //Q and E to rotate
                    if (input.IsKeyDown(KeyCode.KC_Q))
                    {
                        angle += 0.01f;
                    }
                    if (input.IsKeyDown(KeyCode.KC_E))
                    {
                        angle -= 0.01f;
                    }
                }

                //Tab to cycle zones
                if (input.WasKeyPressed(KeyCode.KC_TAB))
                {
                    if (mouseMode == MouseMode.DrawingZone)
                    {
                        CycleDrawnZone();
                    }
                }

                //Toggle the console with `
                if (input.WasKeyPressed(KeyCode.KC_GRAVE))
                {
                    ToggleConsole();
                }

                //Delete buildings with delete key
                if (input.WasKeyPressed(KeyCode.KC_DELETE))
                {
                    CityManager.DeleteSelectedBuildings();
                }

                //Escape to cancel current action
                if (input.WasKeyPressed(KeyCode.KC_ESCAPE))
                {
                    CancelCurrentAction();
                }
            }

            //Ctrl + W to quit the application
            if (input.WasKeyPressed(KeyCode.KC_W) && input.IsKeyDown(KeyCode.KC_LCONTROL))
            {
                StartShutdown();
            }
        }