Esempio n. 1
0
        public static void Main()
        {
            int armorThickness = 2;
            int hullThickness  = 6;

            SizingBox box = new SizingBox()
            {
                Length = 65, Height = 45, Width = 25
            };
            double segWidth  = box.Width / Math.Ceiling(box.Width / 10.0);
            double segHeight = box.Height / Math.Ceiling(box.Height / 10.0);
            double segLength = box.Length / Math.Ceiling(box.Length / 10.0);

            int xEdgeSegs = (int)(box.Width / segWidth);
            int yEdgeSegs = (int)(box.Height / segHeight);
            int zEdgeSegs = (int)(box.Length / segLength);

            int edgeSegs  = Math.Max(2 * ((xEdgeSegs - 1) * (yEdgeSegs - 1)), 0) + Math.Max(2 * ((xEdgeSegs - 1) * (zEdgeSegs - 1)), 0) + Math.Max(2 * ((yEdgeSegs - 1) * (zEdgeSegs - 1)), 0);
            int totalSegs = xEdgeSegs * yEdgeSegs * zEdgeSegs;

            double avgSegCvg = segLength * segHeight * segLength / 1000;

            Ship ship = new Ship();
            List <ShipSegment> segments = new List <ShipSegment>();

            ship.Segments = segments;

            for (int x = 0; x < (box.Width / segWidth); x++)
            {
                for (int y = 0; y < (box.Height / segHeight); y++)
                {
                    for (int z = 0; z < (box.Length / segLength); z++)
                    {
                        int edgeCount = new bool[] { x == 0, x == xEdgeSegs - 1, y == yEdgeSegs - 1, y == 0, z == zEdgeSegs - 1, z == 0 }.Length;

                        segments.Add(new ShipSegment()
                        {
                            Armor = new Armor()
                            {
                                Material        = edgeCount > 1 ? Materials.Steel : Materials.None,
                                ThicknessInches = armorThickness,
                            },
                            Box = new SizingBox()
                            {
                                Height = segHeight,
                                Length = segLength,
                                Width  = segWidth
                            },
                            Coverage = avgSegCvg,
                            Hull     = new Hull()
                            {
                                Material        = edgeCount > 1 ? Materials.Oak : Materials.None,
                                ThicknessInches = hullThickness
                            },
                            Position = new Position <int>()
                            {
                                X = x, Y = y, Z = z
                            }
                        });
                    }
                }
            }

            double   steelVolume  = ship.GetMaterialVolume(Materials.Steel);
            double   oakVolume    = ship.GetMaterialVolume(Materials.Oak);
            Currency cost         = Materials.Steel.CostPerInch * (steelVolume * 12) + Materials.Oak.CostPerInch * (oakVolume * 12);
            double   craftPerWeek = (15 + 13 + 2 * 3) * 20;

            System.Console.WriteLine($"{box.Length}Lx{box.Width}Wx{box.Height}H");
            System.Console.WriteLine($"Volume: (Oak) { oakVolume * 9 * 12 } bd. ft., (Steel) { steelVolume * 9 } cu. ft.");
            System.Console.WriteLine($"Cost: { cost }");
            System.Console.WriteLine($"Structure: (Armor) {ship.TotalArmorStructure} pts, (Hull) {ship.TotalHullStructure} pts");
            System.Console.WriteLine($"Weight: { ship.TotalWeight } lb");
            System.Console.WriteLine($"Build Time: {Math.Ceiling(cost.AsGold() * 10.0D / craftPerWeek)} weeks");
            System.Console.WriteLine($"Segments: {ship.Segments.Count()}");
            System.Console.WriteLine($"Avg Segment Structure: {ship.Segments.Average(segment => segment.ArmorStructure + segment.HullStructure)}");
            System.Console.WriteLine(string.Concat(Enumerable.Repeat('-', System.Console.BufferWidth)));
        }