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

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

private SetText ( int whichRow ) : void
whichRow int
Результат void
        private void SetText(int whichRow)
        {
            var equipment = _availableEquipments[whichRow + _scrollBar.TopIndex];
            if (equipment.Technology == null)
            {
                _columnValues[0][whichRow].SetText("None");
                _buttons[whichRow].SetToolTipText("None");
            }
            else
            {
                _columnValues[0][whichRow].SetText(equipment.DisplayName);
                _buttons[whichRow].SetToolTipText(equipment.Technology.TechDescription);
            }
            switch (_equipmentType)
            {
                case EquipmentType.ARMOR:
                    {
                        _columnValues[1][whichRow].SetText(string.Format("{0:0.0}", equipment.GetActualCost(_techLevels, _shipDesign.Size, _costPerPower)));
                        _columnValues[2][whichRow].SetText(string.Format("{0:0.0}", equipment.GetActualSize(_techLevels, _shipDesign.Size, _spacePerPower)));
                    } break;
                case EquipmentType.COMPUTER:
                    {
                        if (equipment.Technology == null)
                        {
                            _columnValues[1][whichRow].SetText("0");
                            _columnValues[2][whichRow].SetText("0");
                            _columnValues[3][whichRow].SetText("0");
                            _columnValues[4][whichRow].SetText("0");
                        }
                        else
                        {
                            _columnValues[1][whichRow].SetText(string.Format("{0:0.0}", equipment.GetActualCost(_techLevels, _shipDesign.Size, _costPerPower)));
                            _columnValues[2][whichRow].SetText(string.Format("{0:0.0}", equipment.GetSize(_techLevels, _shipDesign.Size)));
                            _columnValues[3][whichRow].SetText(string.Format("{0:0.0}", equipment.GetPower(_shipDesign.Size)));
                            _columnValues[4][whichRow].SetText(string.Format("{0:0.0}", equipment.GetActualSize(_techLevels, _shipDesign.Size, _spacePerPower)));
                        }
                    } break;
                case EquipmentType.SHIELD:
                    {
                        if (equipment.Technology == null)
                        {
                            _columnValues[1][whichRow].SetText("0");
                            _columnValues[2][whichRow].SetText("0");
                            _columnValues[3][whichRow].SetText("0");
                            _columnValues[4][whichRow].SetText("0");
                        }
                        else
                        {
                            _columnValues[1][whichRow].SetText(string.Format("{0:0.0}", equipment.GetActualCost(_techLevels, _shipDesign.Size, _costPerPower)));
                            _columnValues[2][whichRow].SetText(string.Format("{0:0.0}", equipment.GetSize(_techLevels, _shipDesign.Size)));
                            _columnValues[3][whichRow].SetText(string.Format("{0:0.0}", equipment.GetPower(_shipDesign.Size)));
                            _columnValues[4][whichRow].SetText(string.Format("{0:0.0}", equipment.GetActualSize(_techLevels, _shipDesign.Size, _spacePerPower)));
                        }
                    } break;
                case EquipmentType.ECM:
                    {
                        if (equipment.Technology == null)
                        {
                            _columnValues[1][whichRow].SetText("0");
                            _columnValues[2][whichRow].SetText("0");
                            _columnValues[3][whichRow].SetText("0");
                            _columnValues[4][whichRow].SetText("0");
                        }
                        else
                        {
                            _columnValues[1][whichRow].SetText(string.Format("{0:0.0}", equipment.GetActualCost(_techLevels, _shipDesign.Size, _costPerPower)));
                            _columnValues[2][whichRow].SetText(string.Format("{0:0.0}", equipment.GetSize(_techLevels, _shipDesign.Size)));
                            _columnValues[3][whichRow].SetText(string.Format("{0:0.0}", equipment.GetPower(_shipDesign.Size)));
                            _columnValues[4][whichRow].SetText(string.Format("{0:0.0}", equipment.GetActualSize(_techLevels, _shipDesign.Size, _spacePerPower)));
                        }
                    } break;
                case EquipmentType.ENGINE:
                    {
                        float amountReq = _shipDesign.PowerUsed / (equipment.Technology.Speed * 10);
                        float size = equipment.GetSize(_techLevels, _shipDesign.Size);
                        _columnValues[1][whichRow].SetText(string.Format("{0:0.0}", equipment.GetCost(_techLevels, _shipDesign.Size)));
                        _columnValues[2][whichRow].SetText(string.Format("{0:0.0}", size));
                        _columnValues[3][whichRow].SetText(string.Format("{0:0.0}", amountReq));
                        _columnValues[4][whichRow].SetText(string.Format("{0:0.0}", amountReq * size));
                    } break;
                case EquipmentType.SPECIAL:
                    {
                        if (equipment.Technology == null)
                        {
                            _columnValues[1][whichRow].SetText("0");
                            _columnValues[2][whichRow].SetText("0");
                            _columnValues[3][whichRow].SetText("0");
                            _columnValues[4][whichRow].SetText("0");
                        }
                        else
                        {
                            _columnValues[1][whichRow].SetText(string.Format("{0:0.0}", equipment.GetActualCost(_techLevels, _shipDesign.Size, _costPerPower)));
                            _columnValues[2][whichRow].SetText(string.Format("{0:0.0}", equipment.GetSize(_techLevels, _shipDesign.Size)));
                            _columnValues[3][whichRow].SetText(string.Format("{0:0.0}", equipment.GetPower(_shipDesign.Size)));
                            _columnValues[4][whichRow].SetText(string.Format("{0:0.0}", equipment.GetActualSize(_techLevels, _shipDesign.Size, _spacePerPower)));
                        }
                    } break;
                case EquipmentType.WEAPON:
                {
                    if (equipment.Technology == null)
                    {
                        _columnValues[1][whichRow].SetText("0");
                        _columnValues[2][whichRow].SetText("0");
                        _columnValues[3][whichRow].SetText("0");
                        _columnValues[4][whichRow].SetText("0");
                        _columnValues[5][whichRow].SetText("0");
                        _columnValues[6][whichRow].SetText("0");
                    }
                    else
                    {
                        float availableSpace = _shipDesign.TotalSpace - _shipDesign.SpaceUsed;
                        if (_shipDesign.Weapons[_slotNum].Key != null)
                        {
                            availableSpace += _shipDesign.Weapons[_slotNum].Key.GetActualSize(_techLevels, _shipDesign.Size, _spacePerPower) * _shipDesign.Weapons[_slotNum].Value;
                        }
                        float actualSize = equipment.GetActualSize(_techLevels, _shipDesign.Size, _spacePerPower);
                        if (equipment.Technology.WeaponType == Technology.BEAM_WEAPON || equipment.Technology.WeaponType == Technology.BOMB_WEAPON)
                        {
                            _columnValues[1][whichRow].SetText(string.Format("{0}-{1}", equipment.GetMinDamage(), equipment.GetMaxDamage()));
                        }
                        else if (equipment.Technology.WeaponType != Technology.BIOLOGICAL_WEAPON)
                        {
                            _columnValues[1][whichRow].SetText(string.Format("{0}", equipment.GetMaxDamage()));
                        }
                        else
                        {
                            _columnValues[1][whichRow].SetText(string.Format("{0} POP", equipment.Technology.BioWeapon));
                        }
                        _columnValues[2][whichRow].SetText(string.Format("{0:0.0}", equipment.GetActualCost(_techLevels, _shipDesign.Size, _costPerPower)));
                        _columnValues[3][whichRow].SetText(string.Format("{0:0.0}", equipment.GetSize(_techLevels, _shipDesign.Size)));
                        _columnValues[4][whichRow].SetText(string.Format("{0:0.0}", equipment.GetPower(_shipDesign.Size)));
                        _columnValues[5][whichRow].SetText(string.Format("{0:0.0}", actualSize));
                        _columnValues[6][whichRow].SetText(string.Format("{0}", (int)(availableSpace / actualSize)));
                    }
                } break;
            }
        }