/// <summary> /// Creates the instance with limbs, head and torso. /// </summary> /// <param name="origin">Origin of the robot.</param> /// <param name="model">ModelName of the robot.</param> /// <param name="pieces">List of pieces of the robot.</param> public Robot(EOrigin origin, EModelName model, List <RobotPiece> pieces) : this() { this.origin = origin; this.modelName = model; this.pieces = this.CloneList(pieces); }
/// <summary> /// Creates multiples pieces of the robot. /// </summary> /// <param name="metalType">Type Of metal of the robot.</param> /// <param name="origin">Origin of the robot.</param> /// <param name="modelName">Model name of the robot.</param> /// <param name="amountHead">Amount of heads of the robot.</param> /// <param name="amounTorso">Amount of torsos of the robot.</param> /// <param name="amountArms">Amount of arms of the robot.</param> /// <param name="amountLegs">Amount of legs of the robot.</param> /// <param name="amountTail">Amount of tails of the robot.</param> /// <param name="isRidable">boolean state that indicates if the robot is rideable or not.</param> private void ConfigureRobotForBuild(EMetalType metalType, EOrigin origin, EModelName modelName, int amountHead, int amounTorso, int amountArms, int amountLegs, int amountTail, bool isRidable) { amountOfMaterials = (int)modelName; int amountPieces = amountHead + amountArms + amountLegs + amounTorso + amountTail; int totalMaterialsForEachPiece = amountOfMaterials * amountPieces; if (RobotFactory.CheckAmountOfMaterialsInBuckets(totalMaterialsForEachPiece)) { Robot prototype; prototype = RobotFactory.CreateMultiplePiecesAndAddToStock(metalType, origin, modelName, amountOfMaterials, amountHead, amounTorso, amountArms, amountLegs, amountTail, isRidable); filename = prototype.Model.ToString(); absBioPath = $"{pathBiography}{filename}.bin"; prototype.LoadBioFile(absBioPath); try { if (RobotFactory.QualityControl(prototype, amountPieces)) { if (RobotFactory.AddRobotToWarehouse(prototype)) { ShowFormBuildingWithSound(); RobotFactory.SaveDataOfFactory(); prototype.SetSerialNumber(); DataAccessManager.InsertRobot(prototype); ShowFormISOWithSound(prototype); } } else { if (RobotFactory.DissasembleRobot(prototype)) { throw new QualityControlFailedException("There have a difference in the amount of pieces, Quality control has failed!. For safety reasons, the robot was dismantled and its materials recycled."); } } } catch (Exception e) { throw new Exception(e.Message, e); } } else { throw new InsufficientMaterialsException("Insufficients Materials to build this model of robot, you need to import more materials in the machine room or choose another model."); } }
/// <summary> /// Creates the instance with limbs, head and torso. /// </summary> /// <param name="origin">Origin of the robot.</param> /// <param name="model">ModelName of the robot.</param> /// <param name="pieces">List of pieces of the robot.</param> /// <param name="isRideable">A boolean state that indicate if it rideable or not.</param> public Robot(EOrigin origin, EModelName model, List <RobotPiece> pieces, bool isRideable) : this(origin, model, pieces) { this.isRideable = isRideable; }