示例#1
0
        /// <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.");
            }
        }
示例#2
0
 /// <summary>
 /// Creates the instance with the name of the piece and its material
 /// </summary>
 /// <param name="pieceType">Name of the entity.</param>
 /// <param name="metalType">Type of metal of the entity</param>
 /// <param name="material">Material of the entity</param>
 /// <param name="materials">Dictionary of materials Bucket</param>
 public RobotPiece(EPieceType pieceType, EMetalType metalType, EMaterial material, List <MaterialBucket> materials)
     : this(pieceType, metalType, material)
 {
     this.materials = materials;
 }
示例#3
0
 /// <summary>
 /// Creates the instance with the name of the piece and its material
 /// </summary>
 /// <param name="pieceType">Name of the entity.</param>
 /// <param name="metalType">Type of metal of the entity</param>
 /// <param name="material">Material of the entity</param>
 public RobotPiece(EPieceType pieceType, EMetalType metalType, EMaterial material) : base(pieceType.ToString(), material)
 {
     this.materials = new List <MaterialBucket>();
     this.metalType = metalType;
     this.PieceType = pieceType;
 }