Beispiel #1
0
        public void CreateCockpit3()
        {
            var cp = new BaseCockpit(40, 200, 0, 80, "Cockpit Flame");

            AssembleParts(cp, cockpitThree);
        }
Beispiel #2
0
        public void CreateCockpit2()
        {
            var cp = new BaseCockpit(30, 200, 0, 50, "Cockpit Color");

            AssembleParts(cp, cockpitTwo);
        }
Beispiel #3
0
        /// <summary>
        /// Function for adding and replacing parts in a list.
        /// Step 1) Checks the integer values that refer to the player's current amount of steel and fuel against the integer values of the object that represent its cost
        /// Step 2) Checks the type of the selected object that uses the interface IRocketParts.
        /// Step 3-1) Checks if an object of that type doesn't exists at any index of the list.
        /// Step 4) If Step 3-1 returns true:
        /// Adds the object to the list
        /// Increments the Rocket class's integer value total quality based on the object's integer value quality
        /// Decrements the values of the player's steel and fuel based on the object's steel and fuel cost values
        /// Sets an object to be equal to the selected object as current
        /// Exits the function
        /// Step 3-2) Else if Step 3-1 returns false, then check if an object of the same type exists in the list at any index and if the list doesn't contain the selected object
        /// Step 5) If Step 3-2 returns true:
        /// Decrement the Rocket's total quality based on the quality value the current object in the list,
        /// Remove the current object from the list,
        /// And repeat from the start until it meets a condition to exit the function
        /// </summary>
        /// <param name="selectedPart">
        /// The selected part.
        /// The object that the player is attempting to add to the list that will be checked.
        /// </param>
        public bool AddPart(IRocketParts selectedPart)
        {
            var spareList = this.allParts;

            if (User.SteelCount >= selectedPart.SteelCost && User.FuelCount >= selectedPart.FuelCost)
            {
                if (selectedPart is BaseCockpit)
                {
                    if (selectedPart.Name == currentCockpit.Name)
                    {
                        return(false);
                    }
                    else if (!spareList.OfType <BaseCockpit>().Any())
                    {
                        this.allParts.Add(selectedPart);
                        this.totalQuality  += selectedPart.Quality;
                        User.SteelCount    -= selectedPart.SteelCost;
                        User.FuelCount     -= selectedPart.FuelCost;
                        this.currentCockpit = selectedPart as BaseCockpit;
                    }
                    else if (spareList.OfType <BaseCockpit>().Any() && !spareList.Contains(selectedPart))
                    {
                        this.totalQuality -= this.currentCockpit.Quality;
                        this.allParts.Remove(this.currentCockpit);
                        this.AddPart(selectedPart);
                    }
                }
                else if (selectedPart is BaseThrusters)
                {
                    if (selectedPart.Name == currentThrusters.Name)
                    {
                        return(false);
                    }
                    else if (!spareList.OfType <BaseThrusters>().Any())
                    {
                        this.allParts.Add(selectedPart);
                        this.totalQuality    += selectedPart.Quality;
                        User.SteelCount      -= selectedPart.SteelCost;
                        User.FuelCount       -= selectedPart.FuelCost;
                        this.currentThrusters = selectedPart as BaseThrusters;
                    }
                    else if (spareList.OfType <BaseThrusters>().Any() && !spareList.Contains(selectedPart))
                    {
                        this.totalQuality -= this.currentThrusters.Quality;
                        this.allParts.Remove(this.currentThrusters);
                        this.AddPart(selectedPart);
                    }
                }
                else if (selectedPart is BaseWings)
                {
                    if (selectedPart.Name == currentWings.Name)
                    {
                        return(false);
                    }
                    else if (!spareList.OfType <BaseWings>().Any())
                    {
                        this.allParts.Add(selectedPart);
                        this.totalQuality += selectedPart.Quality;
                        User.SteelCount   -= selectedPart.SteelCost;
                        User.FuelCount    -= selectedPart.FuelCost;
                        this.currentWings  = selectedPart as BaseWings;
                    }
                    else if (spareList.OfType <BaseWings>().Any() && !spareList.Contains(selectedPart))
                    {
                        this.totalQuality -= this.currentWings.Quality;
                        this.allParts.Remove(this.currentWings);
                        this.AddPart(selectedPart);
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        public void CreateCockpit1()
        {
            var cp = new BaseCockpit(20, 200, 0, 20, "Cockpit Rust");

            AssembleParts(cp, cockpitOne);
        }
 public void Create(BaseCockpit c)
 {
     Accessed = c;
 }