Beyond_Beyaan.Screens.EquipmentSelection.RefreshLabels C# (CSharp) Метод

RefreshLabels() приватный Метод

private RefreshLabels ( ) : void
Результат void
        private void RefreshLabels()
        {
            float availableSpace = _shipDesign.TotalSpace - _shipDesign.SpaceUsed;
            //Add back the available space used by current equipment, if any, to accurately reflect the option of changing current equipment to another equipment
            switch (_equipmentType)
            {
                case EquipmentType.ARMOR:
                    {
                        availableSpace += _shipDesign.Armor.GetActualSize(_techLevels, _shipDesign.Size, _spacePerPower);
                    } break;
                case EquipmentType.COMPUTER:
                    {
                        if (_shipDesign.Computer != null)
                        {
                            availableSpace += _shipDesign.Computer.GetActualSize(_techLevels, _shipDesign.Size, _spacePerPower);
                        }
                    } break;
                case EquipmentType.SHIELD:
                    {
                        if (_shipDesign.Shield != null)
                        {
                            availableSpace += _shipDesign.Shield.GetActualSize(_techLevels, _shipDesign.Size, _spacePerPower);
                        }
                    } break;
                case EquipmentType.ECM:
                    {
                        if (_shipDesign.ECM != null)
                        {
                            availableSpace += _shipDesign.ECM.GetActualSize(_techLevels, _shipDesign.Size, _spacePerPower);
                        }
                    } break;
                case EquipmentType.ENGINE:
                    {
                        availableSpace += _shipDesign.Engine.Key.GetSize(_techLevels, _shipDesign.Size) * _shipDesign.Engine.Value;
                    } break;
                case EquipmentType.MANEUVER:
                    {
                        availableSpace += PowerRequiredForManeuver(_shipDesign.ManeuverSpeed) * _spacePerPower;
                    } break;
                case EquipmentType.SPECIAL:
                    {
                        if (_shipDesign.Specials[_slotNum] != null)
                        {
                            availableSpace += _shipDesign.Specials[_slotNum].GetActualSize(_techLevels, _shipDesign.Size, _spacePerPower);
                        }
                    } break;
                case EquipmentType.WEAPON:
                    {
                        if (_shipDesign.Weapons[_slotNum].Key != null)
                        {
                            availableSpace += _shipDesign.Weapons[_slotNum].Key.GetActualSize(_techLevels, _shipDesign.Size, _spacePerPower) * _shipDesign.Weapons[_slotNum].Value;
                        }
                    } break;
            }

            if (_equipmentType == EquipmentType.MANEUVER)
            {
                //Unique condition since Maneuver isn't actually an equipment
                for (int i = 0; i < _shipDesign.Engine.Key.Technology.ManeuverSpeed; i++)
                {
                    int powerReq = PowerRequiredForManeuver(i + 1);
                    _columnValues[0][i].SetText(string.Format("Class {0}", i + 1));
                    _columnValues[1][i].SetText(string.Format("{0}", (i + 2) / 2));
                    _columnValues[2][i].SetText(string.Format("{0:0.0}", powerReq * _costPerPower));
                    _columnValues[3][i].SetText(string.Format("{0:0.0}", powerReq));
                    _columnValues[4][i].SetText(string.Format("{0:0.0}", powerReq * _spacePerPower));
                    _buttons[i].SetToolTipText("Maneuver Rating of " + (i + 1));
                    if (powerReq * _spacePerPower > availableSpace)
                    {
                        // TODO: Add restrictions for specials, i.e. having an colony special disables all other colony options.  Having an special restricts that from being available for other slots.  Etc.

                        _buttons[i].Enabled = false;
                        for (int j = 0; j <= _numOfColumnsVisible; j++)
                        {
                            _columnValues[j][i].SetColor(System.Drawing.Color.Tan, System.Drawing.Color.Empty);
                        }
                    }
                    else
                    {
                        _buttons[i].Enabled = true;
                        for (int j = 0; j <= _numOfColumnsVisible; j++)
                        {
                            _columnValues[j][i].SetColor(System.Drawing.Color.White, System.Drawing.Color.Empty);
                        }
                    }
                }
                return;
            }
            for (int i = 0; i < _maxVisible; i++)
            {
                SetText(i);
                if (_availableEquipments[i + _scrollBar.TopIndex].Technology == null)
                {
                    //None is always available
                    _buttons[i].Enabled = true;
                    for (int j = 0; j <= _numOfColumnsVisible; j++)
                    {
                        _columnValues[j][i].SetColor(System.Drawing.Color.White, System.Drawing.Color.Empty);
                    }
                }
                else if (_availableEquipments[i + _scrollBar.TopIndex].GetActualSize(_techLevels, _shipDesign.Size, _spacePerPower) > availableSpace)
                {
                    _buttons[i].Enabled = false;
                    for (int j = 0; j <= _numOfColumnsVisible; j++)
                    {
                        _columnValues[j][i].SetColor(System.Drawing.Color.Tan, System.Drawing.Color.Empty);
                    }
                }
                else
                {
                    _buttons[i].Enabled = true;
                    for (int j = 0; j <= _numOfColumnsVisible; j++)
                    {
                        _columnValues[j][i].SetColor(System.Drawing.Color.White, System.Drawing.Color.Empty);
                    }
                }
            }
        }