当前位置: 首页>>代码示例>>C#>>正文


C# Ship.UpdateEngineNumber方法代码示例

本文整理汇总了C#中Ship.UpdateEngineNumber方法的典型用法代码示例。如果您正苦于以下问题:C# Ship.UpdateEngineNumber方法的具体用法?C# Ship.UpdateEngineNumber怎么用?C# Ship.UpdateEngineNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ship的用法示例。


在下文中一共展示了Ship.UpdateEngineNumber方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RefreshValidButtons

        private void RefreshValidButtons()
        {
            //This function greys out all illegal buttons, and activates all legal buttons.  Illegal meaning that there isn't enough space for incrementation, or decrementation if the weapon count is 1
            float remainingSpace = _shipDesign.TotalSpace - _shipDesign.SpaceUsed;

            _computerButton.SetTextColor(AtLeastOneBetterComputer(remainingSpace) ? System.Drawing.Color.White : System.Drawing.Color.Tan, System.Drawing.Color.Empty);
            _shieldButton.SetTextColor(AtLeastOneBetterShield(remainingSpace) ? System.Drawing.Color.White : System.Drawing.Color.Tan, System.Drawing.Color.Empty);
            _ECMButton.SetTextColor(AtLeastOneBetterECM(remainingSpace) ? System.Drawing.Color.White : System.Drawing.Color.Tan, System.Drawing.Color.Empty);
            _engineButton.SetTextColor(AtLeastOneBetterEngine(remainingSpace) ? System.Drawing.Color.White : System.Drawing.Color.Tan, System.Drawing.Color.Empty);
            _maneuverButton.SetTextColor(AtLeastOneBetterManeuver(remainingSpace) ? System.Drawing.Color.White : System.Drawing.Color.Tan, System.Drawing.Color.Empty);
            _armorButton.SetTextColor(AtLeastOneBetterArmor(remainingSpace) ? System.Drawing.Color.White : System.Drawing.Color.Tan, System.Drawing.Color.Empty);

            for (int i = 0; i < _shipDesign.Weapons.Length; i++)
            {
                if (_shipDesign.Weapons[i].Key == null)
                {
                    _weaponButtons[i].SetTextColor(AtLeastOneBetterWeapon(new KeyValuePair<Equipment, int>(null, 0), remainingSpace) ? System.Drawing.Color.White : System.Drawing.Color.Tan, System.Drawing.Color.Empty);
                    _weaponCounts[i].Enabled = false;
                }
                else
                {
                    _weaponButtons[i].SetTextColor(AtLeastOneBetterWeapon(_shipDesign.Weapons[i], remainingSpace) ? System.Drawing.Color.White : System.Drawing.Color.Tan, System.Drawing.Color.Empty);
                    _weaponCounts[i].Enabled = true;
                    if (_shipDesign.Weapons[i].Key.GetSize(_techLevels, _shipDesign.Size) > remainingSpace)
                    {
                        _weaponCounts[i].UpButtonEnabled = false;
                    }
                    else
                    {
                        _weaponCounts[i].UpButtonEnabled = true;
                    }
                }
            }
            for (int i = 0; i < _shipDesign.Specials.Length; i++)
            {
                if (_shipDesign.Specials[i] != null)
                {
                    _specialButtons[i].SetTextColor(AtLeastOneHigherLevelSpecial(_shipDesign.Specials[i], remainingSpace) ? System.Drawing.Color.White : System.Drawing.Color.Tan, System.Drawing.Color.Empty);
                }
                else
                {
                    _specialButtons[i].SetTextColor(AtLeastOneHigherLevelSpecial(null, remainingSpace) ? System.Drawing.Color.White : System.Drawing.Color.Tan, System.Drawing.Color.Empty);
                }
            }
            for (int i = _shipDesign.Size; i <= Ship.HUGE; i++)
            {
                //Any sizes bigger than current one is enabled by default
                _shipSizeButtons[i].Enabled = true;
            }
            for (int i = _shipDesign.Size - 1; i >= Ship.SMALL; i--)
            {
                //Check if smaller ship size can contain all current equipments, if not, disable the buttons
                Ship testShip = new Ship(_shipDesign);
                testShip.Size = i;
                testShip.UpdateEngineNumber();
                if (testShip.SpaceUsed > testShip.TotalSpace)
                {
                    //invalid design, can't go smaller
                    for (int j = i; j >= Ship.SMALL; j--)
                    {
                        _shipSizeButtons[j].Enabled = false;
                    }
                    break;
                }
                _shipSizeButtons[i].Enabled = true;
            }
        }
开发者ID:Beyonders,项目名称:Beyond-Beyaan,代码行数:67,代码来源:ShipDesignScreen.cs


注:本文中的Ship.UpdateEngineNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。