/// <summary>
        /// Adds a megaland border to the level
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static N8Level AddBorder(N8Level input)
        {
            for (int i = -2; i < 2; i++)
            {
                N8Block land1 = input.blocks.GenerateBlock("landmega", "border " + i);
                N8Block land2 = input.blocks.GenerateBlock("landmega", "border " + i);
                N8Block land3 = input.blocks.GenerateBlock("landmega", "border " + i);
                N8Block land4 = input.blocks.GenerateBlock("landmega", "border " + i);

                land1.position.X = i * -800;
                land2.position.X = i * 800;

                land1.position.Y = 1600;
                land2.position.Y = -1600;

                land3.position.Y = i * 800;
                land4.position.Y = i * -800;

                land3.position.X = 1600;
                land4.position.X = -1600;

            }

            return input;
        }
        public static void GenerateLevel()
        {
            string SavePath = @"C:\Program Files (x86)\N8\Saves\tronictest.ncd";
            string DefaultPath = @"C:\Program Files (x86)\N8\Saves\default.ncd";
            N8Level level = new N8Level(DefaultPath);

            TronicSequence ts = TronicSequence.StartFromButton();
            DataBlock Comma = ts.NewDataBlock("Comma");
            Comma.data = ",";
            DataBlock v = ts.NewDataBlock("V");
            v.data = "v";

            DataBlock OZ = ts.NewDataBlock("Z Offset", "1000");
            DataBlock OY = ts.NewDataBlock("Y Offset", "1000");
            DataBlock InitPos = ts.NewDataBlock("Initial Position", "v100,100,100");
            DataBlock DistanceOut = ts.NewDataBlock("Distance From Init");
            DataBlock ResetTimeout = ts.NewDataBlock("Reset Timeout", "10");

            DataBlock XYMin = ts.NewDataBlock("XY Min");
            XYMin.data = "-1000";

            DataBlock XYZMax = ts.NewDataBlock("XYZ Max");
            XYZMax.data = "1000";

            DataBlock ZMin = ts.NewDataBlock("Z Min");
            ZMin.data = "-1000";

            DataBlock PartialsA = ts.NewDataBlock("Partial Results A");
            DataBlock PartialsB = ts.NewDataBlock("Partial Results B");

            ts.Rand(XYMin.In, XYZMax.In, PartialsA.Out, "X Generator")
              .And(v.In, PartialsA.In, PartialsA.Out, "vX concat")
              .And(PartialsA.In, Comma.In, PartialsB.Out, "vX, concat")
              .Rand(ZMin.In, XYZMax.In, PartialsA.Out, "Z Generator")
              .Plus(PartialsA.In, OZ.In, PartialsA.Out, "Z Offset Adder")
              .And(PartialsB.In, PartialsA.In, PartialsB.Out, "vX,Z concat")
              .And(PartialsB.In, Comma.In, PartialsB.Out, "vX,Z, concat")
              .Rand(XYMin.In, XYZMax.In, PartialsA.Out, "Y Generator")
              .Subtract(PartialsA.In, OY.In, PartialsA.Out, "Y Offset Adder")
              .And(PartialsB.In, PartialsA.In, PartialsB.Out, "vX,Z,Y concat")
              .Display(PartialsB.In, "Final Result")
              .Mover(PartialsB.In, null, "Physical Location")
              .Distance(InitPos.In, PartialsB.In, DistanceOut.Out, "Distance Calculation")
              .Display(DistanceOut.In, "Distance Display")
              .Delay(ResetTimeout.In, "Reset timer")
              .Plus(InitPos.In, null, PartialsB.Out, "Reset swapper")
              .Mover(PartialsB.In, null, "Reset Mover");

            ts.LayoutLinear(new Vector3D(0, 0, 100));
            level.blocks.CopyFromDestructive(ts.tronics);
            Utilities.Save(SavePath, level);
        }
        public static N8Level GetLevel(string InputPath, Vector3D ShiftAmount)
        {
            N8Level Level = new N8Level(InputPath);
            foreach (N8Block b in Level.blocks.Blocks)
            {
                //If b is attached to something, it'll get rotated when whatever it's attached to is rotated.
                if (b.AttachedTo != null)
                {
                    b.position += ShiftAmount;
                }
            }

            return Level;
        }
        public static N8Level GetLevel(int height, Vector3D bottom, string BlockType, string BlockName, int BlockHeight, N8Level input = null)
        {
            N8Level level = input??new N8Level();

            for (int i = 0; i < height; i += BlockHeight)
            {
                N8Block StackBlock = level.blocks.GenerateBlock(BlockType, BlockName);
                //All blocks start off at the origin
                StackBlock.position.Z = i;
                StackBlock.position += bottom;
            }

            return level;
        }
        /// <summary>
        /// Translates a level, including all tronics (and vectors in tronics) contained within it.
        /// </summary>
        /// <param name="SavePath">Path from which the level should be loaded</param>
        /// <param name="offset">The offset the level should be moved by</param>
        /// <returns></returns>
        public static N8Level GetTranslatedLevel(string SavePath, Vector3D offset)
        {
            N8Level Level = new N8Level(SavePath);
            foreach (N8Block b in Level.blocks.Blocks)
            {
                //Only blocks which are not attached to something need to be translated
                //(for the ones that are attached to something, the translation will be handled
                //by the block they're attached to)
                if (b.AttachedTo == null)
                {
                    b.position += offset;
                }
            }

            //In tronics, we also need to translate the vectors in data blocks
            foreach (N8Tronic t in Level.blocks.Tronics)
            {
                if (t.AttachedTo == null)
                {
                    t.position += offset;
                }

                if (t.type == "cdata")
                {
                    if (t.IsVector())
                    {
                        Vector3D contents = t.DataToVector();
                        contents += offset;
                        t.data = contents.ToData();
                    }
                }
            }
            //And then make sure everything is in bounds
            {
                foreach (N8Tronic t in Level.blocks.Tronics)
                {
                    EnforceBounds(t);
                }
                foreach (N8Block b in Level.blocks.Blocks)
                {
                    EnforceBounds(b);
                }
            }

            Level = MinorModifiers.OrderLoading(Level, new Vector3D(0, 0, -1));

            return Level;
        }
        public static void GenerateLevel(string BasePath)
        {
            N8Level Base = new N8Level(BasePath);
            N8Level megadefault = new N8Level(@"C:\Program Files (x86)\N8\Saves\default.ncd");

            foreach (N8Block b in megadefault.blocks.Blocks)
            {
                b.position.Z -= 1;
            }

            Base.MergeWithDestructive(megadefault);

            string NewPath = Path.GetDirectoryName(BasePath) + "\\" + Path.GetFileNameWithoutExtension(BasePath) + "_defaulted.ncd";
            Console.WriteLine(NewPath);
            Console.Read();
            Utilities.Save(NewPath, Base);
        }
        public static N8Level AttachLevel(N8Level Input, N8Block To, bool Absolute = true)
        {
            var NotLands = Utilities.GetNotLands(Input);

            foreach (N8Block b in NotLands)
            {
                if (Absolute)
                {
                    To.AttachToMeAbsolute(b);
                }
                else
                {
                    To.AttachToMe(b);
                }
            }
            return Input;
        }
        public static void GenerateLevel()
        {
            string SavePath = @"C:\Program Files (x86)\N8\Saves\science.ncd";
            N8Level Level = new N8Level();

            TronicSequence ts = TronicSequence.StartFromButton(Level.blocks);
            ts.GetFirst().position.Z = 300;

            int counter = 0;
            for (int i = -4; i < 4; i++)
            {
                for (int j = -4; j < 4; j++)
                {
                    counter++;
                    int x = i * 250;
                    int y = j * 250;
                    N8Block pixel = Level.blocks.GenerateBlock("White QuadPixel", "" + counter);

                    DataBlock MoverData = ts.NewDataBlock("Mover Data", "v" + x + ",1000," + y);
                    DataBlock RotorData = ts.NewDataBlock("Rotor Data", "q0.7071069,0,-0.7071065,0");
                    RotorData.position.Z = 35;
                    MoverData.position.Z = 35;

                    ts.Rotor(RotorData.In, RotorData.Out, "" + counter);
                    Rotor r = (Rotor)ts.GetCurrent().Item1;
                    r.position.Z = 35;

                    ts.Mover(MoverData.In, MoverData.Out, "" + counter);
                    Mover m = (Mover)ts.GetCurrent().Item1;
                    m.position.Z = 35;

                    pixel.position.X = x;
                    pixel.position.Y = y;

                    pixel.AttachToMe(r);
                    pixel.AttachToMe(m);
                    pixel.AttachToMe(MoverData);
                    pixel.AttachToMe(RotorData);
                }
            }

            Utilities.Save(SavePath, Level);
        }
        public static void GenerateLevel()
        {
            N8Level level = new N8Level();
            string BlockType = "land";
            string BlockName = "Land";

            int blocksize = 400;
            for (int i = -2000 + blocksize / 2; i <= 2000 - blocksize / 2; i += blocksize)
            {
                for (int j = -2000 + blocksize / 2; j <= 2000 - blocksize / 2; j += blocksize)
                {
                    N8Block block = level.blocks.GenerateBlock(BlockType, BlockName);
                    block.position = new Vector3D(i, j, 0);
                }
            }

            level.MergeWithDestructive(GenerateStack.GetLevel(1000, new Vector3D(0, 0, -1000), "floor", "Stack", 65));

            Utilities.Save(@"C:\Program Files (x86)\N8\Saves\default_lands.ncd", level);
        }
        public static void GenerateLevel()
        {
            string SavePath = @"C:\Program Files (x86)\N8\Saves\geometry.ncd";

            N8Level Level = new N8Level();

            /*
            Spherical direction = new Spherical(0, Math.PI/4, Math.PI);

            direction.R = 100;

            N8Block b = Level.blocks.GenerateBlock("pole", "Test");

            b.position = direction.ToCartesian();
            b.rotation = direction.GetNormalRotation();
            */

            //Quaternion rotation = new Quaternion(0,0,0,1);
            //*

            string[] colors = {"blue", "green", "magenta"};
            var points = Utilities.GenerateTetrahedron(new Vector3D(0, 0, 0), 3, 160);
            for (int i = 0; i < 5; i++)
            {
                N8Block ControlPoint = Level.blocks.GenerateBlock("snowmancoal", "Control Point " + i);
                ControlPoint.position.Z = 100;
                foreach (var p in points)
                {
                    N8Block b = Level.blocks.GenerateBlock("cartridge." + colors[i%colors.Length] + "light", "Line");
                    b.position = p.Item1;
                    b.rotation = p.Item2;
                    ControlPoint.AttachToMe(b);
                }
            }

            Console.Read();
            //*/

            Utilities.Save(SavePath, Level);
        }
Пример #11
0
        public static N8Level GetLevel()
        {
            N8Level Level = new N8Level();

            Cylindrical c = new Cylindrical(500, 0, -1000);
            char[] bases = new char[] { 'a', 'c', 'g', 't' };
            Random rand = new Random();

            int max = Utilities.MAX_BLOCK_COUNT - 16;

            int BlocksPerRung = MakeRung(Level, c, bases[rand.Next(bases.Length)]);
            int NumRungs = max / BlocksPerRung;

            for (int i = 1; i < NumRungs; i++)
            {
                MakeRung(Level, c, bases[rand.Next(bases.Length)]);
            }

            Level = MinorModifiers.AddBorder(Level);

            return Level;
        }
        public static N8Level AddCrossroads(N8Level input)
        {
            N8Block land = input.blocks.GenerateBlock("street.highway.4way.cross", "Crossroads");
            for (int i = 0; i < 2; i++)
            {

                    N8Block landXp = input.blocks.GenerateBlock("street.highway.mega", "Crossings");
                    N8Block landYp = input.blocks.GenerateBlock("street.highway.mega", "Crossings");
                    N8Block landXm = input.blocks.GenerateBlock("street.highway.mega", "Crossings");
                    N8Block landYm = input.blocks.GenerateBlock("street.highway.mega", "Crossings");

                    landYp.rotation = new Quaternion(new Vector3D(0, 0, 1), 90);
                    landYm.rotation = new Quaternion(new Vector3D(0, 0, 1), 90);

                    landXp.position.X = i * 1000 + 935;
                    landXm.position.X = -(i * 1000 + 935);
                    landYp.position.Y = i * 1000 + 935;
                    landYm.position.Y = -(i * 1000 + 935);
            }

            return input;
        }
        public static void GenerateLevel(string LoadPath)
        {
            N8Level Level = new N8Level(LoadPath);

            N8Block ControlPoint = Level.blocks.GenerateBlock("letter.period", "Moon Control Point");
            ControlPoint.position.Z = 2000;
            //Load it as chibi, if available
            ControlPoint.Special = 2;
            Random rand = new Random();

            for (int i = 0; i < 50; i++)
            {
                N8Block moonblock = Level.blocks.GenerateBlock("simple.white.land.mega", "Moon");
                moonblock.position.Z = 1000;
                moonblock.rotation = rand.NextQuaternion();
                ControlPoint.AttachToMe(moonblock);
            }

            string SavePath = Path.GetDirectoryName(LoadPath) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(LoadPath) + "_moon.ncd";
            MinorModifiers.OrderLoading(Level, new Vector3D(0,0,1));
            Utilities.Save(SavePath, Level);
        }
        public static N8Level GetLevel()
        {
            N8Level ret = new N8Level(Utilities.GetDefaultSaveFolder() + "default");

            List<N8Block> bases = new List<N8Block>();
            List<Rotor> resets = new List<Rotor>();
            List<Rotor> falls = new List<Rotor>();

            DataBlock ResetData = ret.blocks.DataBlock("Reset", new Quaternion(new Vector3D(0,0,1), -90).ToData());
            ResetData.position = new Vector3D(10, 0, 100);
            DataBlock FallData = ret.blocks.DataBlock("Fall", (new Quaternion(new Vector3D(0, 1, 0), 90) * new Quaternion(new Vector3D(0, 0, 1), -90)).ToData());
            FallData.position = new Vector3D(10, 0, 100);

            Add Plus = ret.blocks.Plus();
            Plus.position.X = 1000;
            Plus.position.Y = -100;
            Plus.position.Z = 70;

            for (int i = 0; i < 25; i++)
            {
                var Unit = GenerateUnit(ret.blocks, "street.sign.x", "Hit me!");
                bases.Add(Unit.Item3);
                resets.Add(Unit.Item1);
                falls.Add(Unit.Item2);
                falls.Last().FlowOutTo(Plus);
                falls.Last().DataInA(FallData.In);
                resets.Last().DataInA(ResetData.In);

            }

            Subtract Minus = ret.blocks.Subtract();
            Minus.position.X = 1000;
            Minus.position.Y = 100;
            Minus.position.Z = 70;

            for (int i = 0; i < 25; i++)
            {
                var Unit = GenerateUnit(ret.blocks, "street.sign.heart", "Don't hit me!");
                bases.Add(Unit.Item3);
                resets.Add(Unit.Item1);
                falls.Add(Unit.Item2);
                falls.Last().FlowOutTo(Minus);
                falls.Last().DataInA(FallData.In);
                resets.Last().DataInA(ResetData.In);
            }

            Divide Reset = ret.blocks.Divide();

            Reset.position.X = 1000;
            Reset.position.Z = 70;

            FlowTronic previous = Reset;
            foreach (Rotor r in resets)
            {
                previous.FlowOutTo(r);
                previous = r;
            }

            int x = -350;
            int y = -350;

            for (int i = 0; i < bases.Count; i++)
            {
                bases[i].position = new Vector3D(x, y, 60);
                x += 100;
                if (x >= 350)
                {
                    x = -350;
                    y += 100;
                }
            }

            return ret;
        }
Пример #15
0
        private static int MakeRung(N8Level Level, Cylindrical current, char type)
        {
            int blockcount = 0;
            int tsteps = 5;
            int ttotal = 30;
            int rsteps = 7;
            double tstep = (ttotal * Utilities.DegToRad) / tsteps;
            double hstep = 30;
            bool runged = false;
            for (int i = 0; i < tsteps; i++)
            {
                string backbonecolor = "white";
                if ((i >= tsteps / 2) && !runged)
                {
                    backbonecolor = "black";
                }

                current.Theta += tstep;
                current.H += hstep;
                N8Block Block1 = Level.blocks.GenerateBlock("megapixel" + backbonecolor, "Phosphate Deoxyribose Backbone");
                blockcount++;
                N8Block Block2 = Level.blocks.GenerateBlock("megapixel" + backbonecolor, "Phosphate Deoxyribose Backbone");
                blockcount++;

                Block1.position = current.ToCartesian();
                Block1.rotation = current.GetNormalRotation();
                current.R = -current.R;

                Block2.position = current.ToCartesian();
                Block2.rotation = current.GetNormalRotation();
                current.R = -current.R;

                //Halfway up the ladder, do the rung
                if ((i >= tsteps / 2) && !runged)
                {
                    //T and C are slightly shorter than A and G, so we need to account for that.
                    //colorA is the longer color, colorB is the shorter one; if direction is negative we flip which direction we go.
                    string colorA;
                    string colorB;
                    string nameA;
                    string nameB;
                    int direction = 1;

                    switch (type)
                    {
                        case ('a'):
                            colorA = ADENINE_COLOR;
                            colorB = THYMINE_COLOR;
                            nameA = "Adenine";
                            nameB = "Thymine";
                            break;
                            //Why can't you just let me fall through?
                        case ('t'):
                            colorA = ADENINE_COLOR;
                            colorB = THYMINE_COLOR;
                            nameA = "Adenine";
                            nameB = "Thymine";
                            direction = -1;
                            break;
                        case ('g'):
                            colorA = GUANINE_COLOR;
                            colorB = CYTOSINE_COLOR;
                            nameA = "Guanine";
                            nameB = "Cytosine";
                            break;
                        case ('c'):
                            colorA = GUANINE_COLOR;
                            colorB = CYTOSINE_COLOR;
                            nameA = "Guanine";
                            nameB = "Cytosine";
                            direction = -1;
                            break;
                        default:
                            colorA = ERRORA_COLOR;
                            colorB = ERRORB_COLOR;
                            nameA = "Errornine";
                            nameB = "Errorsine";
                            break;
                    }
                    double initR = current.R;
                    current.R *= direction;

                    double rstep = (2 * current.R) / (double)rsteps;

                    int j;

                    for (j = 0; j < (rsteps / 2) - 1; j++)
                    {
                        N8Block shortblock = Level.blocks.GenerateBlock("pixel" + colorB, nameB);
                        blockcount++;
                        current.R -= rstep;
                        shortblock.position = current.ToCartesian();
                        shortblock.rotation = current.GetNormalRotation();
                    }

                    for (; j < rsteps-1; j++)
                    {
                        N8Block longblock = Level.blocks.GenerateBlock("pixel" + colorA, nameA);
                        blockcount++;
                        current.R -= rstep;
                        longblock.position = current.ToCartesian();
                        longblock.rotation = current.GetNormalRotation();
                    }

                    current.R = initR;
                    runged = true;
                }

            }

            return blockcount;
        }
        /// <summary>
        /// Rotates an entire level. Currently doesn't do tronics.
        /// </summary>
        /// <param name="Input"></param>
        /// <param name="RotationDegrees"></param>
        /// <param name="axis"></param>
        /// <returns></returns>
        public static N8Level RotateLevel(N8Level Input, double RotationDegrees, Vector3D axis)
        {
            var LevelBlocks = Input.blocks.Blocks;
            axis.Normalize();

            foreach (N8Block b in LevelBlocks)
            {
                Cylindrical c = new Cylindrical(b.position, axis);
                c.Theta += RotationDegrees * Utilities.DegToRad;
                b.position = c.ToCartesian();
                b.rotation = b.rotation * new Quaternion(axis, RotationDegrees);
            }

            return Input;
        }
Пример #17
0
        public static N8Level GetBlockOctopus()
        {
            N8Level Level = new N8Level();
            Random rand = new Random();
            int NumBlocks = 349;
            Vector3D diag1 = new Vector3D(1, 1, 0);
            diag1.Normalize();
            Vector3D diag2 = new Vector3D(1, -1, 0);
            diag2.Normalize();
            Vector3D plusX = new Vector3D(1, 0, 0);
            Vector3D plusY = new Vector3D(0, 1, 0);
            //Max distance for a diagonal is Sqrt(4000^2 + 4000^2) ~= 5656, and add an extra two just to make sure it reaches the edges
            int DiagMin = -5658 / 2;
            int DiagMax = 5658 / 2;
            int StraightMin = -2000;
            int StraightMax = 2000;
            for (int i = 0; i < NumBlocks; i++)
            {

                string color = colors[i % colors.Length];
                N8Block CurrentBlock = Level.blocks.GenerateBlock("simple." + color + ".block", names[rand.Next(names.Length)]);

                if (rand.Next(0, 2) == 0)
                {
                    int dmag = rand.Next(DiagMin, DiagMax);
                    if (rand.Next(0, 2) == 0)
                    {

                        CurrentBlock.position = diag1 * dmag;
                    }
                    else
                    {
                        CurrentBlock.position = diag2 * dmag;
                    }
                }
                else
                {
                    int smag = rand.Next(StraightMin, StraightMax);
                    if (rand.Next(0, 2) == 0)
                    {

                        CurrentBlock.position = plusX * smag;
                    }
                    else
                    {
                        CurrentBlock.position = plusY * smag;
                    }
                }

                CurrentBlock.rotation = rand.NextQuaternion();
            }

            //And now make it come up in the center - blocks closer to 0,0,0 get more of a boost.
            int MaxHeight = 300;
            foreach (N8Block b in Level.blocks.Blocks)
            {
                b.position.Z = Math.Round(Math.Min(100 / b.position.Length * MaxHeight, 600));
            }

            MinorModifiers.OrderLoadingCylindrical(Level);

            return Level;
        }
Пример #18
0
        public static N8Level GetCrossroads()
        {
            N8Level Level = new N8Level(); //MaxProtectTest.GetProxyBubble();
            MinorModifiers.AddCrossroads(Level);
            Random rand = new Random();

            int NumBlocks = 349 - (Level.blocks.Tronics.Count + Level.blocks.Blocks.Count);
            Console.WriteLine(NumBlocks);
            Console.ReadLine();
            for (int i = 0; i < NumBlocks; i++)
            {
                string color = colors[i % colors.Length];
                //string color = "black";
                N8Block CurrentBlock = Level.blocks.GenerateBlock("simple." + color + ".block", names[rand.Next(names.Length)]);
                //Keep it out of the crossroads
                CurrentBlock.position = rand.NextVector(new Vector3D(2000, 2000, -1000), new Vector3D(300, 300, 2000));

                //And flop it around the quadrants randomly
                if (rand.Next(0, 2) == 0)
                {
                    CurrentBlock.position.X *= -1;
                }
                if (rand.Next(0, 2) == 0)
                {
                    CurrentBlock.position.Y *= -1;
                }

                CurrentBlock.rotation = rand.NextQuaternion();
            }
            MinorModifiers.OrderLoadingCylindrical(Level);
            return Level;
        }
Пример #19
0
        public static N8Level GetBlockRoad(bool diagonal = false)
        {
            N8Level Level = new N8Level();
            Random rand = new Random();
            int NumBlocks = 349;
            if (diagonal)
            {
                Vector3D diag1 = new Vector3D(1, 1, 0);
                diag1.Normalize();
                Vector3D diag2 = new Vector3D(1, -1, 0);
                diag2.Normalize();
                //Max distance for a diagonal is Sqrt(4000^2 + 4000^2) ~= 5656, and add an extra two just to make sure it reaches the edges
                int Min = -5658 / 2;
                int Max = 5658 / 2;
                for (int i = 0; i < NumBlocks; i++)
                {
                    int mag = rand.Next(Min, Max);
                    string color = colors[i % colors.Length];
                    N8Block CurrentBlock = Level.blocks.GenerateBlock("simple." + color + ".block", names[rand.Next(names.Length)]);

                    if (rand.Next(0, 2) == 0)
                    {
                        CurrentBlock.position = diag1 * mag;
                    }
                    else
                    {
                        CurrentBlock.position = diag2 * mag;
                    }

                    CurrentBlock.rotation = rand.NextQuaternion();
                }
            }
            else
            {
                for (int i = 0; i < NumBlocks; i++)
                {
                    string color = colors[i % colors.Length];
                    N8Block CurrentBlock = Level.blocks.GenerateBlock("simple." + color + ".block", names[rand.Next(names.Length)]);
                    //Either put them in the x-coord area or the y-coord area (yes this means the center will be better covered)
                    if (rand.Next(0, 2) == 0)
                    {
                        CurrentBlock.position = rand.NextVector(new Vector3D(-100, 2000, 0), new Vector3D(100, -2000, 0));
                    }
                    else
                    {
                        CurrentBlock.position = rand.NextVector(new Vector3D(2000, -100, 0), new Vector3D(-2000, 100, 0));
                    }
                    CurrentBlock.rotation = rand.NextQuaternion();
                }
            }

            MinorModifiers.OrderLoading(Level, new Vector3D(1, 1, 0));

            return Level;
        }
        public static N8Level TranslateLevel(N8Level Input, Vector3D Offset)
        {
            //var NotLands = Utilities.GetNotLands(Input);

            foreach (N8Block b in Input.blocks.Blocks)
            {
                if(b.AttachedTo == null)
                    b.position += Offset;
            }

            foreach (N8Tronic t in Input.blocks.Tronics)
            {
                if (t.AttachedTo == null)
                    t.position += Offset;
            }

            return Input;
        }
 public static N8Level OrderLoadingCylindrical(N8Level Input)
 {
     Input.blocks.Blocks = Input.blocks.Blocks.OrderBy((b) => new Cylindrical(b.position).Theta).ToList();
     return Input;
 }
        /// <summary>
        /// Copies a block in input with ID blockID and puts it in NewPosition
        /// This will copy attachments and wirings too.
        /// Note that this does not work on tronics, though if a tronic is attached to a block it will be copied.
        /// </summary>
        /// <param name="input"></param>
        /// <param name="BlockID"></param>
        /// <param name="NewPosition"></param>
        /// <returns></returns>
        public static N8Level CopyBlock(N8Level input, int BlockID, Vector3D NewPosition)
        {
            N8Block ToCopy = (from N8Block b in input.blocks.Blocks where b.ID == BlockID select b).First();

            N8Block Copy = input.blocks.GenerateBlock(ToCopy.type, ToCopy.name);
            Copy.position = NewPosition;

            foreach (N8Block b in ToCopy.Attachees)
            {
                if (b is N8Tronic)
                {

                }
            }

            return input;
        }
Пример #23
0
        public static void GenerateLevel()
        {
            string SavePath = @"C:\Program Files (x86)\N8\Saves\proxybubble.ncd";

            N8Level Level = new N8Level();

            N8BlockFactory LevelBlocks = Level.blocks;
            List<N8Tronic> ProxyBlocks = new List<N8Tronic>();

            //List<Tuple<Vector3D, Quaternion>> points = new List<Tuple<Vector3D, Quaternion>>();
            //points.AddRange(Utilities.EvenCircle(new Vector3D(0, 0, -1), 45, 45));
            /*
            points.AddRange(Utilities.EvenSphere(new Vector3D(0, 0, 50), 70, 150, (double)10 / 16 * Math.PI));
            points.AddRange(Utilities.EvenSphere(new Vector3D(0, 0, 50), 90, 250, (double)8 / 16 * Math.PI));
            points.AddRange(Utilities.EvenSphere(new Vector3D(0, 0, 50), 145, 350, (double)9 / 16 * Math.PI));
            points.AddRange(Utilities.EvenSphere(new Vector3D(0, 0, 50), 175, 450, (double)9 / 16 * Math.PI));
            */

            var b1 = Utilities.EvenSphere(new Vector3D(0, 0, 50), 70, 60);
            var b2 = Utilities.EvenSphere(new Vector3D(0, 0, 50), 45, 50);
            var b3 = Utilities.EvenSphere(new Vector3D(0, 0, 50), 80, 75);
            var b4 = Utilities.EvenSphere(new Vector3D(0, 0, 50), 30, 40);

            //points.AddRange(Utilities.EvenSphere(new Vector3D(0, 0, 50), 90, 250));
            // points.AddRange(Utilities.EvenSphere(new Vector3D(0, 0, 50), 145, 350));
            //points.AddRange(Utilities.EvenSphere(new Vector3D(0, 0, 50), 175, 450));

            Quaternion InitialRotation = new Quaternion(new Vector3D(0, 0, 1), -90) * new Quaternion(new Vector3D(0, 1, 0), 90);

            N8Block Bubble1 = LevelBlocks.GenerateBlock("snowmancoal", "Bubble 1 CP");
            Bubble1.position = new Vector3D(0, 200, 50);
            foreach (var t in b1)
            {
                Proxy p = LevelBlocks.Proxy("Bubble 1");
                p.position = t.Item1;
                p.rotation = t.Item2;
                Bubble1.AttachToMe(p);
            }

            N8Block Bubble2 = LevelBlocks.GenerateBlock("snowmancoal", "Bubble 2 CP");
            Bubble2.position = new Vector3D(0, -200, 50);
            foreach (var t in b2)
            {
                Proxy p = LevelBlocks.Proxy("Bubble 2");
                p.position = t.Item1;
                p.rotation = t.Item2;
                Bubble2.AttachToMe(p);
            }

            N8Block Bubble3 = LevelBlocks.GenerateBlock("snowmancoal", "Bubble 3 CP");
            Bubble3.position = new Vector3D(200, 0, 50);
            foreach (var t in b3)
            {
                Proxy p = LevelBlocks.Proxy("Bubble 3");
                p.position = t.Item1;
                p.rotation = t.Item2;
                Bubble3.AttachToMe(p);
            }

            N8Block Bubble4 = LevelBlocks.GenerateBlock("snowmancoal", "Bubble 4 CP");
            Bubble4.position = new Vector3D(-200, 0, 50);
            foreach (var t in b4)
            {
                Proxy p = LevelBlocks.Proxy("Bubble 4");
                p.position = t.Item1;
                p.rotation = t.Item2;
                Bubble4.AttachToMe(p);
            }

            Utilities.Save(SavePath, Level);
        }
 /// <summary>
 /// Changes the order in which blocks appear on the level, by changing their location in the list of blocks. Currently does not affect tronics.
 /// </summary>
 /// <param name="Input">The level to modify</param>
 /// <param name="Direction">The "direction" in which blocks should load; for instance, (0,0,1) would load blocks from the bottom of the level upwards, whereas (0,0,-1) would do the opposite. You can think of the value as being which component is more important; (1,2,0) would mean "when loading, the Y cooridnate is twice as important as X".</param>
 /// <returns>The modified level; note that the level is already modified in place</returns>
 public static N8Level OrderLoading(N8Level Input, Vector3D Direction)
 {
     Input.blocks.Blocks = Input.blocks.Blocks.OrderBy((b) => Utilities.DotProduct(b.position, Direction)).ToList();
     return Input;
 }