Beyond_Beyaan.Screens.ColonizeScreen.MouseUp C# (CSharp) Метод

MouseUp() публичный Метод

public MouseUp ( int x, int y ) : bool
x int
y int
Результат bool
        public override bool MouseUp(int x, int y)
        {
            if (!_colonizing)
            {
                for (int i = 0; i < _maxShips; i++)
                {
                    if (_shipButtons[i].MouseUp(x, y))
                    {
                        foreach (var button in _shipButtons)
                        {
                            button.Selected = false;
                        }
                        _shipButtons[i].Selected = true;
                    }
                }
                if (_cancelButton.MouseUp(x, y))
                {
                    if (Completed != null)
                    {
                        Completed();
                    }
                }
                if (_colonizeButton.MouseDown(x, y))
                {
                    int whichShip = 0;
                    for (int i = 0; i < _maxShips; i++)
                    {
                        if (_shipButtons[i].Selected)
                        {
                            whichShip = i;
                            break;
                        }
                    }
                    var ship = _colonyShips[whichShip];
                    _colonizingFleet.ColonizePlanet(ship);
                    _nameTextBox.SetText(_starSystem.Name);
                    //Select the textbox so it'd capture the keypresses
                    _nameTextBox.MouseDown(_gameMain.ScreenWidth / 2, _gameMain.ScreenHeight / 2);
                    _nameTextBox.MouseUp(_gameMain.ScreenWidth / 2, _gameMain.ScreenHeight / 2);
                    _landingShipPos = _gameMain.ScreenHeight / 2 - 300;
                    _groundView = _starSystem.Planets[0].GroundSprite;
                    _landingShip = _colonizingFleet.Empire.EmpireRace.LandingShip;
                    _showingText = false;
                    _colonizing = true;
                }
            }
            else
            {
                if (!_showingText)
                {
                    _showingText = true;
                    _landingShipPos = _gameMain.ScreenHeight / 2 + 50;
                }
                else
                {
                    if (!_nameTextBox.MouseUp(x, y) && !string.IsNullOrEmpty(_nameTextBox.Text))
                    {
                        _starSystem.Name = _nameTextBox.Text;
                        _colonizing = false;
                        _showingText = false;
                        //Done
                        if (Completed != null)
                        {
                            Completed();
                        }
                    }
                }
            }
            return false;
        }

Usage Example

 public void MouseUp(int x, int y, int whichButton)
 {
     if (whichButton != 1)
     {
         return;
     }
     if (_exploredSystemsThisTurn.Count > 0)
     {
         _exploredSystemsThisTurn[_whichEmpireFocusedOn].RemoveAt(0);
         if (_exploredSystemsThisTurn[_whichEmpireFocusedOn].Count > 0)
         {
             _systemInfoWindow.LoadExploredSystem(_exploredSystemsThisTurn[_whichEmpireFocusedOn][0]);
             _systemView.LoadSystem(_exploredSystemsThisTurn[_whichEmpireFocusedOn][0], _whichEmpireFocusedOn);
             _camera.CenterCamera(_exploredSystemsThisTurn[_whichEmpireFocusedOn][0].X, _exploredSystemsThisTurn[_whichEmpireFocusedOn][0].Y, 1);
         }
         else
         {
             _exploredSystemsThisTurn.Remove(_whichEmpireFocusedOn);
             if (_exploredSystemsThisTurn.Count > 0)                     //Hot seat humans
             {
                 foreach (var keyPair in _exploredSystemsThisTurn)
                 {
                     _whichEmpireFocusedOn = keyPair.Key;
                     break;
                 }
                 _systemInfoWindow.LoadExploredSystem(_exploredSystemsThisTurn[_whichEmpireFocusedOn][0]);
                 _systemView.LoadSystem(_exploredSystemsThisTurn[_whichEmpireFocusedOn][0], _whichEmpireFocusedOn);
                 _camera.CenterCamera(_exploredSystemsThisTurn[_whichEmpireFocusedOn][0].X, _exploredSystemsThisTurn[_whichEmpireFocusedOn][0].Y, 1);
             }
             else
             {
                 _camera.CenterCamera(_camera.Width / 2, _camera.Height / 2, _camera.MaxZoom);
             }
         }
     }
     if (_colonizableFleetsThisTurn.Count > 0)
     {
         _colonizeScreen.MouseUp(x, y);
     }
     if (_newResearchTopicsNeeded.Count > 0)
     {
         _researchPrompt.MouseUp(x, y);
     }
 }