示例#1
0
        public override void HandleInput(InputHelper helper, KeyManager manager)
        {
            // Mouse over overlay
            if (new Rectangle(MaxOfEmpires.overlayPos.ToPoint(), MaxOfEmpires.ScreenSize).Contains(helper.GetMousePosition(false)))
            {
                // Update the overlay
                overlay.update(helper);
            }

            // Mouse over grid (we hope >_>)
            else
            {
                // Handle input for the grid (things like moving and attacking units)
                ecoGrid.HandleInput(helper, manager);
            }

            // Get the Unit under the mouse...
            Unit unitUnderMouse = ecoGrid.GetTileUnderMouse(helper)?.Unit;

            // ... and the selected Unit...
            Unit selectedUnit = ecoGrid.SelectedTile?.Unit;

            // Show nothing by default
            PrintBuilderInfo(null);

            // ... and print their information if it's an Army...
            if (unitUnderMouse is Army)
            {
                PrintArmyInfo((Army)unitUnderMouse);
            }
            else if (selectedUnit is Army)
            {
                PrintArmyInfo((Army)selectedUnit);
            }
            else
            {
                PrintArmyInfo(null);
            }

            // ... or set the building information if it's a Builder...
            if (selectedUnit is Builder && !ecoGrid.SelectedTile.BuiltOn)
            {
                PrintBuilderInfo((Builder)selectedUnit);
            }

            // ... show the information of the currently selected Building...
            PrintBuildingInfo(ecoGrid.SelectedTile?.Building);

            if (manager.KeyPressed("nextTurn", helper))
            {
                shouldTurnUpdate = true;
            }
        }