public void CreateThrusters3() { BaseThrusters thruster = new BaseThrusters(200, 50, 80, "Thrusters Flame"); AssembleParts(thruster, thrustersThree); }
public void CreateThrusters2() { BaseThrusters thruster = new BaseThrusters(200, 50, 50, "Thrusters Color"); AssembleParts(thruster, thrustersTwo); }
/// <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); } }
public void CreateThrusters1() { BaseThrusters thruster = new BaseThrusters(200, 50, 20, "Thrusters Rust"); AssembleParts(thruster, thrustersOne); }
public void Create(BaseThrusters t) { Accessed = t; }