Exemple #1
0
        /// <summary>
        /// Add the currently selected shipclass to the currently selected taskgroup
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddButton_Click(object sender, EventArgs e)
        {
            if (m_oCurrnetTaskGroup != null && m_oCurrnetShipClass != null)
            {
                int Number = 0;

                bool res = Int32.TryParse(m_oFastOOBPanel.NumberTextBox.Text, out Number);

                if (res == true && Number > 0)
                {
                    /// <summary>
                    /// Ship designs have to be locked if they are not.
                    /// </summary>
                    if (m_oCurrnetShipClass.IsLocked == false)
                    {
                        m_oCurrnetShipClass.IsLocked = true;
                    }

                    for (int loop = 0; loop < Number; loop++)
                    {
                        /// <summary>
                        /// Make the ship and subtract the appropriate amount from the faction Ship PB total.
                        /// </summary>
                        m_oCurrnetTaskGroup.AddShip(m_oCurrnetShipClass);
                        m_oCurrnetFaction.ShipBPTotal = m_oCurrnetFaction.ShipBPTotal - m_oCurrnetShipClass.BuildPointCost;

                        /// <summary>
                        /// Name the ship properly
                        /// </summary>
                        m_oCurrnetTaskGroup.Ships[m_oCurrnetTaskGroup.Ships.Count - 1].Name = m_oCurrnetShipClass.Name + " " + (m_oCurrnetShipClass.ShipsInClass.Count).ToString();

                        /// <summary>
                        /// Ship specific information that SMed ships will want to have, fuel, ordnance,etc.
                        /// </summary>
                        m_oCurrnetTaskGroup.Ships[m_oCurrnetTaskGroup.Ships.Count - 1].Refuel(1000000.0f);
                        if (m_oCurrnetShipClass.ShipClassOrdnance.Count != 0)
                        {
                            foreach (KeyValuePair <OrdnanceDefTN, int> pair in m_oCurrnetShipClass.ShipClassOrdnance)
                            {
                                m_oCurrnetTaskGroup.Ships[m_oCurrnetTaskGroup.Ships.Count - 1].ShipOrdnance.Add(pair.Key, pair.Value);
                            }

                            m_oCurrnetTaskGroup.Ships[m_oCurrnetTaskGroup.Ships.Count - 1].CurrentMagazineCapacity = m_oCurrnetShipClass.PreferredOrdnanceSize;
                        }
                    }

                    UpdateDisplay();
                }
            }
        }